use binder::{
binder_impl::{Deserialize, Serialize},
FromIBinder, SpIBinder, Strong,
};
#[path = "com/android/internal/os/IResultReceiver.rs"]
#[allow(unused_qualifications, clippy::identity_op)]
mod iresultreceiver;
pub use iresultreceiver::*;
pub(crate) mod mangled {
#[allow(non_camel_case_types)]
pub(crate) type _7_android_2_os_14_ResultReceiver = super::ResultReceiver;
}
#[derive(Debug)]
pub(crate) struct ResultReceiver {
binder: Strong<dyn IResultReceiver>,
}
impl ResultReceiver {
pub fn new<T: IResultReceiver + Send + Sync + 'static>(receiver: T) -> Self {
let binder = BnResultReceiver::new_binder(
receiver,
binder::BinderFeatures {
set_requesting_sid: true,
_non_exhaustive: (),
},
);
Self { binder }
}
}
impl Serialize for ResultReceiver {
fn serialize(
&self,
parcel: &mut binder::binder_impl::BorrowedParcel<'_>,
) -> Result<(), binder::StatusCode> {
parcel.write(&1i32)?;
self.binder.as_binder().serialize(parcel)
}
}
impl Deserialize for ResultReceiver {
fn deserialize(
parcel: &binder::binder_impl::BorrowedParcel<'_>,
) -> Result<Self, binder::StatusCode> {
let is_set: i32 = parcel.read()?; assert_eq!(is_set, 1);
SpIBinder::deserialize(parcel).map(|binder| Self {
binder: <dyn IResultReceiver as FromIBinder>::try_from(binder)
.expect("Wrong binder type"),
})
}
}