pub struct Subscriber { /* private fields */ }Expand description
One session’s standing interest in being told that a list changed.
Built once, when the session registers, and read on every publish after
that. Holding the FeatureProfile by value rather than by reference is
deliberate: it is a u128 bitset that FeatureProfile derives Copy for,
and a subscriber that outlives its session must not borrow one.
Implementations§
Source§impl Subscriber
impl Subscriber
Sourcepub fn new(
kind: PrimitiveKind,
feature: Feature,
method: &'static str,
frame: &str,
profile: FeatureProfile,
sink: Arc<dyn DynFrameSink>,
) -> Self
pub fn new( kind: PrimitiveKind, feature: Feature, method: &'static str, frame: &str, profile: FeatureProfile, sink: Arc<dyn DynFrameSink>, ) -> Self
A subscriber for kind, gated on feature, told with method.
frame is the encoded notification. It is built once here rather than
per publish because the bytes are identical for every session receiving
it, and encoding a notification per subscriber turns one publish into
one serialisation per session — which is the difference between a
fan-out that costs a socket write and one that costs a JSON encode.
Sourcepub const fn also_for(self, kind: PrimitiveKind) -> Self
pub const fn also_for(self, kind: PrimitiveKind) -> Self
The same subscriber, also told when kind changes.
For a notification that names more than one kind — see the field’s own comment for the one MCP has.
Sourcepub const fn kind(&self) -> PrimitiveKind
pub const fn kind(&self) -> PrimitiveKind
The kind of primitive this subscriber wants to hear about.
Sourcepub fn covers(&self, kinds: &[PrimitiveKind]) -> bool
pub fn covers(&self, kinds: &[PrimitiveKind]) -> bool
Whether a publish that touched kinds concerns this subscriber.
Sourcepub fn is_eligible(&self) -> bool
pub fn is_eligible(&self) -> bool
Whether this subscriber’s negotiated profile permits the notification.
The one place the gate is decided, so there is no second caller that forgets to ask.