pub struct Service<E> { /* private fields */ }Expand description
A typed service. Methods execute once; only the portable entrypoint invokes serde.
Implementations§
Source§impl<E: 'static> Service<E>
impl<E: 'static> Service<E>
Sourcepub fn new(
name: impl Into<String>,
create: impl Fn(Declaration) -> Result<E> + 'static,
) -> Self
pub fn new( name: impl Into<String>, create: impl Fn(Declaration) -> Result<E> + 'static, ) -> Self
Create a native declaration with explicit identity and default options.
Sourcepub fn before_create<P, F, Fut>(self, prepare: F) -> Self
pub fn before_create<P, F, Fut>(self, prepare: F) -> Self
Wait for an adapter’s executor before running the synchronous declaration factory.
Sourcepub fn signature(self, signature: Option<String>) -> Self
pub fn signature(self, signature: Option<String>) -> Self
Declare the canonical ABI signature used by typed dependency admission.
Sourcepub fn contract(self, binding: impl Into<String>, prepared: &[u8]) -> Self
pub fn contract(self, binding: impl Into<String>, prepared: &[u8]) -> Self
Decode the service’s immutable WIT once for RPC validation before provider execution.
Sourcepub fn lifetime(self, lifetime: Lifetime, linger_ms: u32) -> Self
pub fn lifetime(self, lifetime: Lifetime, linger_ms: u32) -> Self
Set the ownership policy and optional idle retention period.
Sourcepub fn method<A, R, F, Fut>(self, name: impl Into<String>, handle: F) -> Self
pub fn method<A, R, F, Fut>(self, name: impl Into<String>, handle: F) -> Self
Bind one callback to typed local and portable entrypoints.
Sourcepub fn method_with<A, R, F, Fut>(
self,
name: impl Into<String>,
handle: F,
codec: Codec<A, R>,
) -> Self
pub fn method_with<A, R, F, Fut>( self, name: impl Into<String>, handle: F, codec: Codec<A, R>, ) -> Self
Bind one callback to a typed local entrypoint, as Service::method does, and to a
portable entrypoint that reads the arguments and writes the result with codec instead
of serde. Local calls never run the codec.
Source§impl<E: 'static> Service<E>
impl<E: 'static> Service<E>
Sourcepub fn local_method<A, R, F, Fut>(
self,
name: impl Into<String>,
handle: F,
) -> Self
pub fn local_method<A, R, F, Fut>( self, name: impl Into<String>, handle: F, ) -> Self
Bind a host-local callback with typed Rust values and no portable entrypoint.
The method exists only for callers in this process that hold the exact argument type, such
as an executor’s lifecycle adapter carrying owned host resources. Every portable access
(call_portable, Host::invoke_portable, foreign hosts and isolated Orb references) is refused with
Reason::LocalValue before the callback runs; no serde conversion is ever attempted.
Source§impl<E: 'static> Service<E>
impl<E: 'static> Service<E>
Sourcepub fn payload_method<F, Fut, R>(
self,
name: impl Into<String>,
handle: F,
) -> Self
pub fn payload_method<F, Fut, R>( self, name: impl Into<String>, handle: F, ) -> Self
Bind a portable-only callback that receives and returns the whole Payload, including
host-issued capabilities. It is the entrypoint for executors that issue resources. It has
no typed local entrypoint, so crate::Reference::call refuses it.
The callback returns a Payload, or an Outcome when the call keeps physically
working after its result (a stream’s producer, for example).