Service

Trait Service 

Source
pub trait Service<In> {
    type Out;

    // Required method
    fn handle(
        &mut self,
        input: In,
        cx: &Context,
    ) -> impl Stream<Item = Self::Out> + Send;

    // Provided methods
    fn handle_stream(
        &mut self,
        input: impl Stream<Item = In> + Send,
        cx: &Context,
    ) -> impl Stream<Item = Self::Out> + Send
       where In: Send,
             Self: Send,
             Self::Out: Send { ... }
    fn finalize(&mut self, _cx: &Context) -> impl Future<Output = ()>
       where Self: Sized { ... }
}

Required Associated Types§

Required Methods§

Source

fn handle( &mut self, input: In, cx: &Context, ) -> impl Stream<Item = Self::Out> + Send

Provided Methods§

Source

fn handle_stream( &mut self, input: impl Stream<Item = In> + Send, cx: &Context, ) -> impl Stream<Item = Self::Out> + Send
where In: Send, Self: Send, Self::Out: Send,

Source

fn finalize(&mut self, _cx: &Context) -> impl Future<Output = ()>
where Self: Sized,

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.

Implementations on Foreign Types§

Source§

impl<I, O1, E1, O2, E2, S1, S2> Service<I> for (S1, S2)
where I: Send, O1: Send, O2: Send, E1: Send, E2: Send, S1: Service<I, Out = Result<O1, E1>> + Send, S2: Service<O1, Out = Result<O2, E2>> + Send,

Source§

type Out = Result<O2, Either<E1, E2>>

Source§

fn handle( &mut self, msg: I, cx: &Context, ) -> impl Stream<Item = Self::Out> + Send

Source§

impl<I: Send, E, S: Service<I, Out = Result<I, E>>> Service<I> for Option<S>

Source§

type Out = Result<I, E>

Source§

fn handle( &mut self, input: I, cx: &Context, ) -> impl Stream<Item = Self::Out> + Send

Implementors§

Source§

impl<I, M, E1, O, E, S, F> Service<I> for Scope<I, M, E1, S, F>
where S: Service<M, Out = Result<O, E>> + Send, F: Send + Fn(&I) -> Result<M, E1>, M: Send, O: Send, I: Send, E: Send, E1: Send,

Source§

type Out = Result<(I, Result<Vec<O>, Either<E, E1>>), E1>

Source§

impl<I, M, E1, O, E, S, F> Service<I> for ScopeEach<I, M, E1, S, F>
where S: Service<M, Out = Result<O, E>> + Send, F: Send + Fn(&I) -> Result<M, E1>, M: Send, O: Send, I: Send + Clone + Sync + 'static, E: Send, E1: Send,

Source§

type Out = Result<(I, Result<O, E>), E1>

Source§

impl<I, O1, E, O2, S1, S2> Service<I> for Left<S1, S2>
where I: Send, O1: Send, O2: Send, E: Send, S1: Service<I, Out = Result<O1, E>> + Send, S2: Service<O1, Out = O2> + Send,

Source§

type Out = Result<O2, E>

Source§

impl<I, R, E, E2, F, S> Service<I> for Except<S, F>
where S: Service<I, Out = Result<R, E>>, F: Send + Sync + Fn(E) -> Option<E2>,

Source§

type Out = Result<R, E2>

Source§

impl<I, R, E, S> Service<I> for ConcurrentEach<I, S>
where I: Send, R: Send + 'static, E: Send + 'static, S: Service<I, Out = Result<R, E>> + Clone + Send + 'static,

Source§

type Out = Result<ConcurrentRx<<S as Service<I>>::Out>, E>

Source§

impl<M, R, E, S> Service<M> for SpawnEach<M, S>
where M: Send + 'static, R: Send + 'static, E: Send + 'static, S: Clone + Service<M, Out = Result<R, E>> + Send + 'static,

Source§

type Out = Result<Receiver<Result<R, E>>, E>