pub struct CaptureBuffer { /* private fields */ }Expand description
Thread-safe in-memory buffer for captured web content
Uses a VecDeque internally for efficient FIFO operations with
RwLock for thread-safe concurrent access.
Implementations§
Source§impl CaptureBuffer
impl CaptureBuffer
Sourcepub fn builder() -> CaptureBufferBuilder
pub fn builder() -> CaptureBufferBuilder
Create a new capture buffer builder
Sourcepub fn with_config(config: BufferConfig) -> Self
pub fn with_config(config: BufferConfig) -> Self
Create a new capture buffer with custom configuration
Sourcepub async fn push(&self, record: CaptureRecord)
pub async fn push(&self, record: CaptureRecord)
Push a new capture record into the buffer
If the buffer is at capacity, the oldest record is evicted (FIFO).
Sourcepub async fn get(&self, id: Uuid) -> Option<CaptureRecord>
pub async fn get(&self, id: Uuid) -> Option<CaptureRecord>
Get a capture by its ID
Sourcepub async fn get_recent(&self, limit: usize) -> Vec<CaptureRecord>
pub async fn get_recent(&self, limit: usize) -> Vec<CaptureRecord>
Get the most recent N captures
Returns captures in reverse chronological order (newest first).
Sourcepub async fn get_since(&self, timestamp: DateTime<Utc>) -> Vec<CaptureRecord>
pub async fn get_since(&self, timestamp: DateTime<Utc>) -> Vec<CaptureRecord>
Get all captures since a given timestamp
Sourcepub async fn get_by_url(&self, url: &str) -> Vec<CaptureRecord>
pub async fn get_by_url(&self, url: &str) -> Vec<CaptureRecord>
Get all captures for a specific URL
Sourcepub async fn stats(&self) -> BufferStats
pub async fn stats(&self) -> BufferStats
Get buffer statistics
Sourcepub async fn cleanup_expired(&self) -> usize
pub async fn cleanup_expired(&self) -> usize
Remove expired captures from the buffer
Returns the number of captures removed.
Sourcepub fn start_cleanup_task(self: &Arc<Self>) -> JoinHandle<()>
pub fn start_cleanup_task(self: &Arc<Self>) -> JoinHandle<()>
Start the background cleanup task
This spawns a task that periodically removes expired captures.
Sourcepub async fn start_cleanup(self: &Arc<Self>)
pub async fn start_cleanup(self: &Arc<Self>)
Start cleanup task and store handle internally
Sourcepub async fn stop_cleanup(&self)
pub async fn stop_cleanup(&self)
Stop the cleanup task if running
Sourcepub fn config(&self) -> &BufferConfig
pub fn config(&self) -> &BufferConfig
Get the buffer configuration
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for CaptureBuffer
impl !RefUnwindSafe for CaptureBuffer
impl Send for CaptureBuffer
impl Sync for CaptureBuffer
impl Unpin for CaptureBuffer
impl !UnwindSafe for CaptureBuffer
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> 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