pub struct TcpSender { /* private fields */ }Expand description
A hold-open bare-NDJSON-over-TCP sender for STREAMING dispatch (bd-772cb2): one connection is kept open across many commands instead of reconnecting per command. Connects lazily on the first cast and reconnects on the next cast after a write error (so a transient device drop does not abort the stream).
Implementations§
Source§impl TcpSender
impl TcpSender
Sourcepub fn new(host: &str, port: u16) -> Self
pub fn new(host: &str, port: u16) -> Self
Build a sender for host:port (no connection is made until the first cast).
Sourcepub fn cast_one(&mut self, cmd: &InjectionCommand) -> Result<(), AppError>
pub fn cast_one(&mut self, cmd: &InjectionCommand) -> Result<(), AppError>
Send one command as a bare NDJSON line over the held-open connection, connecting first if needed. On any I/O error the connection is dropped so the next call reconnects.
§Errors
AppError::internal on connect / write / flush failure (the stream is
reset for a fresh reconnect next time).
Auto Trait Implementations§
impl Freeze for TcpSender
impl RefUnwindSafe for TcpSender
impl Send for TcpSender
impl Sync for TcpSender
impl Unpin for TcpSender
impl UnsafeUnpin for TcpSender
impl UnwindSafe for TcpSender
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