pub struct HandoffBuffer { /* private fields */ }Expand description
In-memory buffer for handoff contexts with TTL-based expiry.
Implementations§
Source§impl HandoffBuffer
impl HandoffBuffer
Sourcepub fn new(default_ttl_secs: u64) -> Self
pub fn new(default_ttl_secs: u64) -> Self
Create a new HandoffBuffer with the specified default TTL in seconds.
Sourcepub fn insert(&mut self, context: HandoffContext) -> Uuid
pub fn insert(&mut self, context: HandoffContext) -> Uuid
Insert a handoff context into the buffer. Computes expiry from ctx.ttl_secs or falls back to default_ttl.
Sourcepub fn get(&self, id: &Uuid) -> Option<&HandoffContext>
pub fn get(&self, id: &Uuid) -> Option<&HandoffContext>
Get a reference to a handoff context by ID. Returns None if not found or if expired.
Sourcepub fn latest_for_agent(&self, to_agent: &str) -> Option<&HandoffContext>
pub fn latest_for_agent(&self, to_agent: &str) -> Option<&HandoffContext>
Get the most recent handoff for a specific target agent. Returns the handoff with the latest timestamp that hasn’t expired.
Sourcepub fn sweep_expired(&mut self) -> usize
pub fn sweep_expired(&mut self) -> usize
Remove all expired entries and return the count swept.
Sourcepub fn iter(
&self,
) -> impl Iterator<Item = (&Uuid, &HandoffContext, &DateTime<Utc>)>
pub fn iter( &self, ) -> impl Iterator<Item = (&Uuid, &HandoffContext, &DateTime<Utc>)>
Iterate over all entries (including expired ones). The iterator yields (id, context, expiry) tuples.
Sourcepub fn default_ttl_secs(&self) -> u64
pub fn default_ttl_secs(&self) -> u64
Get the default TTL in seconds.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HandoffBuffer
impl RefUnwindSafe for HandoffBuffer
impl Send for HandoffBuffer
impl Sync for HandoffBuffer
impl Unpin for HandoffBuffer
impl UnsafeUnpin for HandoffBuffer
impl UnwindSafe for HandoffBuffer
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> 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>
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