pub struct Server<O>{ /* private fields */ }
Expand description
A Server wrapping a TcpListener, with utils for accepting new clients.
Implementations§
Source§impl<O> Server<O>
impl<O> Server<O>
Sourcepub async fn bind<A: ToSocketAddrs>(
addr: A,
bincode_opts: O,
) -> Result<Server<O>, BindServerError>
pub async fn bind<A: ToSocketAddrs>( addr: A, bincode_opts: O, ) -> Result<Server<O>, BindServerError>
Binds the server to the provided adress.
The server does not listen for new connections imediataly, for that you need .listen()
The provided callback will be used when running the server, it is run in a new task, so it can be asynchronously blocking, although should not be non async blocking
§Errors
if it could not sucessfully bind to the provided adress
pub async fn accept<H, M>( &mut self, ) -> Result<ClientConnection<H, M, O>, AcceptConnectionError>
pub fn as_listener(&self) -> &TcpListener
pub fn as_listener_mut(&mut self) -> &mut TcpListener
pub fn into_listener(self) -> TcpListener
Auto Trait Implementations§
impl<O> !Freeze for Server<O>
impl<O> RefUnwindSafe for Server<O>where
O: RefUnwindSafe,
impl<O> Send for Server<O>where
O: Send,
impl<O> Sync for Server<O>where
O: Sync,
impl<O> Unpin for Server<O>where
O: Unpin,
impl<O> UnwindSafe for Server<O>where
O: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more