Skip to main content

ServerFacade

Struct ServerFacade 

Source
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>

Source

pub fn new(server: &'a mut RaknetServer) -> Self

Creates a new facade around a mutable server reference.

Source

pub fn on_connect<F>(self, handler: F) -> Self
where F: for<'b> FnMut(&'b mut RaknetServer, ConnectEvent) -> ServerHookFuture<'b> + Send + 'static,

Registers on_connect callback.

Source

pub fn on_packet<F>(self, handler: F) -> Self
where F: for<'b> FnMut(&'b mut RaknetServer, PacketEvent) -> ServerHookFuture<'b> + Send + 'static,

Registers on_packet callback.

Source

pub fn on_disconnect<F>(self, handler: F) -> Self
where F: for<'b> FnMut(&'b mut RaknetServer, DisconnectEvent) -> ServerHookFuture<'b> + Send + 'static,

Registers on_disconnect callback.

Source

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.

Source

pub async fn run(&mut self) -> Result<()>

Runs the dispatch loop until stream closure or callback error.

Source

pub fn server(&self) -> &RaknetServer

Returns immutable access to wrapped server.

Source

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> 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more