Skip to main content

CardSubscriber

Trait CardSubscriber 

Source
pub trait CardSubscriber: Send + Sync {
    // Required methods
    fn on_event(&self, ev: &CardEvent) -> Result<(), String>;
    fn describe(&self) -> String;

    // Provided method
    fn has_card(&self, _card_id: &str) -> Result<bool, String> { ... }
}
Expand description

A downstream backend that receives CardEvents in best-effort, serial fan-out order.

Implementations must be Send + Sync so that the bus can hold Arc<dyn CardSubscriber> safely across threads.

Required Methods§

Source

fn on_event(&self, ev: &CardEvent) -> Result<(), String>

Handle one event. Returning Err records a failure in SubscriberStats and emits a tracing::warn!, but does not propagate to the caller of the _with_store API.

Source

fn describe(&self) -> String

Canonical identity URI for this subscriber. Used as the key in SubscriberStats and as the match target for CardEventBus::publish_to.

Provided Methods§

Source

fn has_card(&self, _card_id: &str) -> Result<bool, String>

Best-effort check for whether card_id already exists in this subscriber. Used by alc_card_sink_backfill to skip cards that are already mirrored (drift-safe: we never overwrite).

Default implementation returns Ok(false) so subscribers that cannot cheaply answer (e.g. future network-backed sinks) always get the push. Override when a cheap local check is possible.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§