aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2015-02-05 18:40:31 -0500
committerAndrew Gallant <jamslam@gmail.com>2015-02-05 18:40:31 -0500
commit1c5bfc8fb69be0f39b0f8a1ea8e5c840ec4e5dbb (patch)
tree62bbadcbbf9a7c6fd16af5d15f77965ad95ae93c /README.md
parent24d51df81bd15df95b3053a397577c2bebe23e6b (diff)
downloadbyteorder-1c5bfc8fb69be0f39b0f8a1ea8e5c840ec4e5dbb.tar.gz
Flesh out the README.
Diffstat (limited to 'README.md')
-rw-r--r--README.md54
1 files changed, 43 insertions, 11 deletions
diff --git a/README.md b/README.md
index 231bad2..19328a8 100644
--- a/README.md
+++ b/README.md
@@ -1,17 +1,49 @@
-Convenience functions for reading and writing integers/floats in various byte
-orders such as big-endian and little-endian. This is meant to replace the old
+This crate provides convenience methods for encoding and decoding numbers in
+either big-endian or little-endian order. This is meant to replace the old
methods defined on the standard library `Reader` and `Writer` traits.
-Work in progress.
+[![Build status](https://api.travis-ci.org/BurntSushi/byteorder.png)](https://travis-ci.org/BurntSushi/byteorder)
+Licensed under the [UNLICENSE](http://unlicense.org).
-### TODO
-1. `f32` and `f64` support. (trivial)
-2. Flesh out the README. (Install, examples, links to docs, limitations.)
+### Documentation
+
+[http://burntsushi.net/rustdoc/byteorder/](http://burntsushi.net/rustdoc/byteorder/).
+
+The documentation includes examples.
+
+
+### Installation
+
+This crate works with Cargo and is on
+[crates.io](https://crates.io/crates/byteorder). The package is regularly
+updated. Add is to your `Cargo.toml` like so:
+
+```toml
+[dependencies]
+byteorder = "*"
+```
+
+If you want to augment existing `Reader` and `Writer` types, then import the
+extension methods like so:
+
+```rust
+extern crate byteorder;
+
+use byteorder::{ReaderBytesExt, WriterBytesExt, BigEndian, LittleEndian};
+```
+
+For example:
+
+```rust
+use std::old_io::MemReader;
+use byteorder::{BigEndian, ReaderBytesExt};
+
+let mut rdr = MemReader::new(vec![2, 5, 3, 0]);
+// Note that we use type parameters to indicate which kind of byte order
+// we want!
+assert_eq!(517, rdr.read_u16::<BigEndian>().unwrap());
+assert_eq!(768, rdr.read_u16::<BigEndian>().unwrap());
+```
-### Ideas?
-Use the `rustc-serialize` infrastructure, but it is known to be Not Fast. So
-I'm skeptical of how useful it would be. Basically, it would let you say
-something like: `let n: u32 = rdr.decode::<BigEndian>()` as opposed to
-`let n = rdr.read_u32::<BigEndian>()`. Doesn't seem like an obvious win.