Skip to content

Commit

Permalink
Readme and cargo manifest information
Browse files Browse the repository at this point in the history
  • Loading branch information
haxelion committed Dec 20, 2020
1 parent 8f55fd6 commit 9467be3
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 3 deletions.
10 changes: 9 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@ name = "bva"
version = "0.1.0"
authors = ["Charles Hubain <[email protected]>"]
edition = "2018"
description = "bva is a crate for manipulating bit vectors and doing arithmetics on arbitrarily sized bit vectors."
documentation = "https://docs.rs/bva"
readme = "README.md"
homepage = "https://github.com/haxelion/bva/"
repository = "https://github.com/haxelion/bva/"
license = "Apache-2.0"
keywords = ["bit", "vector", "binary", "arithmetics"]
categories = ["data-structures", "encoding", "mathematics"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[dev-dependencies]

rand = "0.7"
rand = "0.7"
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# bva

`bva` is a rust crate for manipulating bit vectors and doing arithmetics on arbitrarily sized bit
vectors.

This crate emphasizes optimizing storage by providing alternative storage options.
The module `fixed` contains implementations using unsigned integers as storage and thus
has a fixed capacity. The module `dynamic` contains an implementation using dynamically
allocated array of integers as storage and therefore has a dynamic capacity. The module
`auto` contains an implementation capable of switching at runtime between a fixed or
dynamic capacity implementation to try to minimize dynamic memory allocations.
All of those implementations implement the `BitVector` trait and can be freely mixed together
and converted into each other.

## Changelog

* 2020/12/20 - 0.1.0
* BitVector trait with fixed, dynamic and auto implementations.
* Conversion between all the implementations
* Basic arithmetic operations between the different implementations.
* Reading and writing bit vector in various format.

## TODO

* More "advanced" arithmetics: multiplication, division, remainder.
* Fix Display for bit vector longer than 128 bits.
* Bit operations.
* Iterator over bits, IntoIterator and FromIterator.
* Borrowing of bits and bit slice inside a bit vector.
* Really advanced arithmetics: gcd, modular exponentiation, ...
* no-std support

## Why

None of the existing crate really satisfied me and I wanted an implementation capable of
minimizing dynamic memory allocations by automatically switching to fixed storage.
I also wanted a crate that was capable of doing arithmetics on arbitrarily sized bit vectors, not
just powers of two.
Also it was great practice for my rust macro writing skills.
1 change: 1 addition & 0 deletions src/auto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ impl Binary for BV {
}
}

/// Warning: this implementation is broken for bit vector longer than 128 bits.
impl Display for BV {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Expand Down
1 change: 1 addition & 0 deletions src/dynamic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ impl Binary for BVN {
}
}

/// Warning: this implementation is broken for bit vector longer than 128 bits.
impl Display for BVN {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
if let Ok(b) = BV128::try_from(self) {
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Crate for manipulating bit vectors and doing arithmetic on arbitrary sized bit vectors.
//! Crate for manipulating bit vectors and doing arithmetic on arbitrarily sized bit vectors.
//!
//! This crate emphasizes optimizing storage by providing alternative storage options.
//! The module [`fixed`] contains implementations using unsigned integers as storage and thus
Expand Down Expand Up @@ -38,7 +38,7 @@ pub enum Endianness {
BE
}

/// A trait representing common bit vector operations
/// A trait representing common bit vector operations.
pub trait BitVector: Sized + Clone + Debug + PartialEq + Eq + Display + Binary + LowerHex + UpperHex {
/// Construct a bit vector made of `length` 0 bits.
/// Will panic if there is not enough capacity and it is a fixed variant.
Expand Down

0 comments on commit 9467be3

Please sign in to comment.