1
0
Fork 0
mirror of https://codeberg.org/icewind/bitbuffer.git synced 2026-06-03 16:44:06 +02:00

add optional schema

This commit is contained in:
Robin Appelman 2021-07-25 22:31:46 +02:00
commit 6a74d8894e
2 changed files with 19 additions and 1 deletions

View file

@ -803,3 +803,20 @@ fn test_serde_roundtrip() {
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)
}
}