pub struct GspClient {
pub muted: HashSet<u32>,
pub members: HashSet<u32>,
/* private fields */
}Expand description
Stateful GSP client.
Tracks request_id deduplication, the current membership set and the
mute-list. Membership is updated atomically when JOIN, LEAVE, MUTE or
UNMUTE signals are accepted. The request_id set is LRU-bounded at
[GSP_SEEN_CAP] entries per epoch.
The client observes the current group epoch on every GspClient::send
or GspClient::accept call and automatically clears its
request_id deduplication set when the epoch advances. Callers may also
drive a reset explicitly via GspClient::reset.
Fields§
§muted: HashSet<u32>Members that are currently muted.
members: HashSet<u32>Current membership set, driven by JOIN / LEAVE.
Implementations§
Source§impl GspClient
impl GspClient
Sourcepub fn send<S>(
&mut self,
node: &mut GroupNode,
seal: &mut S,
target: u32,
signal: SignalType,
role_claim: u32,
request_id: u32,
codec: PayloadCodec,
) -> Result<OutboundFrame, GspError>where
S: Sealer,
pub fn send<S>(
&mut self,
node: &mut GroupNode,
seal: &mut S,
target: u32,
signal: SignalType,
role_claim: u32,
request_id: u32,
codec: PayloadCodec,
) -> Result<OutboundFrame, GspError>where
S: Sealer,
Sends a signal. Uses the O | R | A profile required by GSP §3.
codec controls payload encoding; use PayloadCodec::Cbor for
maximum compatibility.
Sourcepub fn send_with_args<S>(
&mut self,
node: &mut GroupNode,
seal: &mut S,
target: u32,
signal: SignalType,
role_claim: u32,
request_id: u32,
args: &[u8],
codec: PayloadCodec,
) -> Result<OutboundFrame, GspError>where
S: Sealer,
pub fn send_with_args<S>(
&mut self,
node: &mut GroupNode,
seal: &mut S,
target: u32,
signal: SignalType,
role_claim: u32,
request_id: u32,
args: &[u8],
codec: PayloadCodec,
) -> Result<OutboundFrame, GspError>where
S: Sealer,
Sends a signal with opcode-specific args bytes.
Use this for signals that require structured arguments (MUTE, UNMUTE,
ROLE_CHANGE, STREAM_START, STREAM_STOP, CODEC_UPDATE).
codec controls how the GspSignal envelope is encoded; args
bytes are always opaque and carried as-is regardless of codec.
Sourcepub fn accept(
&mut self,
plaintext: &[u8],
current_epoch: u64,
codec: PayloadCodec,
) -> Result<GspAccept, GspError>
pub fn accept( &mut self, plaintext: &[u8], current_epoch: u64, codec: PayloadCodec, ) -> Result<GspAccept, GspError>
Accepts a signal payload, applies the state effects defined in GSP §5
and returns the decoded GspAccept.
current_epoch is the receiver node’s current epoch — passing it lets
the client auto-reset its request_id deduplication set when the
epoch advances. codec must match [DeliveredPayload::codec].
Sourcepub fn sync_epoch(&mut self, epoch: u64)
pub fn sync_epoch(&mut self, epoch: u64)
Synchronises the client’s view of the group epoch and resets the
request_id deduplication set when the epoch has advanced. Called
automatically by GspClient::send and GspClient::accept.
Auto Trait Implementations§
impl Freeze for GspClient
impl RefUnwindSafe for GspClient
impl Send for GspClient
impl Sync for GspClient
impl Unpin for GspClient
impl UnsafeUnpin for GspClient
impl UnwindSafe for GspClient
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
Source§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
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>
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>
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 more