pub struct GtpClient { /* private fields */ }Expand description
Stateful GTP client.
Tracks the set of already-seen (sender_id, message_id) pairs to enforce
the idempotency contract of GTP §5. The seen-set is LRU-bounded at
[GTP_SEEN_CAP] entries per epoch to prevent unbounded memory growth
in long-lived groups.
The client observes the current group epoch on every GtpClient::send
or GtpClient::accept call and automatically clears its idempotency
set when the epoch advances. Callers may also drive a reset explicitly
via GtpClient::reset.
Implementations§
Source§impl GtpClient
impl GtpClient
Sourcepub fn send<S>(
&mut self,
node: &mut GroupNode,
seal: &mut S,
target: u32,
message_id: u64,
text: &str,
codec: PayloadCodec,
) -> Result<OutboundFrame, GtpError>where
S: Sealer,
pub fn send<S>(
&mut self,
node: &mut GroupNode,
seal: &mut S,
target: u32,
message_id: u64,
text: &str,
codec: PayloadCodec,
) -> Result<OutboundFrame, GtpError>where
S: Sealer,
Sends a text message via the given GBP node and AEAD sealer.
Returns a wire-ready OutboundFrame that the caller MUST hand to the
transport. Uses the O | R | A profile from GTP §5.
codec controls how the GtpMessage payload is encoded inside the
GBP frame; use PayloadCodec::Cbor for maximum compatibility.
Sourcepub fn accept(
&mut self,
plaintext: &[u8],
current_epoch: u64,
codec: PayloadCodec,
) -> Result<GtpAccept, GtpError>
pub fn accept( &mut self, plaintext: &[u8], current_epoch: u64, codec: PayloadCodec, ) -> Result<GtpAccept, GtpError>
Accepts a plaintext payload delivered by the GBP layer
(Event::PayloadReceived).
current_epoch is the receiver node’s current epoch — passing it lets
the client auto-reset its idempotency set when the epoch advances.
codec must match the value from [DeliveredPayload::codec].
Returns either GtpAccept::New or GtpAccept::Duplicate, or
GtpError::Decode if the plaintext is not a valid GTP message.
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
idempotency state when the epoch has advanced. Called automatically
by GtpClient::send and GtpClient::accept.
Auto Trait Implementations§
impl Freeze for GtpClient
impl RefUnwindSafe for GtpClient
impl Send for GtpClient
impl Sync for GtpClient
impl Unpin for GtpClient
impl UnsafeUnpin for GtpClient
impl UnwindSafe for GtpClient
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