pub struct PacketCodec;Trait Implementations§
Source§impl Decoder for PacketCodec
impl Decoder for PacketCodec
Source§fn decode(&mut self, src: &mut BytesMut) -> Result<Option<Packet>>
fn decode(&mut self, src: &mut BytesMut) -> Result<Option<Packet>>
Decodes a packet from the byte stream
Returns None if there aren’t enough bytes to form a complete packet.
The header is validated as soon as its 9 bytes have arrived, before any of
the payload is buffered, so a peer cannot make the connection hold a frame
larger than MAX_PAYLOAD_SIZE or one with a bad magic or version.
§Errors
Returns ProtocolError::InvalidHeader for a wrong magic,
ProtocolError::UnsupportedVersion for an unknown version, and
ProtocolError::OversizedPacket for a declared length over
MAX_PAYLOAD_SIZE.
Source§type Error = ProtocolError
type Error = ProtocolError
The type of unrecoverable frame decoding errors. Read more
Source§impl Encoder<Packet> for PacketCodec
impl Encoder<Packet> for PacketCodec
Source§fn encode(&mut self, packet: Packet, dst: &mut BytesMut) -> Result<()>
fn encode(&mut self, packet: Packet, dst: &mut BytesMut) -> Result<()>
Encodes a packet into the byte stream
§Errors
Returns ProtocolError::OversizedPacket if the payload is larger than
MAX_PAYLOAD_SIZE, which the receiving side would reject.
Source§type Error = ProtocolError
type Error = ProtocolError
The type of encoding errors. Read more
Auto Trait Implementations§
impl Freeze for PacketCodec
impl RefUnwindSafe for PacketCodec
impl Send for PacketCodec
impl Sync for PacketCodec
impl Unpin for PacketCodec
impl UnsafeUnpin for PacketCodec
impl UnwindSafe for PacketCodec
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