changed project name to 'bincode'
This commit is contained in:
parent
a8edf6cdfd
commit
ed96883a53
|
|
@ -1,4 +1,4 @@
|
||||||
[package]
|
[package]
|
||||||
name = "binary_encode"
|
name = "bincode"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = ["Ty Overby <ty@pre-alpha.com>"]
|
authors = ["Ty Overby <ty@pre-alpha.com>"]
|
||||||
|
|
|
||||||
14
README.md
14
README.md
|
|
@ -1,23 +1,23 @@
|
||||||
# Binary Encoder / Decoder
|
# Binary Encoder / Decoder
|
||||||
|
|
||||||
[](https://travis-ci.org/TyOverby/binary-encode)
|
[](https://travis-ci.org/TyOverby/bincode)
|
||||||
|
|
||||||
A compact encoder / decoder pair that uses an binary zero-fluff encoding scheme.
|
A compact encoder / decoder pair that uses an binary zero-fluff encoding scheme.
|
||||||
The size of the encoded object will be the same or smaller than the size that
|
The size of the encoded object will be the same or smaller than the size that
|
||||||
the object takes up in memory in a running Rust program.
|
the object takes up in memory in a running Rust program.
|
||||||
|
|
||||||
In addition to exposing two simple funcitons that encode to `Vec<u8>` and decode
|
In addition to exposing two simple funcitons that encode to Vec<u8> and decode
|
||||||
from `Vec<u8>`, binary-encode exposes a Reader/Writer API that makes it work
|
from Vec<u8>, binary-encode exposes a Reader/Writer API that makes it work
|
||||||
perfectly with other stream-based apis such as rust files, network streams,
|
perfectly with other stream-based apis such as rust files, network streams,
|
||||||
and the [flate2-rs](https://github.com/alexcrichton/flate2-rs) compression
|
and the [flate2-rs](https://github.com/alexcrichton/flate2-rs) compression
|
||||||
library.
|
library.
|
||||||
|
|
||||||
[Api Documentation](http://tyoverby.github.io/binary-encode/binary_encode/)
|
[Api Documentation](http://tyoverby.github.io/bincode/bincode/)
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
extern crate binary_encode;
|
extern crate bincode;
|
||||||
extern crate serialize;
|
extern crate serialize;
|
||||||
|
|
||||||
#[deriving(Encodable, Decodable, PartialEq)]
|
#[deriving(Encodable, Decodable, PartialEq)]
|
||||||
|
|
@ -36,8 +36,8 @@ fn main() {
|
||||||
entities: vec![Entity {x: 0.0, y: 4.0}, Entity {x: 10.0, y: 20.5}]
|
entities: vec![Entity {x: 0.0, y: 4.0}, Entity {x: 10.0, y: 20.5}]
|
||||||
};
|
};
|
||||||
|
|
||||||
let encoded: Vec<u8> = binary_encode::encode(&world).unwrap();
|
let encoded: Vec<u8> = bincode::encode(&world).unwrap();
|
||||||
let decoded: World = binary_encode::decode(encoded).unwrap();
|
let decoded: World = bincode::decode(encoded).unwrap();
|
||||||
|
|
||||||
assert!(world == decoded);
|
assert!(world == decoded);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
extern crate binary_encode;
|
extern crate bincode;
|
||||||
extern crate serialize;
|
extern crate serialize;
|
||||||
|
|
||||||
#[deriving(Encodable, Decodable, PartialEq)]
|
#[deriving(Encodable, Decodable, PartialEq)]
|
||||||
|
|
@ -17,8 +17,8 @@ fn main() {
|
||||||
entities: vec![Entity {x: 0.0, y: 4.0}, Entity {x: 10.0, y: 20.5}]
|
entities: vec![Entity {x: 0.0, y: 4.0}, Entity {x: 10.0, y: 20.5}]
|
||||||
};
|
};
|
||||||
|
|
||||||
let encoded: Vec<u8> = binary_encode::encode(&world).unwrap();
|
let encoded: Vec<u8> = bincode::encode(&world).unwrap();
|
||||||
let decoded: World = binary_encode::decode(encoded).unwrap();
|
let decoded: World = bincode::decode(encoded).unwrap();
|
||||||
|
|
||||||
assert!(world == decoded);
|
assert!(world == decoded);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
extern crate bincode;
|
||||||
|
extern crate serialize;
|
||||||
|
|
||||||
|
use std::collections::HashMap;
|
||||||
|
use std::io::{Truncate, ReadWrite, File, BufferedReader};
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let mut word_counts = HashMap::new();
|
||||||
|
word_counts.insert("foo".to_string(), 3u);
|
||||||
|
word_counts.insert("fizzbuzz".to_string(), 8u);
|
||||||
|
|
||||||
|
let file = File::open_mode(&Path::new("store.bin"), Truncate, ReadWrite);
|
||||||
|
let mut file = file.unwrap();
|
||||||
|
bincode::encode_into(&word_counts, &mut file);
|
||||||
|
file.fsync().unwrap();
|
||||||
|
|
||||||
|
let out: HashMap<String, uint> =
|
||||||
|
bincode::decode_from(&mut BufferedReader::new(file)).unwrap();
|
||||||
|
|
||||||
|
assert!(out == word_counts);
|
||||||
|
}
|
||||||
|
|
@ -1,12 +1,18 @@
|
||||||
# Binary Encoder / Decoder
|
# Binary Encoder / Decoder
|
||||||
|
|
||||||
[](https://travis-ci.org/TyOverby/binary-encode)
|
[](https://travis-ci.org/TyOverby/bincode)
|
||||||
|
|
||||||
A compact encoder / decoder pair that uses an binary zero-fluff encoding scheme.
|
A compact encoder / decoder pair that uses an binary zero-fluff encoding scheme.
|
||||||
The size of the encoded object will be the same or smaller than the size that
|
The size of the encoded object will be the same or smaller than the size that
|
||||||
the object takes up in memory in a running Rust program.
|
the object takes up in memory in a running Rust program.
|
||||||
|
|
||||||
[Api Documentation](http://tyoverby.github.io/binary-encode/binary_encode/)
|
In addition to exposing two simple funcitons that encode to Vec<u8> and decode
|
||||||
|
from Vec<u8>, binary-encode exposes a Reader/Writer API that makes it work
|
||||||
|
perfectly with other stream-based apis such as rust files, network streams,
|
||||||
|
and the [flate2-rs](https://github.com/alexcrichton/flate2-rs) compression
|
||||||
|
library.
|
||||||
|
|
||||||
|
[Api Documentation](http://tyoverby.github.io/bincode/bincode/)
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#![crate_name = "binary_encode"]
|
#![crate_name = "bincode"]
|
||||||
#![crate_type = "rlib"]
|
#![crate_type = "rlib"]
|
||||||
#![crate_type = "dylib"]
|
#![crate_type = "dylib"]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue