mirror of
https://codeberg.org/icewind/bitbuffer.git
synced 2026-06-03 16:44:06 +02:00
readme typo
This commit is contained in:
parent
758bba200b
commit
d51b57c17b
1 changed files with 11 additions and 9 deletions
16
README.md
16
README.md
|
|
@ -16,7 +16,7 @@ Once you have a BitStream, there are 2 different approaches of reading data
|
|||
|
||||
- read primitives, Strings and byte arrays, using `read_bool`, `read_int`, `read_float`, `read_byes` and `read_string`
|
||||
- read any type implementing the `BitRead` or `BitReadSized` traits using `read` and `read_sized`
|
||||
- `BitRead` is for types that can be read without requiring any size info (e.g. null-terminal strings, floats, whole integers, etc)
|
||||
- `BitRead` is for types that can be read without requiring any size info (e.g. null-terminated strings, floats, whole integers, etc)
|
||||
- `BitReadSized` is for types that require external sizing information to be read (fixed length strings, arbitrary length integers
|
||||
|
||||
The `BitRead` and `BitReadSized` traits can be used with `#[derive]` if all fields implement `BitRead` or `BitReadSized`.
|
||||
|
|
@ -34,14 +34,16 @@ struct ComplexType {
|
|||
third: bool,
|
||||
}
|
||||
|
||||
let bytes = vec![
|
||||
fn main() {
|
||||
let bytes = vec![
|
||||
0b1011_0101, 0b0110_1010, 0b1010_1100, 0b1001_1001,
|
||||
0b1001_1001, 0b1001_1001, 0b1001_1001, 0b1110_0111
|
||||
];
|
||||
let buffer = BitBuffer::new(bytes, LittleEndian);
|
||||
let mut stream = BitStream::new(buffer);
|
||||
let value: u8 = stream.read_int(7)?;
|
||||
let complex: ComplexType = stream.read()?;
|
||||
];
|
||||
let buffer = BitBuffer::new(bytes, LittleEndian);
|
||||
let mut stream = BitStream::new(buffer);
|
||||
let value: u8 = stream.read_int(7)?;
|
||||
let complex: ComplexType = stream.read()?;
|
||||
}
|
||||
```
|
||||
|
||||
## License
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue