Skip to main content

Service

Trait Service 

Source
pub trait Service<In>: Send + Sync {
    type Out;

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

    // Provided methods
    fn handle_stream(
        &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( &self, input: In, cx: &Context, ) -> impl Stream<Item = Self::Out> + Send

Provided Methods§

Source

fn handle_stream( &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, E, S> Service<I> for Option<S>
where I: Send, S: Service<I, Out = Result<I, E>>,

Source§

type Out = Result<I, E>

Source§

fn handle( &self, input: I, cx: &Context, ) -> impl Stream<Item = <Option<S> as Service<I>>::Out> + Send

Source§

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

Source§

type Out = Result<O2, E>

Source§

fn handle( &self, msg: I, cx: &Context, ) -> impl Stream<Item = <(S1, S2) as Service<I>>::Out> + Send

Source§

impl<P> Service<P> for DirReader
where P: AsRef<Path> + Send,

Source§

type Out = Result<WithSource<PathBuf>, Error>

Source§

fn handle( &self, dir: P, cx: &Context, ) -> impl Stream<Item = <DirReader as Service<P>>::Out> + Send

Source§

impl<P> Service<P> for FileReader
where P: AsRef<Path> + Send + Sync,

Source§

type Out = Result<WithSource<Bytes>, Error>

Source§

fn handle( &self, path: P, cx: &Context, ) -> impl Stream<Item = <FileReader as Service<P>>::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> + Sync, M: Send + Sync, O: Send, I: Send + Sync, E: Send + Sync + From<E1>, E1: Send + Sync,

Source§

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

Source§

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

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 + Sync, 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 + Sync + 'static, R: Send + 'static, E: Send + 'static, S: Service<M, Out = Result<R, E>> + 'static,