pub struct ServerFacade<'a> { /* private fields */ }Expand description
Closure-based facade over RaknetServerEvent stream.
Useful when you want to wire small handlers without defining custom handler traits.
Implementations§
Source§impl<'a> ServerFacade<'a>
impl<'a> ServerFacade<'a>
Sourcepub fn new(server: &'a mut RaknetServer) -> Self
pub fn new(server: &'a mut RaknetServer) -> Self
Creates a new facade around a mutable server reference.
Sourcepub fn on_connect<F>(self, handler: F) -> Selfwhere
F: for<'b> FnMut(&'b mut RaknetServer, ConnectEvent) -> ServerHookFuture<'b> + Send + 'static,
pub fn on_connect<F>(self, handler: F) -> Selfwhere
F: for<'b> FnMut(&'b mut RaknetServer, ConnectEvent) -> ServerHookFuture<'b> + Send + 'static,
Registers on_connect callback.
Sourcepub fn on_disconnect<F>(self, handler: F) -> Selfwhere
F: for<'b> FnMut(&'b mut RaknetServer, DisconnectEvent) -> ServerHookFuture<'b> + Send + 'static,
pub fn on_disconnect<F>(self, handler: F) -> Selfwhere
F: for<'b> FnMut(&'b mut RaknetServer, DisconnectEvent) -> ServerHookFuture<'b> + Send + 'static,
Registers on_disconnect callback.
Sourcepub async fn next(&mut self) -> Result<bool>
pub async fn next(&mut self) -> Result<bool>
Polls one server event and dispatches to registered callbacks.
Returns Ok(false) when the server event stream is closed.
Sourcepub async fn run(&mut self) -> Result<()>
pub async fn run(&mut self) -> Result<()>
Runs the dispatch loop until stream closure or callback error.
Sourcepub fn server(&self) -> &RaknetServer
pub fn server(&self) -> &RaknetServer
Returns immutable access to wrapped server.
Sourcepub fn server_mut(&mut self) -> &mut RaknetServer
pub fn server_mut(&mut self) -> &mut RaknetServer
Returns mutable access to wrapped server.
Auto Trait Implementations§
impl<'a> Freeze for ServerFacade<'a>
impl<'a> !RefUnwindSafe for ServerFacade<'a>
impl<'a> Send for ServerFacade<'a>
impl<'a> !Sync for ServerFacade<'a>
impl<'a> Unpin for ServerFacade<'a>
impl<'a> UnsafeUnpin for ServerFacade<'a>
impl<'a> !UnwindSafe for ServerFacade<'a>
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