ericseppanen / cddl-cat Goto Github PK
View Code? Open in Web Editor NEWA Rust library for validating CBOR or JSON data against a CDDL schema specification
License: MIT License
A Rust library for validating CBOR or JSON data against a CDDL schema specification
License: MIT License
serde_cbor
seems to be deprecated / archived, see: https://github.com/pyfisch/cbor, a good alternative for the future could be to use ciborium
.
Hi @ericseppanen! Thank you so much for this helpful implementation of cddl-cat
! We're currently looking into integrating it in https://github.com/p2panda/p2panda
One thing we would need is support for the .regexp
control operator. Do you have any pointers in what might be required to integrate it into cddl-cat
?
Thank you!
Some extended thoughts on deserialization:
I have been toying with the idea of doing "streaming" style validation: instead of deserializing the entire data structure before validation, only deserialize the fields that are immediately needed to perform the next "step" of validation. For maps, this would not change anything, but in some cases it would make the validation use a lot less memory. And the validation-failure path could short-circuit (returning without deserializing the rest of the data).
I built the cbor_tools
crate as a debugging tool, but something based on that might allow me to do streaming validation of CBOR. It would also allow some additional additional strict checks like "CDDL says f32, but the value is a CBOR f64"; that level of detail is currently lost during deserialization.
Optimizing the validation-failure path is probably not the best use of time; there are probably better things to spend my time on.
Also, I'm not sure if it would be possible to do streaming validation of JSON and I like the fact that both JSON and CBOR share the same validation code.
My repo compiles fine when i link to this repo via git
... However when i try and pull from crates-io i get this error below.
crates-io advertises v0.6.1, and this master repo also advertises v0.6.1. but i suspect they are out of sync. Can you publish v0.6.2 perhaps?
error[E0277]: the trait bound `cddl_cat::parser::ParseError: std::cmp::Eq` is not satisfied
--> src/util.rs:6:11
|
4 | #[derive(Debug, PartialEq, Eq)]
| -- in this derive macro expansion
5 | pub enum ValidateError {
6 | Parse(ParseError),
| ^^^^^^^^^^ the trait `std::cmp::Eq` is not implemented for `cddl_cat::parser::ParseError`
|
note: required by a bound in `AssertParamIsEq`
--> /home/thomas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/cmp.rs:313:31
|
313 | pub struct AssertParamIsEq<T: Eq + ?Sized> {
| ^^ required by this bound in `AssertParamIsEq`
= note: this error originates in the derive macro `Eq` (in Nightly builds, run with -Z macro-backtrace for more info)
```
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.