pub trait Service {
type MethodCall<'de>: Deserialize<'de> + Debug;
type ReplyParams<'ser>: Serialize + Debug
where Self: 'ser;
type ReplyStreamParams: Serialize + Debug;
type ReplyStream: Stream<Item = Reply<Self::ReplyStreamParams>> + Unpin + Debug;
type ReplyError<'ser>: Serialize + Debug
where Self: 'ser;
// Required method
fn handle<'ser>(
&'ser mut self,
method: Call<Self::MethodCall<'_>>,
) -> impl Future<Output = MethodReply<Self::ReplyParams<'ser>, Self::ReplyStream, Self::ReplyError<'ser>>>;
}
Expand description
Service trait for handling method calls.
Required Associated Types§
Sourcetype MethodCall<'de>: Deserialize<'de> + Debug
type MethodCall<'de>: Deserialize<'de> + Debug
The type of method call that this service handles.
This should be a type that can deserialize itself from a complete method call message: i-e
an object containing method
and parameter
fields. This can be easily achieved using the
serde::Deserialize
derive (See the code snippet in
crate::connection::WriteConnection::send_call
documentation for an example).
Sourcetype ReplyParams<'ser>: Serialize + Debug
where
Self: 'ser
type ReplyParams<'ser>: Serialize + Debug where Self: 'ser
The type of the successful reply.
This should be a type that can serialize itself as the parameters
field of the reply.
Sourcetype ReplyStreamParams: Serialize + Debug
type ReplyStreamParams: Serialize + Debug
The type of the item that Service::ReplyStream
will be expected to yield.
This should be a type that can serialize itself as the parameters
field of the reply.
Sourcetype ReplyStream: Stream<Item = Reply<Self::ReplyStreamParams>> + Unpin + Debug
type ReplyStream: Stream<Item = Reply<Self::ReplyStreamParams>> + Unpin + Debug
The type of the multi-reply stream.
If the client asks for multiple replies, this stream will be used to send them.
Sourcetype ReplyError<'ser>: Serialize + Debug
where
Self: 'ser
type ReplyError<'ser>: Serialize + Debug where Self: 'ser
The type of the error reply.
This should be a type that can serialize itself to the whole reply object, containing
error
and parameter
fields. This can be easily achieved using the serde::Serialize
derive (See the code snippet in crate::connection::ReadConnection::receive_reply
documentation for an example).
Required Methods§
Sourcefn handle<'ser>(
&'ser mut self,
method: Call<Self::MethodCall<'_>>,
) -> impl Future<Output = MethodReply<Self::ReplyParams<'ser>, Self::ReplyStream, Self::ReplyError<'ser>>>
fn handle<'ser>( &'ser mut self, method: Call<Self::MethodCall<'_>>, ) -> impl Future<Output = MethodReply<Self::ReplyParams<'ser>, Self::ReplyStream, Self::ReplyError<'ser>>>
Handle a method call.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.