Loading libs/binder/rust/binder_tokio/lib.rs +22 −1 Original line number Original line Diff line number Diff line Loading @@ -29,7 +29,7 @@ //! [`Tokio`]: crate::Tokio //! [`Tokio`]: crate::Tokio use binder::public_api::{BinderAsyncPool, BoxFuture, Strong}; use binder::public_api::{BinderAsyncPool, BoxFuture, Strong}; use binder::{FromIBinder, StatusCode}; use binder::{FromIBinder, StatusCode, BinderAsyncRuntime}; use std::future::Future; use std::future::Future; /// Retrieve an existing service for a particular interface, sleeping for a few /// Retrieve an existing service for a particular interface, sleeping for a few Loading Loading @@ -120,3 +120,24 @@ impl BinderAsyncPool for Tokio { } } } } } } /// Wrapper around Tokio runtime types for providing a runtime to a binder server. pub struct TokioRuntime<R>(pub R); impl BinderAsyncRuntime for TokioRuntime<tokio::runtime::Runtime> { fn block_on<F: Future>(&self, future: F) -> F::Output { self.0.block_on(future) } } impl BinderAsyncRuntime for TokioRuntime<std::sync::Arc<tokio::runtime::Runtime>> { fn block_on<F: Future>(&self, future: F) -> F::Output { self.0.block_on(future) } } impl BinderAsyncRuntime for TokioRuntime<tokio::runtime::Handle> { fn block_on<F: Future>(&self, future: F) -> F::Output { self.0.block_on(future) } } libs/binder/rust/src/binder_async.rs +6 −0 Original line number Original line Diff line number Diff line Loading @@ -53,3 +53,9 @@ pub trait BinderAsyncPool { B: Send + 'a, B: Send + 'a, E: From<crate::StatusCode>; E: From<crate::StatusCode>; } } /// A runtime for executing an async binder server. pub trait BinderAsyncRuntime { /// Block on the provided future, running it to completion and returning its output. fn block_on<F: Future>(&self, future: F) -> F::Output; } libs/binder/rust/src/lib.rs +1 −1 Original line number Original line Diff line number Diff line Loading @@ -112,7 +112,7 @@ pub use crate::binder::{ Stability, Strong, ToAsyncInterface, ToSyncInterface, TransactionCode, TransactionFlags, Weak, Stability, Strong, ToAsyncInterface, ToSyncInterface, TransactionCode, TransactionFlags, Weak, FIRST_CALL_TRANSACTION, FLAG_CLEAR_BUF, FLAG_ONEWAY, FLAG_PRIVATE_LOCAL, LAST_CALL_TRANSACTION, FIRST_CALL_TRANSACTION, FLAG_CLEAR_BUF, FLAG_ONEWAY, FLAG_PRIVATE_LOCAL, LAST_CALL_TRANSACTION, }; }; pub use crate::binder_async::{BoxFuture, BinderAsyncPool}; pub use crate::binder_async::{BoxFuture, BinderAsyncPool, BinderAsyncRuntime}; pub use error::{status_t, ExceptionCode, Result, Status, StatusCode}; pub use error::{status_t, ExceptionCode, Result, Status, StatusCode}; pub use native::{add_service, force_lazy_services_persist, is_handling_transaction, register_lazy_service, Binder}; pub use native::{add_service, force_lazy_services_persist, is_handling_transaction, register_lazy_service, Binder}; pub use parcel::{BorrowedParcel, Parcel}; pub use parcel::{BorrowedParcel, Parcel}; Loading Loading
libs/binder/rust/binder_tokio/lib.rs +22 −1 Original line number Original line Diff line number Diff line Loading @@ -29,7 +29,7 @@ //! [`Tokio`]: crate::Tokio //! [`Tokio`]: crate::Tokio use binder::public_api::{BinderAsyncPool, BoxFuture, Strong}; use binder::public_api::{BinderAsyncPool, BoxFuture, Strong}; use binder::{FromIBinder, StatusCode}; use binder::{FromIBinder, StatusCode, BinderAsyncRuntime}; use std::future::Future; use std::future::Future; /// Retrieve an existing service for a particular interface, sleeping for a few /// Retrieve an existing service for a particular interface, sleeping for a few Loading Loading @@ -120,3 +120,24 @@ impl BinderAsyncPool for Tokio { } } } } } } /// Wrapper around Tokio runtime types for providing a runtime to a binder server. pub struct TokioRuntime<R>(pub R); impl BinderAsyncRuntime for TokioRuntime<tokio::runtime::Runtime> { fn block_on<F: Future>(&self, future: F) -> F::Output { self.0.block_on(future) } } impl BinderAsyncRuntime for TokioRuntime<std::sync::Arc<tokio::runtime::Runtime>> { fn block_on<F: Future>(&self, future: F) -> F::Output { self.0.block_on(future) } } impl BinderAsyncRuntime for TokioRuntime<tokio::runtime::Handle> { fn block_on<F: Future>(&self, future: F) -> F::Output { self.0.block_on(future) } }
libs/binder/rust/src/binder_async.rs +6 −0 Original line number Original line Diff line number Diff line Loading @@ -53,3 +53,9 @@ pub trait BinderAsyncPool { B: Send + 'a, B: Send + 'a, E: From<crate::StatusCode>; E: From<crate::StatusCode>; } } /// A runtime for executing an async binder server. pub trait BinderAsyncRuntime { /// Block on the provided future, running it to completion and returning its output. fn block_on<F: Future>(&self, future: F) -> F::Output; }
libs/binder/rust/src/lib.rs +1 −1 Original line number Original line Diff line number Diff line Loading @@ -112,7 +112,7 @@ pub use crate::binder::{ Stability, Strong, ToAsyncInterface, ToSyncInterface, TransactionCode, TransactionFlags, Weak, Stability, Strong, ToAsyncInterface, ToSyncInterface, TransactionCode, TransactionFlags, Weak, FIRST_CALL_TRANSACTION, FLAG_CLEAR_BUF, FLAG_ONEWAY, FLAG_PRIVATE_LOCAL, LAST_CALL_TRANSACTION, FIRST_CALL_TRANSACTION, FLAG_CLEAR_BUF, FLAG_ONEWAY, FLAG_PRIVATE_LOCAL, LAST_CALL_TRANSACTION, }; }; pub use crate::binder_async::{BoxFuture, BinderAsyncPool}; pub use crate::binder_async::{BoxFuture, BinderAsyncPool, BinderAsyncRuntime}; pub use error::{status_t, ExceptionCode, Result, Status, StatusCode}; pub use error::{status_t, ExceptionCode, Result, Status, StatusCode}; pub use native::{add_service, force_lazy_services_persist, is_handling_transaction, register_lazy_service, Binder}; pub use native::{add_service, force_lazy_services_persist, is_handling_transaction, register_lazy_service, Binder}; pub use parcel::{BorrowedParcel, Parcel}; pub use parcel::{BorrowedParcel, Parcel}; Loading