pub struct Channel { /* private fields */ }Expand description
Blocking, length-prefixed JSON channel over a Unix stream socket.
Uses 4-byte big-endian length + JSON payload for robustness.
Implementations§
Source§impl Channel
impl Channel
pub fn new(stream: UnixStream) -> Self
Sourcepub fn recv<T: for<'de> Deserialize<'de>>(&mut self) -> Result<Option<T>>
pub fn recv<T: for<'de> Deserialize<'de>>(&mut self) -> Result<Option<T>>
Receive a deserializable message. Blocks until a message arrives. Returns Ok(None) on clean EOF (peer closed).
Sourcepub fn set_read_timeout(&mut self, timeout: Option<Duration>) -> Result<()>
pub fn set_read_timeout(&mut self, timeout: Option<Duration>) -> Result<()>
Set a read timeout on the underlying socket.
After this, recv() will return an error if no data arrives
within the given duration (instead of blocking forever).
Sourcepub fn set_write_timeout(&mut self, timeout: Option<Duration>) -> Result<()>
pub fn set_write_timeout(&mut self, timeout: Option<Duration>) -> Result<()>
Set a write timeout on the underlying socket.
Without this, send() calls write_all() which blocks indefinitely
when the peer stops draining its receive buffer — e.g. a wedged shim
that stopped reading. A blocking write_all inside the daemon’s
poll_shim_handles / ping_pong tick wedges the ENTIRE daemon event
loop on a single stuck handle, which matches the documented “daemon
freezes after 10-15 min productive window” failure mode. Setting a
bounded write timeout turns that hard-hang into a regular send()
error that the caller can classify as a stale / dead handle and
escalate via the usual respawn / crash paths.
Auto Trait Implementations§
impl Freeze for Channel
impl RefUnwindSafe for Channel
impl Send for Channel
impl Sync for Channel
impl Unpin for Channel
impl UnsafeUnpin for Channel
impl UnwindSafe for Channel
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.