A library for working with binaries and strings. The library tries to avoid
heap-allocations / memory-copy whenever possible by automatically choosing a reasonable
strategy: stack for small binaries; static-lifetime-binary or reference-counting. It's
easy to use (no lifetimes; the binary type is sized), Send + Sync
is optional (thus
no synchronization overhead), provides optional serde support and has a similar API for
strings and binaries. Custom binary/string types can be implemented for fine-tuning.
use FromIterator;
use Deref;
use ;
// static binary / static string
let static_bin: Bin = from_static;
let static_str: Str = from_static;
assert_eq!;
assert_eq!;
// non-static (but small enough to be stored on the stack)
let hello_bin: Bin = from_iter;
let hello_str: Str = copy_from_str;
assert_eq!;
assert_eq!;
// operations for binaries / strings
// length (number of bytes / number of utf-8 bytes)
assert_eq!;
assert_eq!;
// is_empty
assert_eq!;
assert_eq!;
// as_slice / as_str / deref / as_bin
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
// slice
assert_eq!;
assert_eq!;
// clone
assert_eq!;
assert_eq!;
// compare
assert!;
assert!;
// convert string into binary and binary into string
let hello_bin_from_str: Bin = hello_str.clone.into_bin;
assert_eq!;
let hello_str_from_bin: Str = from_utf8.expect;
assert_eq!;
// convert into Vec<u8> / String
assert_eq!;
assert_eq!;