Service

Trait Service 

Source
pub trait Service<Request> {
    type QueryResponse: Send + 'static;
    type OnQueryFuture: Future<Output = Option<Self::QueryResponse>> + Send + 'static;
    type OnMessageFuture: Future<Output = ()> + Send + 'static;

    // Required methods
    fn on_query(&self, req: Request) -> Self::OnQueryFuture;
    fn on_message(&self, req: Request) -> Self::OnMessageFuture;
}

Required Associated Types§

Source

type QueryResponse: Send + 'static

Source

type OnQueryFuture: Future<Output = Option<Self::QueryResponse>> + Send + 'static

Source

type OnMessageFuture: Future<Output = ()> + Send + 'static

Required Methods§

Source

fn on_query(&self, req: Request) -> Self::OnQueryFuture

Called when a query is received.

Returns a future that resolves to the either response to the query if Some, or cancellation of the query if None.

Source

fn on_message(&self, req: Request) -> Self::OnMessageFuture

Called when a message is received.

Implementations on Foreign Types§

Source§

impl<'a, S, Request> Service<Request> for &'a S
where S: Service<Request> + Sync + 'a,

Source§

type QueryResponse = <S as Service<Request>>::QueryResponse

Source§

type OnQueryFuture = <S as Service<Request>>::OnQueryFuture

Source§

type OnMessageFuture = <S as Service<Request>>::OnMessageFuture

Source§

fn on_query(&self, req: Request) -> Self::OnQueryFuture

Source§

fn on_message(&self, req: Request) -> Self::OnMessageFuture

Source§

impl<S, Request> Service<Request> for Box<S>
where S: Service<Request> + ?Sized,

Source§

type QueryResponse = <S as Service<Request>>::QueryResponse

Source§

type OnQueryFuture = <S as Service<Request>>::OnQueryFuture

Source§

type OnMessageFuture = <S as Service<Request>>::OnMessageFuture

Source§

fn on_query(&self, req: Request) -> Self::OnQueryFuture

Source§

fn on_message(&self, req: Request) -> Self::OnMessageFuture

Source§

impl<S, Request> Service<Request> for Arc<S>
where S: Service<Request> + Sync + ?Sized,

Source§

type QueryResponse = <S as Service<Request>>::QueryResponse

Source§

type OnQueryFuture = <S as Service<Request>>::OnQueryFuture

Source§

type OnMessageFuture = <S as Service<Request>>::OnMessageFuture

Source§

fn on_query(&self, req: Request) -> Self::OnQueryFuture

Source§

fn on_message(&self, req: Request) -> Self::OnMessageFuture

Implementors§

Source§

impl Service<ServiceRequest> for DhtService

Source§

impl Service<ServiceRequest> for OverlayService

Source§

impl<Request, Q> Service<Request> for BoxCloneService<Request, Q>
where Request: Send + 'static, Q: Send + 'static,

Source§

type QueryResponse = Q

Source§

type OnQueryFuture = Pin<Box<dyn Future<Output = Option<Q>> + Send>>

Source§

type OnMessageFuture = Pin<Box<dyn Future<Output = ()> + Send>>

Source§

impl<Request, Q> Service<Request> for BoxService<Request, Q>
where Request: Send + 'static, Q: Send + 'static,

Source§

type QueryResponse = Q

Source§

type OnQueryFuture = Pin<Box<dyn Future<Output = Option<Q>> + Send>>

Source§

type OnMessageFuture = Pin<Box<dyn Future<Output = ()> + Send>>

Source§

impl<Request, Q> Service<Request> for Router<Request, Q>
where Request: Send + AsRef<[u8]> + 'static, Q: Send + 'static,

Source§

impl<Request, Q, T, F> Service<Request> for ServiceMessageFn<Q, T>
where Q: Send + 'static, T: Fn(Request) -> F + Send + 'static, F: Future<Output = ()> + Send + 'static,

Source§

impl<Request, Q, T, F> Service<Request> for ServiceQueryFn<T>
where Q: Send + 'static, T: Fn(Request) -> F + Send + 'static, F: Future<Output = Option<Q>> + Send + 'static,