Crate compris

Source
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.

What is CPS? It’s the implicit data schema underlying JSON and many other representation formats. It comprises primitive data types (numbers, booleans, strings, etc.) as well as list and map collection types. The collections allow for nested structure, hence it is “composite” (a.k.a. “algebraic”).

And yet despite being so widely used, it 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 comparitively 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 several 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§

cite
Citing the source.
deserde
General-purpose serde deserialization plus support for normal value types.
hints
Hints for extending representation formats (such as XJSON).
kv
Iterate key-value pairs.
merge
Merging.
meta
Metadata.
normal
Normal values.
parse
Parse various formats into normal value types.
path
Paths.
resolve
Resolve normal value types into other types. A lot like TryFrom, except that:
serserde
General-purpose serde serialization plus support for normal value types.
tag
Tags for Debuggable.

Macros§

impl_resolve_from_str
Implement Resolve for a FromStr.
normal
Creates a Value from a bare primitive expression.
normal_list
Creates a Value::List from a sequence of bare primitive expressions.
normal_map
Creates a Value::Map from a sequence of key-value tuples.
normal_vec
Creates a Vec<Value> from a sequence of bare primitive expressions.
traverse
Traverse a value by calling Value::get recursively.
traverse_mut
Traverse a value by calling Value::get_mut recursively.

Structs§

UnknownFormatError
$type.

Enums§

Format
CPS format.