pub struct MessageHistory { /* private fields */ }Expand description
Bounded ring-buffer of recent GTP messages.
The capacity is fixed at construction time; older messages are discarded once the buffer is full. Insertion is O(1); resync queries are O(n) over the buffer (typically small).
Implementations§
Source§impl MessageHistory
impl MessageHistory
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Sourcepub fn push(&mut self, msg: GtpMessage) -> bool
pub fn push(&mut self, msg: GtpMessage) -> bool
Records a message. Returns true if it was newly added, false if
(sender_id, message_id) was already present (idempotent insert).
Sourcepub fn contains(&self, sender_id: MemberId, message_id: u64) -> bool
pub fn contains(&self, sender_id: MemberId, message_id: u64) -> bool
Returns true if (sender_id, message_id) is present.
Sourcepub fn since<'a>(
&'a self,
watermark: &'a Watermark,
) -> impl Iterator<Item = &'a GtpMessage> + 'a
pub fn since<'a>( &'a self, watermark: &'a Watermark, ) -> impl Iterator<Item = &'a GtpMessage> + 'a
Returns every message produced after the given watermark, in insertion order. Use this to satisfy a peer’s resync request.
Sourcepub fn since_for_sender(
&self,
sender_id: MemberId,
since_message_id: u64,
) -> impl Iterator<Item = &GtpMessage>
pub fn since_for_sender( &self, sender_id: MemberId, since_message_id: u64, ) -> impl Iterator<Item = &GtpMessage>
Returns every message from a single sender produced strictly after
since_message_id.
Auto Trait Implementations§
impl Freeze for MessageHistory
impl RefUnwindSafe for MessageHistory
impl Send for MessageHistory
impl Sync for MessageHistory
impl Unpin for MessageHistory
impl UnsafeUnpin for MessageHistory
impl UnwindSafe for MessageHistory
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
Mutably borrows from an owned value. Read more
Source§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
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>
Converts
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>
Converts
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