Expand description
Staquia creates positions: short strings that keep the order of a list.
Sort the items by their position string and you get the order back; moving an item only changes its own position, so only one row is written to the database per change. It is the Rust version of the staquia JavaScript library: for the same system and operations, both create the same positions.
The guides (how positions work, storing them in a database, error handling) are on the documentation site, which opens with every example in Rust.
Staquiais a number system that createsPositions.LexicalListkeeps the order of your values and their positions in sync.
Nothing panics: every operation that can fail returns a Result with an error enum
(PositionError, LexicalError) that works with ?.
§Example
use staquia::Staquia;
let system = Staquia::create('!', 'a', 'z', 5, 15, 0.15)?;
let first = system.start()?; // "mmmmm!"
let second = system.next(&first)?; // "mmmmn!"
let between = system.core(&first, &second)?; // "mmmmmn"
let mut positions = [second.to_string(), first.to_string(), between.to_string()];
positions.sort();
assert_eq!(positions, ["mmmmm!", "mmmmmn", "mmmmn!"]);Structs§
- Iter
- The items of a
LexicalListin their order, seeLexicalList::iter. - Lexical
Item - A value of a
LexicalListwith its position and the ids of its neighbors. - Lexical
List - A list that keeps the order of your values and their positions in sync, as a doubly linked list of ids.
- Options
- The configuration of a
Staquiasystem, forStaquia::create_with_options. - Position
- A position: a short string that keeps the order of a list.
- Rejected
- An operation of a
LexicalListthat took ownership of a value failed: the error and the value, given back unchanged. - Staquia
- A lexicographic number system that creates positions: short strings that keep the order of a list.
Enums§
- Create
Error - Why
Staquia::createrejected a configuration. - Direction
- The direction of
Staquia::nextandStaquia::previous, given byPositionError::EdgeReachedto tell which end ofNwas reached. - Error
- Any error of the crate, so every operation can use
?in the same function without boxing the errors.Kis the type of the ids of aLexicalList,()when no list is used. - Lexical
Error - Why an operation of a
LexicalListfailed.Kis the type of the ids, so the error tells which item caused it. - Position
Error - Why a position could not be created.
Constants§
- MAX_
LENGTH - The maximum length of a position (
ln + lz) of any system.
Traits§
- Item
- A value that can be stored in a
LexicalList: it has an id and a position.
Type Aliases§
- Replaced
- The result of the operations that change many positions of a
LexicalListat once (set,set_untrusted): the affected items (the rows to save), or the error with the values given back in aRejected.