[][src]Trait uni_components::service::Service

pub trait Service {
    type In: 'static + DeserializeOwned + Serialize;
    type Out: 'static + DeserializeOwned + Serialize;
    fn path(&self) -> &str;
fn kind(&self) -> Kind;
fn from_response(
        &self
    ) -> fn(response: Response) -> Result<Self::Out, Response>; fn exec(
        &self,
        parameter: &Self::In,
        slot: &dyn Slot<Result<Self::Out, Response>>
    ) -> Result<(), CallError> { ... } }

Represents server side handler.

It's a good idea to use define_service! instead of trying to implement the trait by yourself.

Associated Types

type In: 'static + DeserializeOwned + Serialize

Input parameter type (There are special limitations for Kind::Get requests

type Out: 'static + DeserializeOwned + Serialize

Output parameter type

Loading content...

Required methods

fn path(&self) -> &str

Path to the handler at service

fn kind(&self) -> Kind

The kind of requests service will process

fn from_response(&self) -> fn(response: Response) -> Result<Self::Out, Response>

Converter from HTTP response to Service's output type

Loading content...

Provided methods

fn exec(
    &self,
    parameter: &Self::In,
    slot: &dyn Slot<Result<Self::Out, Response>>
) -> Result<(), CallError>

Executes the service. Default implementation call related to the path at server side.

parameter - input parameter

slot - will receive result of the server call

Loading content...

Implementors

Loading content...