Expand description
A Rust library to work with CPS (Composite Primitive Schema) data and parse it from and serialize it to several binary and textual representation formats, such as YAML, JSON, and CBOR.
A useful side effect of this bi-direction is that Compris can be used to convert between these formats.
What is CPS? It’s the implicit, common data schema underlying these representation formats. It comprises primitive data types (numbers, booleans, strings, etc.) as well as list and map collection types, which enable a nested (recursive) structure. Hence it is “composite” (a.k.a. “algebraic”).
And yet despite being so widely used, CPS has been unnamed… until now. You’re welcome.
CPS is sometimes glossed as “JSON”, but that’s misleading and ultimately unhelpful because JSON is merely one representation format for the data, and is actually comparatively quite limited (e.g. implementations do not often preserve the distinction between integers and floats). So instead of saying “let’s just store it as JSON”, say “let’s just store it as CPS”, and use Compris to handle the representation. It will allow you and your users to select from all supported formats at runtime.
Compris is pronounced “com-PREE”. The name comes from shortening CompositePrimitiveSchema to ComPriS.
For more information and usage examples see the home page.
J’ai compris!
Modules§
- annotate
- Annotate any type.
- de
serde - General-purpose serde deserialization using normal types as the intermediary.
- hints
- Hints for extending representation formats (such as XJSON).
- kv
- Iterate key-value pairs.
- normal
- Normal types.
- parse
- Parse various formats into normal types.
- path
- Path.
- resolve
- Resolve normal types into other types. A lot like TryFrom, except that:
- ser
serde - General-purpose serde serialization with enhanced support for normal types.
Macros§
- impl_
annotated - Helper macro for implementing Annotated.
- impl_
dyn_ annotated_ error - Helper macro for implementing DynAnnotatedError.
- impl_
normal - Helper macro for implementing normal types.
- impl_
normal_ basic - Helper macro for implementing normal types.
- impl_
resolve_ from_ str - Implement Resolve for a FromStr.
- normal
- Creates a Variant from a bare primitive expression.
- normal_
list - Creates a Variant::List from a sequence of bare primitive expressions.
- normal_
map - Creates a Variant::Map from a sequence of key-value tuples.
- normal_
vec - Creates a Vec<Variant> from a sequence of bare primitive expressions.
- traverse
- Traverse a variant by calling Variant::get recursively.
- traverse_
mut - Traverse a value by calling Variant::get_mut recursively.
- with_
annotations - Cast to a Variant with Annotations.
- without_
annotations - Cast to a Variant without Annotations.
Structs§
- Unknown
Format Error - $type.
Enums§
- Format
- CPS format.