Skip to main content

NotificationSink

Trait NotificationSink 

Source
pub trait NotificationSink: Send + Sync {
    // Required method
    fn publish(&self, notification: Notification);
}
Expand description

Where an ambient notification goes on a given transport.

A task transition has no request-scoped Peer to send on, and each transport reaches its client differently: the stdio/socket runtime queues onto ServerState’s ambient pump, while the HTTP adapters store-and-forward onto the session’s SSE StreamRegistry.

The trait exists so the mapping from a task transition to notifications/tasks/status is written once. A new transport implements one method; it does not re-derive the notification, and so cannot get it subtly wrong the way five hand-rolled copies of a routing rule did.

Publishing is best-effort by contract: a notification with nowhere to go is dropped, never an error.

Required Methods§

Source

fn publish(&self, notification: Notification)

Hand the notification to this transport’s outbound path.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§