Loading libs/binder/rust/src/binder.rs +5 −5 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ use std::cmp::Ordering; use std::convert::TryFrom; use std::ffi::{c_void, CStr, CString}; use std::fmt; use std::fs::File; use std::io::Write; use std::marker::PhantomData; use std::ops::Deref; use std::os::raw::c_char; Loading Loading @@ -62,7 +62,7 @@ pub trait Interface: Send + Sync + DowncastSync { /// /// This handler is a no-op by default and should be implemented for each /// Binder service struct that wishes to respond to dump transactions. fn dump(&self, _file: &File, _args: &[&CStr]) -> Result<()> { fn dump(&self, _writer: &mut dyn Write, _args: &[&CStr]) -> Result<()> { Ok(()) } } Loading Loading @@ -165,7 +165,7 @@ pub trait Remotable: Send + Sync + 'static { /// Handle a request to invoke the dump transaction on this /// object. fn on_dump(&self, file: &File, args: &[&CStr]) -> Result<()>; fn on_dump(&self, file: &mut dyn Write, args: &[&CStr]) -> Result<()>; /// Retrieve the class of this remote object. /// Loading Loading @@ -934,8 +934,8 @@ macro_rules! declare_binder_interface { } } fn on_dump(&self, file: &std::fs::File, args: &[&std::ffi::CStr]) -> std::result::Result<(), $crate::StatusCode> { self.0.dump(file, args) fn on_dump(&self, writer: &mut dyn std::io::Write, args: &[&std::ffi::CStr]) -> std::result::Result<(), $crate::StatusCode> { self.0.dump(writer, args) } fn get_class() -> $crate::binder_impl::InterfaceClass { Loading libs/binder/rust/src/native.rs +4 −3 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ use crate::sys; use std::convert::TryFrom; use std::ffi::{c_void, CStr, CString}; use std::fs::File; use std::io::Write; use std::mem::ManuallyDrop; use std::ops::Deref; use std::os::raw::c_char; Loading Loading @@ -341,7 +342,7 @@ impl<T: Remotable> InterfaceClassMethods for Binder<T> { } // Safety: Our caller promised that fd is a file descriptor. We don't // own this file descriptor, so we need to be careful not to drop it. let file = unsafe { ManuallyDrop::new(File::from_raw_fd(fd)) }; let mut file = unsafe { ManuallyDrop::new(File::from_raw_fd(fd)) }; if args.is_null() && num_args != 0 { return StatusCode::UNEXPECTED_NULL as status_t; Loading @@ -366,7 +367,7 @@ impl<T: Remotable> InterfaceClassMethods for Binder<T> { // Safety: Our caller promised that the binder has a `T` pointer in its // user data. let binder: &T = unsafe { &*(object as *const T) }; let res = binder.on_dump(&file, &args); let res = binder.on_dump(&mut *file, &args); match res { Ok(()) => 0, Loading Loading @@ -569,7 +570,7 @@ impl Remotable for () { Ok(()) } fn on_dump(&self, _file: &File, _args: &[&CStr]) -> Result<()> { fn on_dump(&self, _writer: &mut dyn Write, _args: &[&CStr]) -> Result<()> { Ok(()) } Loading libs/binder/rust/tests/integration.rs +2 −2 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ use binder::binder_impl::{ use std::convert::{TryFrom, TryInto}; use std::ffi::CStr; use std::fs::File; use std::io::Write; use std::sync::Mutex; /// Name of service runner. Loading Loading @@ -118,7 +118,7 @@ impl TryFrom<u32> for TestTransactionCode { } impl Interface for TestService { fn dump(&self, _file: &File, args: &[&CStr]) -> Result<(), StatusCode> { fn dump(&self, _writer: &mut dyn Write, args: &[&CStr]) -> Result<(), StatusCode> { let mut dump_args = self.dump_args.lock().unwrap(); dump_args.extend(args.iter().map(|s| s.to_str().unwrap().to_owned())); Ok(()) Loading Loading
libs/binder/rust/src/binder.rs +5 −5 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ use std::cmp::Ordering; use std::convert::TryFrom; use std::ffi::{c_void, CStr, CString}; use std::fmt; use std::fs::File; use std::io::Write; use std::marker::PhantomData; use std::ops::Deref; use std::os::raw::c_char; Loading Loading @@ -62,7 +62,7 @@ pub trait Interface: Send + Sync + DowncastSync { /// /// This handler is a no-op by default and should be implemented for each /// Binder service struct that wishes to respond to dump transactions. fn dump(&self, _file: &File, _args: &[&CStr]) -> Result<()> { fn dump(&self, _writer: &mut dyn Write, _args: &[&CStr]) -> Result<()> { Ok(()) } } Loading Loading @@ -165,7 +165,7 @@ pub trait Remotable: Send + Sync + 'static { /// Handle a request to invoke the dump transaction on this /// object. fn on_dump(&self, file: &File, args: &[&CStr]) -> Result<()>; fn on_dump(&self, file: &mut dyn Write, args: &[&CStr]) -> Result<()>; /// Retrieve the class of this remote object. /// Loading Loading @@ -934,8 +934,8 @@ macro_rules! declare_binder_interface { } } fn on_dump(&self, file: &std::fs::File, args: &[&std::ffi::CStr]) -> std::result::Result<(), $crate::StatusCode> { self.0.dump(file, args) fn on_dump(&self, writer: &mut dyn std::io::Write, args: &[&std::ffi::CStr]) -> std::result::Result<(), $crate::StatusCode> { self.0.dump(writer, args) } fn get_class() -> $crate::binder_impl::InterfaceClass { Loading
libs/binder/rust/src/native.rs +4 −3 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ use crate::sys; use std::convert::TryFrom; use std::ffi::{c_void, CStr, CString}; use std::fs::File; use std::io::Write; use std::mem::ManuallyDrop; use std::ops::Deref; use std::os::raw::c_char; Loading Loading @@ -341,7 +342,7 @@ impl<T: Remotable> InterfaceClassMethods for Binder<T> { } // Safety: Our caller promised that fd is a file descriptor. We don't // own this file descriptor, so we need to be careful not to drop it. let file = unsafe { ManuallyDrop::new(File::from_raw_fd(fd)) }; let mut file = unsafe { ManuallyDrop::new(File::from_raw_fd(fd)) }; if args.is_null() && num_args != 0 { return StatusCode::UNEXPECTED_NULL as status_t; Loading @@ -366,7 +367,7 @@ impl<T: Remotable> InterfaceClassMethods for Binder<T> { // Safety: Our caller promised that the binder has a `T` pointer in its // user data. let binder: &T = unsafe { &*(object as *const T) }; let res = binder.on_dump(&file, &args); let res = binder.on_dump(&mut *file, &args); match res { Ok(()) => 0, Loading Loading @@ -569,7 +570,7 @@ impl Remotable for () { Ok(()) } fn on_dump(&self, _file: &File, _args: &[&CStr]) -> Result<()> { fn on_dump(&self, _writer: &mut dyn Write, _args: &[&CStr]) -> Result<()> { Ok(()) } Loading
libs/binder/rust/tests/integration.rs +2 −2 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ use binder::binder_impl::{ use std::convert::{TryFrom, TryInto}; use std::ffi::CStr; use std::fs::File; use std::io::Write; use std::sync::Mutex; /// Name of service runner. Loading Loading @@ -118,7 +118,7 @@ impl TryFrom<u32> for TestTransactionCode { } impl Interface for TestService { fn dump(&self, _file: &File, args: &[&CStr]) -> Result<(), StatusCode> { fn dump(&self, _writer: &mut dyn Write, args: &[&CStr]) -> Result<(), StatusCode> { let mut dump_args = self.dump_args.lock().unwrap(); dump_args.extend(args.iter().map(|s| s.to_str().unwrap().to_owned())); Ok(()) Loading