Skip to main content

Producer

Trait Producer 

Source
pub trait Producer:
    Send
    + Sync
    + 'static {
    type Item: Send + 'static;
    type Snap: Snapshot;

    // Required methods
    fn snapshot(&self) -> Result<Self::Snap, AttachError>;
    fn subscribe(&self) -> Result<Receiver<Self::Item>, AttachError>;
}
Expand description

A producer of live data + bootable snapshots. The trait is the only thing engate needs to provide attach semantics; concrete producers (tear pane, WS channel, K8s log stream) implement it.

Required Associated Types§

Source

type Item: Send + 'static

Items emitted on the live stream.

Source

type Snap: Snapshot

Snapshot representation. Whatever the consumer needs to reach the producer’s current state without replaying every historical item.

Required Methods§

Source

fn snapshot(&self) -> Result<Self::Snap, AttachError>

Capture the producer’s current state. Must NOT be racy with subscribe — the contract is “no item between snapshot capture and live-stream registration may be lost”; concrete implementors typically subscribe first, then snapshot.

Source

fn subscribe(&self) -> Result<Receiver<Self::Item>, AttachError>

Register a live subscriber. Returns a receiver; items are pushed asynchronously by the producer. Dropping the receiver unsubscribes.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§