mirror of
https://codeberg.org/icewind/bitbuffer.git
synced 2026-06-03 08:34:07 +02:00
add optional schema
This commit is contained in:
parent
9c3d98dc62
commit
6a74d8894e
2 changed files with 19 additions and 1 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "bitbuffer"
|
name = "bitbuffer"
|
||||||
version = "0.10.2"
|
version = "0.10.3"
|
||||||
authors = ["Robin Appelman <robin@icewind.nl>"]
|
authors = ["Robin Appelman <robin@icewind.nl>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
description = "Reading bit sequences from a byte slice"
|
description = "Reading bit sequences from a byte slice"
|
||||||
|
|
@ -13,6 +13,7 @@ err-derive = "0.3"
|
||||||
bitbuffer_derive = { version = "0.10", path = "bitbuffer_derive" }
|
bitbuffer_derive = { version = "0.10", path = "bitbuffer_derive" }
|
||||||
memchr = "2"
|
memchr = "2"
|
||||||
serde = { version = "1", features = ["derive"], optional = true }
|
serde = { version = "1", features = ["derive"], optional = true }
|
||||||
|
schemars = { version = "0.8", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
maplit = "1"
|
maplit = "1"
|
||||||
|
|
|
||||||
|
|
@ -803,3 +803,20 @@ fn test_serde_roundtrip() {
|
||||||
|
|
||||||
assert_eq!(result, stream);
|
assert_eq!(result, stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "schemars")]
|
||||||
|
impl<'a, E: Endianness> schemars::JsonSchema for BitReadStream<'a, E> {
|
||||||
|
fn schema_name() -> String {
|
||||||
|
"BitReadStream".into()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
|
||||||
|
#[derive(schemars::JsonSchema)]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
struct StreamSchema {
|
||||||
|
data: Vec<u8>,
|
||||||
|
bit_length: usize,
|
||||||
|
}
|
||||||
|
StreamSchema::json_schema(gen)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue