Skip to main content

Module table

Module table 

Source
Expand description

Typed tables a provider reads and writes through, whatever keeps them.

A Table is the source of a provider’s records: a MemoryTable built in code, a file with a codec, a SQL database or an HTTP API are all tables, and the provider cannot tell them apart. Reloading caches the latest Snapshot and refreshes it through Table::changes_since.

Structs§

MemoryTable
A table kept in memory, built in code. It is writable and its revision counts the changes made to it.
Reloading
A table with its latest Snapshot cached, refreshed through Table::changes_since on every use, so a write by anyone else is seen without reopening.
Revision
Which state of a table a Snapshot is: opaque, compared only for equality, and chosen by the table. 0 is what a table that never changes may use for ever.
Snapshot
All the records of a table at one Revision, in the table’s order.

Enums§

SourceError
Why a table could not answer. Messages never contain record contents or secrets.

Traits§

Keyed
A record a table can find again by name.
Table
Where a provider’s records of type T come from, and optionally go to.

Functions§

check_field
Whether value may be a record’s field: not empty, at most max_bytes long, and free of control characters (which would let a field forge a line in a log or a file).
check_keys
Checks that no key is used twice and that there are at most max records. A provider’s own validation calls this first.
unix_now
Now, in whole seconds since the Unix epoch, as records stamp made_unix and compare expires_unix; 0 on a clock set before 1970.

Type Aliases§

Update
What Table::update is given to decide a change: the records read, and the record to put, if any.
UpdateOne
What Table::update_one is given to decide a change to one record: that record as the table holds it (None when there is none), and the record to put, if any.