pub struct FeedState { /* private fields */ }Expand description
Shared state for the feed system
This struct manages the broadcast channel and client tracking.
It should be wrapped in Arc and shared across handlers.
Implementations§
Source§impl FeedState
impl FeedState
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Create a new FeedState with the specified channel capacity
§Arguments
capacity- Maximum number of events to buffer in the channel. Clients that fall behind will miss events.
Sourcepub fn subscribe(&self) -> Receiver<FeedEvent>
pub fn subscribe(&self) -> Receiver<FeedEvent>
Subscribe to the event feed
Returns a receiver that will receive all events published after subscription.
Sourcepub fn publish(&self, event: FeedEvent) -> usize
pub fn publish(&self, event: FeedEvent) -> usize
Publish an event to all connected clients
Returns the number of clients that received the event. Returns 0 if no clients are connected.
Sourcepub fn publish_capture_received(
&self,
capture_id: impl Into<String>,
url: impl Into<String>,
capture_type: impl Into<String>,
) -> usize
pub fn publish_capture_received( &self, capture_id: impl Into<String>, url: impl Into<String>, capture_type: impl Into<String>, ) -> usize
Publish a capture_received event
Sourcepub fn publish_processing_complete(
&self,
capture_id: impl Into<String>,
duration_ms: u64,
size_bytes: u64,
summary: Option<String>,
) -> usize
pub fn publish_processing_complete( &self, capture_id: impl Into<String>, duration_ms: u64, size_bytes: u64, summary: Option<String>, ) -> usize
Publish a processing_complete event
Sourcepub fn publish_error(
&self,
capture_id: Option<String>,
code: impl Into<String>,
message: impl Into<String>,
recoverable: bool,
) -> usize
pub fn publish_error( &self, capture_id: Option<String>, code: impl Into<String>, message: impl Into<String>, recoverable: bool, ) -> usize
Publish an error event
Sourcepub fn connected_clients(&self) -> u64
pub fn connected_clients(&self) -> u64
Get the number of connected clients
Sourcepub fn uptime_seconds(&self) -> u64
pub fn uptime_seconds(&self) -> u64
Get the server uptime in seconds
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for FeedState
impl !RefUnwindSafe for FeedState
impl Send for FeedState
impl Sync for FeedState
impl Unpin for FeedState
impl !UnwindSafe for FeedState
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