pub struct MessageCodec { /* private fields */ }Expand description
Tokio codec for length-prefixed BitTorrent messages.
Wire format: <4-byte big-endian length><payload>
where payload = <message-id><message-body> (or empty for keep-alive).
Implementations§
Source§impl MessageCodec
impl MessageCodec
Sourcepub fn with_max_size(self, max: usize) -> Self
pub fn with_max_size(self, max: usize) -> Self
Set the maximum allowed message size.
Trait Implementations§
Source§impl Decoder for MessageCodec
impl Decoder for MessageCodec
Source§fn decode(
&mut self,
src: &mut BytesMut,
) -> Result<Option<Message<Bytes>>, Error>
fn decode( &mut self, src: &mut BytesMut, ) -> Result<Option<Message<Bytes>>, Error>
Attempts to decode a frame from the provided buffer of bytes. Read more
Source§impl Default for MessageCodec
impl Default for MessageCodec
Auto Trait Implementations§
impl Freeze for MessageCodec
impl RefUnwindSafe for MessageCodec
impl Send for MessageCodec
impl Sync for MessageCodec
impl Unpin for MessageCodec
impl UnsafeUnpin for MessageCodec
impl UnwindSafe for MessageCodec
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