pub trait FixedSizeEncoding<const BYTE_LEN: usize, const FD_LEN: usize> {
const BYTE_LEN: usize = BYTE_LEN;
const FD_LEN: usize = FD_LEN;
// Required methods
fn encode(&self) -> ([u8; BYTE_LEN], [BorrowedFd<'_>; FD_LEN]);
fn decode(bytes: [u8; BYTE_LEN], fds: [OwnedFd; FD_LEN]) -> Self;
}
Expand description
Encoding/decoding functionality that relies on each message being
encoded to a constant (and small) “packet” size, allowing the use
of 1:1 sendmsg
and recvmsg
calls, i.e. removing the need for
any kind of “packet framing” that a SOCK_STREAM
needs to soundly
handle receiving a message’s fds through multiple recvmsg
calls.
Provided Associated Constants§
Required Methods§
fn encode(&self) -> ([u8; BYTE_LEN], [BorrowedFd<'_>; FD_LEN])
fn decode(bytes: [u8; BYTE_LEN], fds: [OwnedFd; FD_LEN]) -> Self
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.