Skip to main content

Module table

Module table 

Source
Expand description

A model type’s storage contract as data.

What a record does with its fields — read them, write them, compare them, edit, check and describe them — is the same walk for every record, over each field’s own type. #[derive(Model)] describes a record as a table of its fields (ResourceDesc) and three small functions reaching into it (a field by position, the same mutably, and building one from its fields), and every Model operation of a record is one function here, compiled once into the runtime. A field’s type is reached through its ModelTable: the type’s Model functions with the type erased, built once per type, and for the types this crate defines, once.

Structs§

CheckReads
What a record’s own check reads: an edit that touches none of it cannot break the invariant, so the record is not read again to check it.
FieldDesc
One field of a record, as ResourceDesc lists it.
ItemOps
A collection type’s ItemSource functions, its type erased.
ItemOpsOf
The ItemOps of a collection type.
JsonDesc
A type stored whole through its serde form: as one JSON string, last writer winning (json_model!), or as that form’s maps, lists and scalars (value_model!).
JsonOf
The serde functions of a type stored as JSON text.
MapDesc
What the table of a map of string keys reaches into one with.
MapIn
The MapDesc of the map M of string keys to Ts: a BTreeMap<String, T> (MapOf) or a Map, stored alike.
ModelOps
A model type’s Model functions, its type erased. Each takes the table it was reached through, which for a record carries its ResourceDesc. A value is handed over as &dyn Any of the type; a value made is put into an &mut dyn Any of Option of the type.
ModelTable
A model type as data: its erased Model functions, what it is (a record’s fields), and what it holds (a collection’s items).
OptionDesc
What Option<T>’s table reaches into one with.
OptionOf
The OptionDesc of Option<T>.
OwnCheck
A record’s own invariant (#[model(check = path)]).
ResourceDesc
A record type as #[derive(Model)] describes it. See the module docs.
Run
A value of a type whose table does the work (Model::to_json of an Option, a Collection): the type’s functions as the table runs them.
TableOf
The table of T, from its own Model functions.
UnitDesc
A #[derive(Model)] enum of unit variants, each stored as its name.
ValueOf
The serde functions of a value_model! type, stored as its JSON form’s maps, lists and scalars.
VecDesc
What Vec<T>’s table reaches into one with.
VecOf
The VecDesc of Vec<T>.

Statics§

ATOM_STRING
The table of a String stored whole, last writer winning (#[model(atom)]): an id or a name two people setting at once must not interleave.
JSON_OPS
The functions of every type stored as JSON text.
MAP_OPS
The functions of every map of string keys: a map, one key per entry.
OPTION_OPS
The functions of every Option: None is an absent key (or a null list element).
RESOURCE_OPS
The functions of every record, over its ResourceDesc.
UNIT_OPS
The functions of every enum of unit variants.
VEC_OPS
The functions of every Vec: a list of values.

Traits§

Atomic
A type #[model(atom)] stores whole: one value, last writer wins, never merged part by part. A colour, a name from a list or an encoded path merged by character or element reads as no value at all.
FieldSource
Where a record being built takes its fields from, one after the other.
ListItems
A list’s items, whatever their type.
MapEntries
A map’s entries, whatever their value type.
PublishedItems
A collection whose items are published: its items’ type’s table.

Functions§

check
Model::check of a record: its own invariant, then its fields’.
collect_text
Model::collect_text of a record.
diff
Model::diff of a record: each field that is not read-only, at its key. A field that would store as it is (Model::stores_as) has nothing to submit and is passed over, compared in memory: no path made for it, nothing turned into JSON. The path of a field compared further is made once, in one buffer.
diff_into
Model::diff of a record into edits of the record E.
edit
Model::edit of a record.
edit_fields
Fields::edit_fields of a record: a field segment routes the edit to its field; a set of the record replaces it whole; the record’s own check runs after.
empty_of
An empty Option of T.
filled
The value a record function put into out.
for_view
Call read as a view’s reader reads: every #[model(demanded)] field it meets reads as its missing value, unread, until a view demands the item holding it and the resource’s load reads that item whole. A read outside it reads every field as stored.
from_json
Model::from_json of a record, put into out.
get_at
Model::get_at of a record.
holds_nested_items
Whether the record value (described by record) holds an item at the end of path: collection fields by their Rust names, the outer ones looked into item by item over their first published page, as a publication lists them.
item_collection_sizes
Fields::item_collection_sizes of a record.
item_collections
Fields::item_collections of a record: each collection field’s first page, then the collections inside their items.
item_fields
The collection fields of published items a model of the table table holds, by name: where an item’s id (<kind>/<field>/<item>) may stand, read from the table alone.
item_holds
Whether the collection field name holds the item id, counting one it keeps out because it no longer reads: the check an action makes before it resolves a reference, so one that already names the id costs a scan of the ids alone.
item_id_any
Whether reference is the id of an item of any of the record’s collections: an action that names one may hold it in a collection other than the one its parameter is named after (item_named).
item_json
What the published part of a record resource_id names holds, as its own model’s JSON ([Model::to_json]): the document read of an item of a collection, or of a field of one (an issue’s body), whatever their types, found in record (of the table table) by the steps <kind>/<field>/<item>, …/<field>/<item> for an item of a collection inside an item, and a last …/<field> for a field of the item reached.
item_label
Fields::item_label of a record.
item_named
Resolve reference to an item of the collection field name.
item_named_as
item_named in the words what names the items by — ("project or area", "projects and areas") where the field’s own name is not what the app calls them — the field’s words when it is None.
item_search
Fields::item_search of a record.
label
Model::label of a record: what its label = path names it, else the texts of its label fields joined by spaces, else its #[model(label)] field.
load
Model::load of a record, put into out.
missing
Model::missing of a record, put into out.
names_item
Whether resource_id names an item of a collection of published items in a record of the table table and kind kind, an item inside an item included, rather than a part of an item (an issue’s body, a channel’s call): what may be opened as an item.
op_coalesces
Model::op_coalesces of a record.
op_continuable
Model::op_continuable of a record.
op_describe
Model::op_describe of a record.
op_lands
Model::op_lands of a record.
op_schemas
Model::op_schemas of a record: only a field whose type has a vocabulary of its own is visited.
put
Put value into out, an Option of its type.
put_variant
Put variant into out, an Option of its enum.
read_fields
Fields::read_fields, put into out: every stored field read in one walk of the map.
reads_item
Whether resource_id names a part item_json reads in a record of the table table and kind kind: each step an item of a collection of published items, or a last field, of the record the step before reached. Decided from the tables alone, so offering the read costs no read.
reads_on_demand
Whether a value of table holds a #[model(demanded)] field anywhere (in its fields, their collections’ items, and theirs): whether what a view’s reader holds of it may be less than the document holds.
refresh
Model::refresh of a record.
refresh_fields
Fields::refresh_fields of a record: a map changed all over is read anew, else each touched field.
replace_of
Swap the T in filled, an Option of it, with target: filled then holds what target held, dropped with it.
resource_items
Every item the record table names holds, by the collection field holding it: the id and the label each item is offered under, in the order the collection keeps them. Nothing is left out: item_collections is the page a publication carries, which a record with thousands of items is not.
set_variant
Set target to variant.
store
Model::store of a record. One whose map is made now is made with every field that can be at once ([fresh_fields]): twenty fields are one batch, not twenty writes each looking up its key first.
store_changed
Model::store_changed of a record.
stores_as
Model::stores_as of a record.
take
The next field of source, a T.
take_or
The next field of source, a T, or what repair derives for it when the document holds none: a field declared #[model(default = ..)], so a record missing it (written by an older app, or half-made by an edit that raced its deletion) still reads, and the next whole write stores it.
to_json
Model::to_json of a record.
unit_schema
Model::value_schema of an enum of the variants names.
unwrap_of
The T in a filled Option of it.
whole
Call read reading every field as stored, inside a read for a view too: what a resource’s load reads of the items a view demands.
write_changed_fields
Fields::write_changed_fields of a record: each field written as write_key_changed writes it.
write_fields
Fields::write_fields of a record.

Type Aliases§

MapOf
The MapDesc of BTreeMap<String, T>.
ReadResource
Read a record, boxed, from the map it is stored in.