barf 1.0.0

Turn any input into "barf"-ed output.
Documentation
  • Coverage
  • 98.11%
    52 out of 53 items documented46 out of 47 items with examples
  • Size
  • Source code size: 20.91 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.46 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Vonr/barf
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Vonr

Barf

Turn any input into "barf"-ed output.

The name is a play on the purpose of this crate as a deparser - the opposite of the fantastic nom crate.

Barf aims to have some integrations with common datatypes such as LEB128 encoded variable-length integers.
When these integrations require another crate, they will be locked behind feature flags.

These integrations include

  • LEB128 with the "leb128" feature flag using nano-leb128.
  • vint64 with the "vint64" feature flag.

For a full list, see Cargo.toml.

If you want to see more integrations, please open an issue, or preferably a pull request.
There is also nothing stopping you from implementing [Barfer] on your own types and creating extension traits for them.

Barf can operate in no_std environments, but the "alloc" feature flag needs to be enabled for the default implementations of [Barfer] for [Vec] and [String].

use barf::Barfer;

// Vec<T> implements Barfer<T>.
let mut buf: Vec<u8> = Vec::new();

// Push 42_u8
buf.single(42); 
// Push "test".bytes() iterator with `many`
buf.many("test".bytes()); 
// Push 1, 2, and 3
buf.slice([1, 2, 3]); 

assert_eq!(
    &buf[..], 
    [
        42,                 // 42_u8
        116, 101, 115, 116, // Bytes in "test"
        1, 2, 3,            // 1, 2, and 3
    ]
);