tokio-u8-codec 0.1.0

A Tokio codec that just reads and writes u8s
Documentation
  • Coverage
  • 20%
    1 out of 5 items documented1 out of 3 items with examples
  • Size
  • Source code size: 5.17 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.73 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 14s Average build duration of successful builds.
  • all releases: 14s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Documentation
  • paulkernfeld/tokio-u8-codec
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • paulkernfeld

tokio-u8-codec

A Tokio codec that just reads and writes u8s.

This is probably not a very performant way to process streams of bytes because it only looks at one byte at a time.

extern crate bytes;
extern crate tokio_io;
extern crate tokio_u8_codec;

use tokio_io::codec::{Decoder, Encoder};
use tokio_u8_codec::U8Codec;
use bytes::BytesMut;

fn main() {
    let mut buf: BytesMut = Default::default();
    let mut codec: U8Codec = Default::default();
    codec.encode(1, &mut buf).unwrap();
    codec.encode(2, &mut buf).unwrap();
    assert_eq!(codec.decode(&mut buf).unwrap(), Some(1));
    assert_eq!(codec.decode(&mut buf).unwrap(), Some(2));
    assert_eq!(codec.decode(&mut buf).unwrap(), None);
}

License: MIT/Apache-2.0