Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jmcph4/spinifex-unsigned-varint
Implementation of the Multiformat unsigned variable integer type
https://github.com/jmcph4/spinifex-unsigned-varint
integer multiformat multiformat-specifications multiformat-unsigned-varint varint
Last synced: 3 days ago
JSON representation
Implementation of the Multiformat unsigned variable integer type
- Host: GitHub
- URL: https://github.com/jmcph4/spinifex-unsigned-varint
- Owner: jmcph4
- License: mit
- Created: 2020-03-24T05:32:35.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-03-31T08:58:45.000Z (over 4 years ago)
- Last Synced: 2024-10-18T12:56:14.203Z (21 days ago)
- Topics: integer, multiformat, multiformat-specifications, multiformat-unsigned-varint, varint
- Language: Rust
- Size: 26.4 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# spinifex-unsigned-varint
[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
Implementation of the unsigned variable integer type used in multiformats
## Table of Contents
- [Install](#install)
- [Usage](#usage)
- [API](#api)
- [Maintainers](#maintainers)
- [Contributing](#contributing)
- [License](#license)## Install
```shell
$ git clone [email protected]:jmcph4/spinifex-unsigned-varint.git
$ cd spinifex-unsigned-varint
$ cargo build
```## Usage
```rust
/* 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 = my_uvarint
println!("{:#b}", my_uvarint_bytes); /* "[128, 1]" *//* decode from byte vector */
let my_other_uvarint_bytes: Vec = vec![128, 128, 1];
let my_other_uvarint: UVarInt = UVarInt::from_bytes(my_other_uvarint_bytes).unwrap();
println!("{}", my_other_uvarint); /* "uv16384" */
```## Maintainers
[@jmcph4](https://github.com/jmcph4)
## Contributing
Small note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.
## License
MIT © 2020 Jack McPherson