pub struct Server<T: AsyncRead + AsyncWrite, C: Encoder + Decoder, I> { /* private fields */ }
Expand description
Server provides a generic base for building stream servers.
This is generic over T, a stream reader and writer, C, and encoder and decoder, and I, and information object.
You probably want to be looking at TcpServer and UnixServer implementations
Implementations§
Source§impl<T, C, I> Server<T, C, I>where
T: AsyncWrite + AsyncRead + Send + Sync + 'static,
C: Encoder + Decoder + Clone + Send + 'static,
I: Clone + Send + Debug + 'static,
<C as Decoder>::Item: Clone + Send + Debug,
<C as Decoder>::Error: Send + Debug,
<C as Encoder>::Item: Clone + Send + Debug,
<C as Encoder>::Error: Send + Debug,
impl<T, C, I> Server<T, C, I>where
T: AsyncWrite + AsyncRead + Send + Sync + 'static,
C: Encoder + Decoder + Clone + Send + 'static,
I: Clone + Send + Debug + 'static,
<C as Decoder>::Item: Clone + Send + Debug,
<C as Decoder>::Error: Send + Debug,
<C as Encoder>::Item: Clone + Send + Debug,
<C as Encoder>::Error: Send + Debug,
Sourcepub fn base(codec: C) -> Server<T, C, I>
pub fn base(codec: C) -> Server<T, C, I>
Create a new base server with defined request and response message types.
This sets up internal resources however requires implementation to handle creating listeners and binding connections See TcpServer and UnixServer for examples
Sourcepub fn incoming(&mut self) -> Option<UnboundedReceiver<Request<T, C, I>>>
pub fn incoming(&mut self) -> Option<UnboundedReceiver<Request<T, C, I>>>
Take the incoming data handle.
You can then use for_each
to iterate over received requests as in
the examples
Source§impl<C> Server<UnixStream, C, UnixInfo>
Unix server implementation
impl<C> Server<UnixStream, C, UnixInfo>
Unix server implementation
This binds to and listens on a unix domain socket
Trait Implementations§
Source§impl<T, C, I> Clone for Server<T, C, I>where
T: AsyncWrite + AsyncRead + Send + Sync + 'static,
C: Encoder + Decoder + Clone + Send + 'static,
I: Clone + Send + Debug + 'static,
<C as Decoder>::Item: Clone + Send + Debug,
<C as Decoder>::Error: Send + Debug,
<C as Encoder>::Item: Clone + Send + Debug,
<C as Encoder>::Error: Send + Debug,
Clone over generic connector
impl<T, C, I> Clone for Server<T, C, I>where
T: AsyncWrite + AsyncRead + Send + Sync + 'static,
C: Encoder + Decoder + Clone + Send + 'static,
I: Clone + Send + Debug + 'static,
<C as Decoder>::Item: Clone + Send + Debug,
<C as Decoder>::Error: Send + Debug,
<C as Encoder>::Item: Clone + Send + Debug,
<C as Encoder>::Error: Send + Debug,
Clone over generic connector
All instances of a given connector contain the same arc/mutex protected information