Skip to main content

Server

Struct Server 

Source
pub struct Server<P: Protocol> { /* private fields */ }
Expand description

A server endpoint for one connection.

Consume it with serve to dispatch requests from the peer.

Implementations§

Source§

impl<P: Protocol> Server<P>

Source

pub async fn serve<H>(self, handler: H) -> Result<(), Error>
where H: AsyncFn(CallContext<P>, P::Request) + Send + Sync + 'static,

Serves requests until the peer disconnects, the session fails, or a handler requests graceful shutdown.

The handler may be called concurrently for independent requests. Each invocation must consume its CallContext with CallContext::respond or CallContext::respond_with_trailer; dropping the context without responding reports a per-request error to the peer.

Auto Trait Implementations§

§

impl<P> !RefUnwindSafe for Server<P>

§

impl<P> !Sync for Server<P>

§

impl<P> !UnwindSafe for Server<P>

§

impl<P> Freeze for Server<P>
where UnboundedSender<Outgoing<<P as Protocol>::Response>>: Freeze, UnboundedReceiver<Outgoing<<P as Protocol>::Response>>: Freeze, PhantomData<fn() -> P>: Freeze,

§

impl<P> Send for Server<P>
where UnboundedSender<Outgoing<<P as Protocol>::Response>>: Send, UnboundedReceiver<Outgoing<<P as Protocol>::Response>>: Send, PhantomData<fn() -> P>: Send,

§

impl<P> Unpin for Server<P>
where UnboundedSender<Outgoing<<P as Protocol>::Response>>: Unpin, UnboundedReceiver<Outgoing<<P as Protocol>::Response>>: Unpin, PhantomData<fn() -> P>: Unpin,

§

impl<P> UnsafeUnpin for Server<P>
where UnboundedSender<Outgoing<<P as Protocol>::Response>>: UnsafeUnpin, UnboundedReceiver<Outgoing<<P as Protocol>::Response>>: UnsafeUnpin, PhantomData<fn() -> P>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.