pub struct EventBus { /* private fields */ }Expand description
Subscribers by event type. See the module docs.
Implementations§
Source§impl EventBus
impl EventBus
pub fn new() -> EventBus
Sourcepub fn subscribe<E, F>(&self, handler: F) -> SubscriptionId
pub fn subscribe<E, F>(&self, handler: F) -> SubscriptionId
Call handler with every event of type E published from now on.
Sourcepub fn unsubscribe(&self, id: SubscriptionId) -> bool
pub fn unsubscribe(&self, id: SubscriptionId) -> bool
Stop a subscription; false when it was already gone.
Sourcepub fn publish<E>(&self, event: &E) -> usizewhere
E: Any,
pub fn publish<E>(&self, event: &E) -> usizewhere
E: Any,
Hand event to every subscriber of its type, in subscription
order; returns how many ran to completion.
Sourcepub fn subscribers<E>(&self) -> usizewhere
E: Any,
pub fn subscribers<E>(&self) -> usizewhere
E: Any,
How many subscribers events of type E have.
Sourcepub fn forward_to_mcp<E, F>(
&self,
server: McpServer,
method: &str,
params: F,
) -> SubscriptionId
pub fn forward_to_mcp<E, F>( &self, server: McpServer, method: &str, params: F, ) -> SubscriptionId
Send each E to MCP clients as the notification method, with
params(event) (a JSON object) as its params
(McpServer::notify).
Sourcepub fn forward_to_channel<E, T, M>(
&self,
hub: Hub,
topic: T,
message: M,
) -> SubscriptionId
Available on non-WebAssembly only.
pub fn forward_to_channel<E, T, M>( &self, hub: Hub, topic: T, message: M, ) -> SubscriptionId
Publish each E to the channel topic topic(event) as
message(event) (Hub::publish).
Trait Implementations§
Auto Trait Implementations§
impl Forget for EventBus
impl Freeze for EventBus
impl Move for EventBus
impl RefUnwindSafe for EventBus
impl Send for EventBus
impl Sync for EventBus
impl Unpin for EventBus
impl UnsafeUnpin for EventBus
impl UnwindSafe for EventBus
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
Available on crate feature
map-response-body only.Apply a transformation to the response body. Read more
Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
Available on crate feature
trace only.High level tracing that classifies responses using HTTP status codes. Read more
Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
Available on crate feature
trace only.High level tracing that classifies responses using gRPC headers. Read more