Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
bitrange
getting started
To get started, add this to your Cargo.toml
:
bitrange = "0.1.0"
Then add the following code to your main.rs
or lib.rs
#![feature(proc_macro)]
#[macro_use]
extern crate bitrange;
bitrange needs a nightly version of the compiler because it uses the feature proc_macro
which is not stabilized yet
The last field may not have a trailing comma at this point in time
examples
Bitrange helps you map bit fields to proper getters and setters.
Say you're trying to make an IP parser. The rfc will give you this:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version| IHL |Type of Service| Total Length |
If you wanted to parse this in Rust, you'd have to make the following mapping:
- the first 4 bits are mapped to
version
- The next 4 bits are mapped to
ihl
- The next 8 bits are mapped to
type_of_service
- The last 16 bits are mapped to
total_length
With bitrange, you can easily map bytes to fields. To parse this part of the protocol, simply write
extern crate bitrange;
bitrange!
If you wanted to make a field mutable, simply add a second ident to the field mapping, e.g.:
bitrange!
In addition, you can define constraints to bits that have to always be 0 or 1
bitrange!
Compile-time checks
bitrange will also check fields at compile time to see if they exist
bitrange!
However, this does not work for unmapped fields
bitrange!