pub struct IpcBroadcast { /* private fields */ }Expand description
A Unix-socket broadcast server. Drops slow clients; optionally replays the last buffer on connect; optionally decodes inbound length-prefixed frames.
Implementations§
Source§impl IpcBroadcast
impl IpcBroadcast
Sourcepub async fn bind(
path: impl AsRef<Path>,
queue_depth: usize,
keep_last: bool,
inbound: Option<usize>,
) -> Result<(Self, Option<Receiver<InboundCommand>>)>
pub async fn bind( path: impl AsRef<Path>, queue_depth: usize, keep_last: bool, inbound: Option<usize>, ) -> Result<(Self, Option<Receiver<InboundCommand>>)>
Bind the socket and start accepting clients.
queue_depth: per-client outbound queue size (256 for MAVLink, 32 for state, per the contracts).keep_last: replay the last broadcast buffer to a newly connected client (state socket behaviour).inbound: ifSome, each client connection is also read as a stream of length-prefixed frames whose payloads are forwarded on the channel asInboundCommands carrying the writing connection’s identity (MAVLink command path). The capacity bounds the inbound backlog.
Sourcepub async fn broadcast(&self, buf: Bytes)
pub async fn broadcast(&self, buf: Bytes)
Broadcast a byte buffer to all connected clients. Clients whose queue is
full are dropped. If keep_last is set, the buffer is also stored as the
last-state replayed to future clients.
Takes Bytes rather than Vec<u8> because every clone below — one per
attached client, plus one for the retained last-state — used to be a full
copy of the buffer. On the FC frame lane that is ~66 copies/s per
connected consumer, growing with the number of consumers; as Bytes each
is a refcount bump and the cost stops scaling with the client count. A
producer holding a freshly built Vec<u8> converts with .into(), which
is a move, not a copy.
Sourcepub async fn client_count(&self) -> usize
pub async fn client_count(&self) -> usize
Number of currently connected clients.
Sourcepub fn queue_depth(&self) -> usize
pub fn queue_depth(&self) -> usize
The per-client queue depth this server was bound with.
Sourcepub fn dropped_clients(&self) -> u64
pub fn dropped_clients(&self) -> u64
Monotonic count of clients evicted for falling behind — a full outbound queue — since this server was bound. A client that disconnected cleanly is not counted here.
A slow consumer is pruned without an error reaching it, so this counter is the producer-visible signal that an eviction happened. The owning service folds it into the state snapshot it already publishes so the eviction is observable remotely rather than silent. Lock-free.