Available on crate features
io and bytes only.Expand description
Encoder/Decoder implementation with Bytes
This module provides a codec implementation for bytes serialization and deserialization (noop per se).
§Examples
use compio_buf::{IoBuf, bytes::Bytes};
use compio_io::framed::codec::{Decoder, Encoder, bytes::BytesCodec};
let mut codec = BytesCodec::new();
let data = Bytes::from("Hello, world!");
// Encoding
let mut buffer = Vec::new();
codec.encode(data.clone(), &mut buffer).unwrap();
// Decoding
let decoded = codec.decode(&buffer.slice(..)).unwrap();
assert_eq!(decoded, data);Structs§
- Bytes
Codec - A codec for bytes serialization and deserialization.