Skip to main content

Crate wire_codec

Crate wire_codec 

Source
Expand description

§wire-codec

Binary frame codec and protocol codec toolkit. Length-prefixed, delimiter- based, and custom framing strategies. Built-in varint, zigzag, and bitfield encoding. Runtime-agnostic foundation under network-protocol crates.

§Module map

§Example

Length-prefix a payload, then read it back:

use wire_codec::WriteBuf;
use wire_codec::framing::{Endian, Framer, LengthPrefixed, LengthWidth};

let framer = LengthPrefixed::new(LengthWidth::U16, Endian::Big);

let mut out = [0u8; 32];
let mut buf = WriteBuf::new(&mut out);
framer.write_frame(b"ping", &mut buf).unwrap();
let n = buf.position();

let frame = framer.next_frame(&out[..n]).unwrap().unwrap();
assert_eq!(frame.payload(), b"ping");

§Status

Pre-1.0 foundation. Public API surface defined in this release; further milestones expand implementations and lock semantics in.

§License

Dual-licensed under Apache-2.0 OR MIT.

Re-exports§

pub use bitfield::BitReader;
pub use bitfield::BitWriter;
pub use buf::ReadBuf;
pub use buf::WriteBuf;
pub use error::Error;
pub use error::Result;
pub use traits::Decode;
pub use traits::Encode;

Modules§

bitfield
Bit-level read and write cursors.
buf
Zero-copy cursor primitives over borrowed byte slices.
error
Error type returned by codec and framing operations.
framing
Frame extraction strategies.
traits
Core traits implemented by every encodable value.
varint
Unsigned LEB128 varint encoding.
zigzag
Zigzag encoding for signed integers.

Constants§

VERSION
Crate version string, populated by Cargo at build time.