compris

Crates.iocompris
lib.rscompris
version
sourcesrc
created_at2024-12-08 03:10:39.062436
updated_at2024-12-08 03:10:39.062436
descriptionComposite Primitive Schema (CPS) for Rust
homepage
repositoryhttps://github.com/tliron/rust-compris
max_upload_size
id1476038
Cargo.toml error:TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Tal Liron (tliron)

documentation

README

Work in progress, not ready for general use

Compris: Composite Primitive Schema (CPS)

A Rust library to work with Composite Primitive Schema (CPS) data in various formats.

What is the Composite Primitive Schema?

It refers to primitive data types (numbers, booleans, strings, etc.), with the addition of lists and maps, allowing for nested structures (hence, it is composite). It is a concept that is a schema that is very widely used but has remarkably remained unnamed. Until now. You're welcome. See here for full details.

Some people gloss it as "JSON", but that's misleading and ultimately unhelpful because JSON is merely one representation format for the data, and rather limited at that (e.g. implementations do not always preserve the distinction between integers and floats). So instead of saying "let's just store it in JSON", say "let's just store it in CPS", and use Compris to do the heavy lifting, allowing you (and your users) to select from any supported representation format.

J'ai compris!

Supported Representation Formats

  • YAML
  • JSON, including an "XJSON" convention for extending JSON to support all CPS types
  • XML via a conventional schema (work in progress)
  • CBOR
  • MessagePack

Compris can read any of these formats into normalized Rust data types. This saves you from having to deal with different types from different parsing libraries. These types also include source location information (column and row) for debugging.

All formats are enabled by default, but can be turned off selectively using default-features = false.

Need more formats? We accept contributions and suggestions!

Serialization

Our normalized types can be serialized via serde (optional serde feature). We support pretty printing for human readability, including colorization for terminals.

Actually, this feature can be used with any Rust type that supports serde serialization, not just our normalized types. It is thus useful if you just need to easily write to various formats.

cpsq

Also included is a cpsq CLI tool for querying and converting any CPS format.

References

Libraries implementing this concept for other languages:

License

Like much of the Rust ecosystem, licensed under your choice of either of

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 3

cargo fmt