[−][src]Struct remote_trait_object::ServiceToExport
A special wrapper of skeleton, used to export a service object.
You can make any smart pointer of a trait object into a ServiceToExport
as far as the trait is a subtrait of Service and marked with the macro service.
The only way to actually export a ServiceToExport is either
- Returning it while handling a method in another service
- Passing as an argument in a remote call
ServiceToExport is a compatible type with ServiceToImport and ServiceRef
You can import a proxy object by putting one of those two types on the same place in the client side.
See Service Compatibility section
ServiceToExport is a wrapper of Skeleton that hides the detail exchange process.
However you don't have to know what Skeleton is, unless you're going to perform raw export and import.
NOTE: it implements Serialize, but you must NEVER try to serialize it.
It has a side effect of registering the service object in the context,
and so should be called only by remote-trait-object's internal process.
Example
use remote_trait_object::*; use std::sync::Arc; use parking_lot::RwLock; #[service(no_proxy)] pub trait Hello: Service { fn hello(&self) -> Vec<ServiceToExport<dyn Hello>>; } struct A; impl Service for A {} impl Hello for A { fn hello(&self) -> Vec<ServiceToExport<dyn Hello>> { // Export by return vec![ ServiceToExport::new(Box::new(A) as Box<dyn Hello>), ServiceToExport::new(Arc::new(A) as Arc<dyn Hello>), ServiceToExport::new(Arc::new(RwLock::new(A)) as Arc<RwLock<dyn Hello>>), ] } }
Implementations
impl<T: ?Sized + Service> ServiceToExport<T>[src]
pub fn new(service: impl IntoSkeleton<T>) -> Self[src]
Creates a new instance from a smart pointer of a service object.
Trait Implementations
impl<T: ?Sized + Service> Serialize for ServiceToExport<T>[src]
Auto Trait Implementations
impl<T> !RefUnwindSafe for ServiceToExport<T>
impl<T: ?Sized> Send for ServiceToExport<T>
impl<T> !Sync for ServiceToExport<T>
impl<T: ?Sized> Unpin for ServiceToExport<T> where
T: Unpin,
T: Unpin,
impl<T> !UnwindSafe for ServiceToExport<T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,