pub struct Server<I, O, S = Nothing> { /* private fields */ }
Expand description
Server for processing requests and responses on standard I/O or TCP.
Implementations
sourceimpl<I, O> Server<I, O, Nothing> where
I: AsyncRead + Unpin,
O: AsyncWrite,
impl<I, O> Server<I, O, Nothing> where
I: AsyncRead + Unpin,
O: AsyncWrite,
sourcepub fn new(stdin: I, stdout: O) -> Self
pub fn new(stdin: I, stdout: O) -> Self
Creates a new Server
with the given stdin
and stdout
handles.
Examples
Initialize with a standard I/O transport:
let stdin = tokio::io::stdin();
let stdout = tokio::io::stdout();
let server = Server::new(stdin, stdout);
Initialize with a TCP transport:
let mut listener = tokio::net::TcpListener::bind("127.0.0.1:9257").await?;
let (stream, _) = listener.accept().await?;
let (read, write) = tokio::io::split(stream);
let server = Server::new(read, write);
sourceimpl<I, O, S> Server<I, O, S> where
I: AsyncRead + Unpin,
O: AsyncWrite,
S: Stream<Item = Outgoing>,
impl<I, O, S> Server<I, O, S> where
I: AsyncRead + Unpin,
O: AsyncWrite,
S: Stream<Item = Outgoing>,
sourcepub fn interleave<T>(self, stream: T) -> Server<I, O, T> where
T: Stream<Item = Outgoing>,
pub fn interleave<T>(self, stream: T) -> Server<I, O, T> where
T: Stream<Item = Outgoing>,
Interleaves the given stream of messages into stdout
together with the responses.
Trait Implementations
Auto Trait Implementations
impl<I, O, S> RefUnwindSafe for Server<I, O, S> where
I: RefUnwindSafe,
O: RefUnwindSafe,
S: RefUnwindSafe,
impl<I, O, S> Send for Server<I, O, S> where
I: Send,
O: Send,
S: Send,
impl<I, O, S> Sync for Server<I, O, S> where
I: Sync,
O: Sync,
S: Sync,
impl<I, O, S> Unpin for Server<I, O, S> where
I: Unpin,
O: Unpin,
S: Unpin,
impl<I, O, S> UnwindSafe for Server<I, O, S> where
I: UnwindSafe,
O: UnwindSafe,
S: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more