Service

Trait Service 

Source
pub trait Service:
    Sized
    + RefUnwindSafe
    + 'static {
    type Req: Serialize + DeserializeOwned;
    type Res: Serialize + DeserializeOwned;
    type Config: Serialize + DeserializeOwned + Clone + 'static;

    // Required methods
    fn args(config: &Self::Config) -> Vec<OsString>;
    fn timeout(config: &Self::Config) -> Duration;
    fn create(config: Self::Config) -> Result<Self, IoError>;
    fn handle(&self, request: Self::Req) -> Self::Res;
}
Expand description

In order to sandbox some logic, there needs to be an implementation of this trait for it.

Required Associated Types§

Source

type Req: Serialize + DeserializeOwned

The request, sent from the parent to the child.

Source

type Res: Serialize + DeserializeOwned

The response, sent from the child to the parent after the request has been processed.

Source

type Config: Serialize + DeserializeOwned + Clone + 'static

The config is passed to the child on startup.

Required Methods§

Source

fn args(config: &Self::Config) -> Vec<OsString>

When your app is passed these CLI flags, it should call become_child.

Source

fn timeout(config: &Self::Config) -> Duration

The amount of time that can be spent servicing queries.

Source

fn create(config: Self::Config) -> Result<Self, IoError>

Creates an instance of the service from the config.

Source

fn handle(&self, request: Self::Req) -> Self::Res

Responds to one request, returning a result.

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.

Implementors§