Skip to content

A small and easy crate to mutate or read u8 slices

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

soerenmeier/simple-bytes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CI crates.io docs.rs

A small and easy crate to mutate or read u8 slices.

Reads or writes any number using the byte order "big-endian".

Read a slice

use simple_bytes::{Bytes, BytesRead};

let bytes: Vec<u8> = (0..255).collect();
let mut slice: Bytes = bytes.as_slice().into();

assert_eq!(0, slice.read_u8());
assert_eq!(1, slice.read_u8());
assert_eq!(515, slice.read_u16());

Write to a slice

use simple_bytes::{BytesMut, BytesRead, BytesWrite};

let mut bytes = [0u8; 10];
let mut slice = BytesMut::from(bytes.as_mut());

slice.write_u8(1);
slice.write_f32(1.234);
slice.write(&[1u8, 2u8]);
assert_eq!(3, slice.remaining().len());

About

A small and easy crate to mutate or read u8 slices

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Languages