pub struct BusCapture { /* private fields */ }Expand description
Unified bus capture — WireTap implementation with three storage modes.
Wrap in Arc to share between client and test code:
§Examples
use oms_modbus::*;
use std::sync::Arc;
let cap = Arc::new(BusCapture::unbounded());
let opts = ClientOptions::default().with_tap(cap.clone());Implementations§
Source§impl BusCapture
impl BusCapture
Sourcepub fn stats_only() -> Self
pub fn stats_only() -> Self
Statistics only — no recording, atomic counters only. Zero memory allocation beyond the counters themselves.
Sourcepub fn bounded(capacity: usize) -> Self
pub fn bounded(capacity: usize) -> Self
Bounded ring buffer — oldest records evicted when full.
Records are returned in chronological order by Self::drain and Self::snapshot.
capacity is clamped to a minimum of 1. Passing 0 is equivalent to
passing 1 — a single-record buffer.
pub fn count_requests(&self) -> u64
pub fn count_responses(&self) -> u64
pub fn count_errors(&self) -> u64
pub fn dropped(&self) -> u64
pub fn reset_stats(&self)
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn drain(&self) -> Vec<PacketRecord>
pub fn drain(&self) -> Vec<PacketRecord>
Drain all records in chronological order. Stats are NOT reset.
Sourcepub fn snapshot(&self) -> Vec<PacketRecord>
pub fn snapshot(&self) -> Vec<PacketRecord>
Snapshot without clearing. Records are in chronological order.
Clones all records under the lock. For large capture buffers in
hot paths, prefer Self::drain which swaps the buffer and releases
the lock immediately.
Trait Implementations§
Source§impl WireTap for BusCapture
impl WireTap for BusCapture
Source§fn on_write(&self, bytes: &[u8], ts: u64)
fn on_write(&self, bytes: &[u8], ts: u64)
Bytes successfully written to the transport.
Called once per
poll_write that returns Ok(n) with n > 0.Auto Trait Implementations§
impl !Freeze for BusCapture
impl RefUnwindSafe for BusCapture
impl Send for BusCapture
impl Sync for BusCapture
impl Unpin for BusCapture
impl UnsafeUnpin for BusCapture
impl UnwindSafe for BusCapture
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