mirror of
https://codeberg.org/icewind/bitbuffer.git
synced 2026-06-03 16:44:06 +02:00
flake updates
This commit is contained in:
parent
089be072be
commit
acb6265b83
3 changed files with 59 additions and 45 deletions
52
README.md
52
README.md
|
|
@ -4,27 +4,40 @@
|
||||||
|
|
||||||
# bitbuffer
|
# bitbuffer
|
||||||
|
|
||||||
Tools for reading and writing data types of arbitrary bit length and might not be byte-aligned in the source data
|
Tools for reading and writing data types of arbitrary bit length and might not
|
||||||
|
be byte-aligned in the source data
|
||||||
|
|
||||||
The main way of reading the binary data is to first create a `BitReadBuffer` ,wrap it into a `BitReadStream` and then read from the stream.
|
The main way of reading the binary data is to first create a `BitReadBuffer`
|
||||||
|
,wrap it into a `BitReadStream` and then read from the stream.
|
||||||
|
|
||||||
Once you have a BitStream, there are 2 different approaches of reading data
|
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_bytes` and `read_string`
|
- read primitives, Strings and byte arrays, using `read_bool`, `read_int`,
|
||||||
- read any type implementing the `BitRead` or `BitReadSized` traits using `read` and `read_sized`
|
`read_float`, `read_bytes` and `read_string`
|
||||||
- `BitRead` is for types that can be read without requiring any size info (e.g. null-terminal strings, floats, whole integers, etc)
|
- read any type implementing the `BitRead` or `BitReadSized` traits using `read`
|
||||||
- `BitReadSized` is for types that require external sizing information to be read (fixed length strings, arbitrary length integers
|
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)
|
||||||
|
- `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`.
|
The `BitRead` and `BitReadSized` traits can be used with `#[derive]` if all
|
||||||
|
fields implement `BitRead` or `BitReadSized`.
|
||||||
|
|
||||||
For writing the data you wrap the output `Vec` into a `BitWriteStream` which can then be used in a manner similar to the `BitReadStream`
|
For writing the data you wrap the output `Vec` into a `BitWriteStream` which can
|
||||||
|
then be used in a manner similar to the `BitReadStream`
|
||||||
|
|
||||||
- write primitives, Strings and byte arrays, using `write_bool`, `write_int`, `write_float`, `write_bytes` and `write_string`
|
- write primitives, Strings and byte arrays, using `write_bool`, `write_int`,
|
||||||
- write any type implementing the `BitWrite` or `BitWriteSized` traits using `write` and `write_sized`
|
`write_float`, `write_bytes` and `write_string`
|
||||||
- `BitWrite` is for types that can be written without requiring any size info (e.g. null-terminal strings, floats, whole integers, etc)
|
- write any type implementing the `BitWrite` or `BitWriteSized` traits using
|
||||||
- `BitWriteSized` is for types that require external sizing information to be written (fixed length strings, arbitrary length integers
|
`write` and `write_sized`
|
||||||
|
- `BitWrite` is for types that can be written without requiring any size info
|
||||||
|
(e.g. null-terminal strings, floats, whole integers, etc)
|
||||||
|
- `BitWriteSized` is for types that require external sizing information to be
|
||||||
|
written (fixed length strings, arbitrary length integers
|
||||||
|
|
||||||
Just like the read counterparts, `BitWrite` and `BitWriteSized` traits can be used with `#[derive]` if all fields implement `BitWrite` or `BitWriteSized`.
|
Just like the read counterparts, `BitWrite` and `BitWriteSized` traits can be
|
||||||
|
used with `#[derive]` if all fields implement `BitWrite` or `BitWriteSized`.
|
||||||
|
|
||||||
# Examples
|
# Examples
|
||||||
|
|
||||||
|
|
@ -62,14 +75,15 @@ write_stream.write(&ComplexType {
|
||||||
|
|
||||||
Licensed under either of
|
Licensed under either of
|
||||||
|
|
||||||
- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0)
|
- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
||||||
- MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT)
|
https://www.apache.org/licenses/LICENSE-2.0)
|
||||||
|
- MIT license ([LICENSE-MIT](LICENSE-MIT) or
|
||||||
|
https://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
at your option.
|
at your option.
|
||||||
|
|
||||||
### Contribution
|
### Contribution
|
||||||
|
|
||||||
Unless you explicitly state otherwise, any contribution intentionally
|
Unless you explicitly state otherwise, any contribution intentionally submitted
|
||||||
submitted for inclusion in the work by you, as defined in the Apache-2.0
|
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
|
||||||
license, shall be dual licensed as above, without any additional terms or
|
dual licensed as above, without any additional terms or conditions.
|
||||||
conditions.
|
|
||||||
|
|
|
||||||
42
flake.lock
generated
42
flake.lock
generated
|
|
@ -2,11 +2,11 @@
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"crane": {
|
"crane": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1739936662,
|
"lastModified": 1742394900,
|
||||||
"narHash": "sha256-x4syUjNUuRblR07nDPeLDP7DpphaBVbUaSoeZkFbGSk=",
|
"narHash": "sha256-vVOAp9ahvnU+fQoKd4SEXB2JG2wbENkpqcwlkIXgUC0=",
|
||||||
"owner": "ipetkov",
|
"owner": "ipetkov",
|
||||||
"repo": "crane",
|
"repo": "crane",
|
||||||
"rev": "19de14aaeb869287647d9461cbd389187d8ecdb7",
|
"rev": "70947c1908108c0c551ddfd73d4f750ff2ea67cd",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -22,11 +22,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1739796086,
|
"lastModified": 1747659009,
|
||||||
"narHash": "sha256-jxpUiVJ6O+V1YsXsvWdMgqnv8zk9TFiqF86CRdGGGH4=",
|
"narHash": "sha256-3FFAthqh4rWKTClF+WgM+9CmMDlnfWcPdd3hGBFVNHc=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "flakelight",
|
"repo": "flakelight",
|
||||||
"rev": "540efca2f9015aff7dc574c7a03404e5fa72d42f",
|
"rev": "93d72adbe0b022791b0faadfb31cb6e98c37f0ad",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -44,26 +44,26 @@
|
||||||
"rust-overlay": "rust-overlay"
|
"rust-overlay": "rust-overlay"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1740345481,
|
"lastModified": 1748035164,
|
||||||
"narHash": "sha256-1lAgc6UhpYTHwKm88BUNSnC9nlT4a00rc6UmaE2n0LY=",
|
"narHash": "sha256-PMWOFLi3oU/Eb+y4a0MlHS0IcUZ+UFCoGmA1Q7DnoW4=",
|
||||||
"owner": "icewind1991",
|
"ref": "refs/heads/main",
|
||||||
"repo": "mill-scale",
|
"rev": "e6d5d797b3d2c738309152f2545518b2b117f72b",
|
||||||
"rev": "582f15f238322a7f9c129aa5adef12dde3f0a5ce",
|
"revCount": 48,
|
||||||
"type": "github"
|
"type": "git",
|
||||||
|
"url": "https://codeberg.org/icewind/mill-scale.git"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "icewind1991",
|
"type": "git",
|
||||||
"repo": "mill-scale",
|
"url": "https://codeberg.org/icewind/mill-scale.git"
|
||||||
"type": "github"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1740162160,
|
"lastModified": 1747862697,
|
||||||
"narHash": "sha256-SSYxFhqCOb3aiPb6MmN68yEzBIltfom8IgRz7phHscM=",
|
"narHash": "sha256-U4HaNZ1W26cbOVm0Eb5OdGSnfQVWQKbLSPrSSa78KC0=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "11415c7ae8539d6292f2928317ee7a8410b28bb9",
|
"rev": "2baa12ff69913392faf0ace833bc54bba297ea95",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -88,11 +88,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1740277845,
|
"lastModified": 1742697269,
|
||||||
"narHash": "sha256-NNU0CdiaSbAeZ8tpDG4aFi9qtcdlItRvk8Xns9oBrVU=",
|
"narHash": "sha256-Lpp0XyAtIl1oGJzNmTiTGLhTkcUjwSkEb0gOiNzYFGM=",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "f933070c29f9c1c5457447a51903f27f76ebb519",
|
"rev": "01973c84732f9275c50c5f075dd1f54cc04b3316",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
mill-scale = {
|
mill-scale = {
|
||||||
url = "github:icewind1991/mill-scale";
|
url = "git+https://codeberg.org/icewind/mill-scale.git";
|
||||||
inputs.flakelight.follows = "flakelight";
|
inputs.flakelight.follows = "flakelight";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue