spinifex-unsigned-varint

Crates.iospinifex-unsigned-varint
lib.rsspinifex-unsigned-varint
version0.2.2
sourcesrc
created_at2020-03-31 09:02:47.572652
updated_at2020-03-31 09:02:47.572652
descriptionRust implementation of the unsigned variable integer format used in the Multiformat specifications.
homepage
repositoryhttps://github.com/jmcph4/spinifex-unsigned-varint
max_upload_size
id224788
size15,625
Jack (jmcph4)

documentation

README

spinifex-unsigned-varint

standard-readme compliant

Implementation of the unsigned variable integer type used in multiformats

Table of Contents

Install

$ git clone git@github.com:jmcph4/spinifex-unsigned-varint.git
$ cd spinifex-unsigned-varint
$ cargo build

Usage

/* initialise from native integer types */
let some_number: u128 = 128;
let my_uvarint: UVarInt = UVarInt::new(some_number);

/* encode into byte vector */
let my_uvarint_bytes: Vec<u8> = my_uvarint
println!("{:#b}", my_uvarint_bytes); /* "[128, 1]" */

/* decode from byte vector */
let my_other_uvarint_bytes: Vec<u8> = vec![128, 128, 1];
let my_other_uvarint: UVarInt = UVarInt::from_bytes(my_other_uvarint_bytes).unwrap();
println!("{}", my_other_uvarint); /* "uv16384" */

Maintainers

@jmcph4

Contributing

Small note: If editing the README, please conform to the standard-readme specification.

License

MIT © 2020 Jack McPherson

Commit count: 39

cargo fmt