pub trait PhysicalTransport {
// Required methods
fn send(&mut self, data: &[u8]) -> Result<()>;
fn receive(&mut self, buf: &mut [u8]) -> Result<usize>;
// Provided method
fn set_read_timeout(&mut self, timeout: Option<Duration>) -> Result<()> { ... }
}Expand description
A bidirectional byte channel abstracting the physical medium.
Framing sub-layers (HDLC, wrapper) are built on top of this trait, so they are independent of whether the underlying medium is a serial line, a TCP connection or a UDP socket.
Required Methods§
Provided Methods§
Sourcefn set_read_timeout(&mut self, timeout: Option<Duration>) -> Result<()>
fn set_read_timeout(&mut self, timeout: Option<Duration>) -> Result<()>
Sets the maximum time a subsequent receive call may
block before returning an io::ErrorKind::TimedOut (or
io::ErrorKind::WouldBlock) error. None waits indefinitely (the
default behaviour, and what every receive implementation must do
when this method is never called).
Used by crate::transport::hdlc::HdlcLayer to enforce the IEC 62056-46
inter-octet and inactivity timeouts. The default implementation is a
no-op that returns Ok(()): a transport that ignores this request
(i.e. keeps blocking indefinitely) makes those timeouts inactive but
otherwise behaves exactly as before this method existed — mirrors
std::net::TcpStream::set_read_timeout, which most network
transports can delegate to directly.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".