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:
parent
9c3d98dc62
commit
6a74d8894e
2 changed files with 19 additions and 1 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue