pub struct Dispatcher<S: EventSource> { /* private fields */ }Implementations§
Source§impl<S: EventSource> Dispatcher<S>
impl<S: EventSource> Dispatcher<S>
Sourcepub fn with_config(source: S, config: ClientConfig) -> Self
pub fn with_config(source: S, config: ClientConfig) -> Self
Creates a dispatcher with a custom configuration.
Sourcepub fn source_mut(&mut self) -> &mut S
pub fn source_mut(&mut self) -> &mut S
Returns a mutable reference to the event source.
Sourcepub fn add_handler<F>(&mut self, event: Event, handler: F)
pub fn add_handler<F>(&mut self, event: Event, handler: F)
Adds a handler for a specific event.
Sourcepub fn add_handler_any<F>(&mut self, handler: F)
pub fn add_handler_any<F>(&mut self, handler: F)
Adds a handler which receives all events.
Sourcepub fn on_event<F>(self, event: Event, handler: F) -> Self
pub fn on_event<F>(self, event: Event, handler: F) -> Self
Adds a handler and returns the dispatcher for chaining.
Sourcepub fn on_any<F>(self, handler: F) -> Self
pub fn on_any<F>(self, handler: F) -> Self
Adds a handler for all events and returns the dispatcher for chaining.
Sourcepub fn on_user_joined<F>(self, handler: F) -> Self
pub fn on_user_joined<F>(self, handler: F) -> Self
Adds a handler for user join events.
Sourcepub fn on_user_left<F>(self, handler: F) -> Self
pub fn on_user_left<F>(self, handler: F) -> Self
Adds a handler for user left events.
Sourcepub fn on_text_message<F>(self, handler: F) -> Self
pub fn on_text_message<F>(self, handler: F) -> Self
Adds a handler for text messages.
Sourcepub fn on_connect_success<F>(self, handler: F) -> Self
pub fn on_connect_success<F>(self, handler: F) -> Self
Adds a handler for connection success events.
Sourcepub fn on_connection_lost<F>(self, handler: F) -> Self
pub fn on_connection_lost<F>(self, handler: F) -> Self
Adds a handler for connection lost events.
Sourcepub fn on_connect_failed<F>(self, handler: F) -> Self
pub fn on_connect_failed<F>(self, handler: F) -> Self
Adds a handler for connection failure events.
Sourcepub fn on_command_error<F>(self, handler: F) -> Self
pub fn on_command_error<F>(self, handler: F) -> Self
Adds a handler for command error events.
Sourcepub fn run(&mut self) -> DispatchFlow
pub fn run(&mut self) -> DispatchFlow
Runs the dispatcher loop with the configured timeout.
Sourcepub fn run_with_timeout(&mut self, timeout_ms: i32) -> DispatchFlow
pub fn run_with_timeout(&mut self, timeout_ms: i32) -> DispatchFlow
Runs the dispatcher loop with an explicit timeout.
Sourcepub fn step(&mut self, timeout_ms: i32) -> DispatchFlow
pub fn step(&mut self, timeout_ms: i32) -> DispatchFlow
Performs one poll/dispatch step.
Auto Trait Implementations§
impl<S> Freeze for Dispatcher<S>where
S: Freeze,
impl<S> !RefUnwindSafe for Dispatcher<S>
impl<S> Send for Dispatcher<S>where
S: Send,
impl<S> !Sync for Dispatcher<S>
impl<S> Unpin for Dispatcher<S>where
S: Unpin,
impl<S> UnsafeUnpin for Dispatcher<S>where
S: UnsafeUnpin,
impl<S> !UnwindSafe for Dispatcher<S>
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more