Skip to content

Commit c1ff254

Browse files
committed
fixed tests, add doc
1 parent 2ae68ef commit c1ff254

File tree

5 files changed

+39
-3
lines changed

5 files changed

+39
-3
lines changed

src/bson.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
2020
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

22+
//! BSON definition
23+
2224
use std::collections::BTreeMap;
2325
use std::string;
2426

src/decoder.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
2020
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

22+
//! Decoder
23+
2224
use std::io::{self, Read};
2325
use std::str;
2426
use std::convert::From;

src/encoder.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
2020
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

22+
//! Encoder
23+
2224
use std::io::{self, Write};
2325
use std::convert::From;
2426
use std::mem;
@@ -325,7 +327,7 @@ mod test {
325327
enc.encode_document(&doc).unwrap();
326328
}
327329

328-
assert_eq!(&buf[..], dst);
330+
assert_eq!(&buf[..], &dst[..]);
329331
}
330332

331333
#[test]
@@ -342,6 +344,6 @@ mod test {
342344
enc.encode_document(&doc).unwrap();
343345
}
344346

345-
panic!("{:?}", buf);
347+
assert_eq!(&buf[..], &dst[..]);
346348
}
347349
}

src/lib.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,36 @@
2121

2222
#![feature(core)]
2323

24+
//! BSON is a binary format in which zero or more key/value pairs are stored as a single entity.
25+
//! We call this entity a document.
26+
//!
27+
//! This library supports Version 1.0 of BSON standard.
28+
//!
29+
//! ## Basic usage
30+
//!
31+
//! ```rust
32+
//! extern crate bson;
33+
//! use std::io::Cursor;
34+
//! use bson::{Bson, Document, Encoder, Decoder};
35+
//!
36+
//! fn main() {
37+
//! let mut doc = Document::new();
38+
//! doc.insert("foo".to_string(), Bson::String("bar".to_string()));
39+
//!
40+
//! let mut buf = Vec::new();
41+
//! {
42+
//! let mut enc = Encoder::new(&mut buf);
43+
//! enc.encode_document(&doc).unwrap();
44+
//! }
45+
//!
46+
//! let mut r = Cursor::new(&buf[..]);
47+
//! {
48+
//! let mut dec = Decoder::new(&mut r);
49+
//! let doc = dec.decode_document().unwrap();
50+
//! }
51+
//! }
52+
//! ```
53+
2454
extern crate rustc_serialize;
2555
extern crate chrono;
2656
extern crate byteorder;

src/spec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
2020
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

22-
/// BSON Specification Version 1.0
22+
//! BSON Specification Version 1.0
2323
/// http://bsonspec.org/spec.html
2424
2525
use std::convert::From;

0 commit comments

Comments
 (0)