Expand description
§SwimOS Model
This model is a generic representation of the SwimOS serialization model. Any valid
serialized record can be deserialized as an instance of the Value
type in this
crate.
§The Value type
A SwimOS Value
can be of any one of the following kinds.
- An absent value (represented as
Value::Extant
). - A primitive value from the following set:
- Booleans, represented as
Value::BooleanValue
- Integers. When deserializing, an appropriate Rust integer type will be chosen, depending on this size of the integer.
- 64bit floating point numbers, represented as
Value::Float64Value
. - UTF-8 Strings, represented as
Value::Text
. - Arrays of bytes (represented as
Value::Data
).
- A record consisting of an list of attributes (
Attr
) and and list of items (Item
). This is represented asValue::Record
.
An attribute is a labelled (with a UTF-8 String) Value
.
An item is one of:
- A value item which is an instance of
Value
. This is represented asItem::ValueItem
. - A slot item which is a pair of two
Value
s, the first of which is interpreted as a key. This is represented asItem::Slot
.
Note that the attributes and items of a record are always ordered, although the order may not always be significant, for example if a record, consisting only of slots, is used to represent a map.
The record
and value
macros can be used to simplify the creation of Value
instances.
§Using the model
The use the model for serialization or deserialization, a format supporting the SwimOS model is required.
The default format used by SwimsOS is the Recon markup language, an example of which can be found in the
swimos_recon
crate.
Modules§
- identifier
- Functions to define an identifier for the SwimOS model.
- literal
- Functions to encode string literals.
Macros§
Structs§
- Attr
- An attribute that can be applied to a record
Value
. A key-value pair where the key is aString
and the value can be anyValue
. - BigInt
- A big signed integer type.
- BigUint
- A big unsigned integer type.
- Blob
- A Binary Large OBject (BLOB) structure for encoding and decoding base-64 data. A URL-safe encoding (UTF-7) is used.
- Text
- A container for a UTF-8 string that has a small string optimization for strings consisting of
SMALL_SIZE
bytes (allowing such strings to be held entirely within the object rather than requiring a separate allocation. This can be used in exactly the same way asString
in most circumstances. - Timestamp
- A structure representing the time that it was created.
Enums§
- Item
- An item that may occur in the body of record
Value
. - Value
- The core Swim model type. A recursive data type that can be represented in text as a Recon document.
- Value
Kind - The kinds of data that can be represented as a
Value
.
Traits§
- Reconstruct
From Value - Trait for types that can be reconstructed from
Value
s. - ToValue
- Trait for types that can be converted to
Value
s.