pub trait SequenceStore {
type ParentId: ?Sized + PartialEq + Debug;
const START_SEQ: i32 = 1;
Show 14 methods
// Required methods
fn is_valid_parent(
conn: &mut SqliteConnection,
parent: &Self::ParentId,
) -> QueryResult<bool>;
fn count_children(
conn: &mut SqliteConnection,
parent: &Self::ParentId,
) -> QueryResult<i32>;
fn get_seq_numbers(
conn: &mut SqliteConnection,
parent: &Self::ParentId,
) -> QueryResult<Vec<i32>>;
fn reset_seq(
conn: &mut SqliteConnection,
parent: &Self::ParentId,
) -> QueryResult<usize>;
fn shift_seq(
conn: &mut SqliteConnection,
parent: &Self::ParentId,
range: Range<i32>,
delta: i32,
) -> QueryResult<usize>;
// Provided methods
fn validate_seq_numbers(
conn: &mut SqliteConnection,
parent: &Self::ParentId,
) -> QueryResult<bool> { ... }
fn increment_seq_gte(
conn: &mut SqliteConnection,
parent: &Self::ParentId,
seq: i32,
) -> QueryResult<usize> { ... }
fn decrement_seq_gt(
conn: &mut SqliteConnection,
parent: &Self::ParentId,
seq: i32,
) -> QueryResult<usize> { ... }
fn increment_seq_gte_lt(
conn: &mut SqliteConnection,
parent: &Self::ParentId,
start: i32,
end: i32,
) -> QueryResult<usize> { ... }
fn decrement_seq_gt_lte(
conn: &mut SqliteConnection,
parent: &Self::ParentId,
start: i32,
end: i32,
) -> QueryResult<usize> { ... }
fn update_seq_before_insert(
conn: &mut SqliteConnection,
parent: &Self::ParentId,
seq: Option<i32>,
) -> QueryResult<(i32, usize)> { ... }
fn update_seq_before_move_to(
conn: &mut SqliteConnection,
old_parent: &Self::ParentId,
parent: &Self::ParentId,
old_seq: i32,
seq: Option<i32>,
) -> QueryResult<Option<(i32, usize)>> { ... }
fn update_seq_before_move_in(
conn: &mut SqliteConnection,
parent: &Self::ParentId,
old_seq: i32,
seq: Option<i32>,
) -> QueryResult<Option<(i32, usize)>> { ... }
fn update_seq_before_move(
conn: &mut SqliteConnection,
old_parent: &Self::ParentId,
parent: &Self::ParentId,
old_seq: i32,
seq: Option<i32>,
) -> QueryResult<Option<(i32, usize)>> { ... }
}Expand description
A database-backed ordered collection. A scope is a parent ID, playlist ID, or
() for a global filtered collection. Positions are contiguous from START_SEQ.
Mutating primitives must be called inside the transaction that changes the item. Membership filters must be identical for counting, reading, shifting and renumbering.
Provided Associated Constants§
Sourceconst START_SEQ: i32 = 1
const START_SEQ: i32 = 1
First stored position, dictated by the model and database format.
Master database collections conventionally start at one. OneLibrary uses zero for playlist/My Tag siblings (also adopted for history siblings), but one for playlist/history contents and visible browse settings. Implementations must select their own start; it cannot be inferred from the connection type.
Required Associated Types§
Required Methods§
Sourcefn is_valid_parent(
conn: &mut SqliteConnection,
parent: &Self::ParentId,
) -> QueryResult<bool>
fn is_valid_parent( conn: &mut SqliteConnection, parent: &Self::ParentId, ) -> QueryResult<bool>
Check collection existence and whether it accepts this kind of item.
Sourcefn count_children(
conn: &mut SqliteConnection,
parent: &Self::ParentId,
) -> QueryResult<i32>
fn count_children( conn: &mut SqliteConnection, parent: &Self::ParentId, ) -> QueryResult<i32>
Number of members of the collection.
Sourcefn get_seq_numbers(
conn: &mut SqliteConnection,
parent: &Self::ParentId,
) -> QueryResult<Vec<i32>>
fn get_seq_numbers( conn: &mut SqliteConnection, parent: &Self::ParentId, ) -> QueryResult<Vec<i32>>
Positions in ascending order.
Sourcefn reset_seq(
conn: &mut SqliteConnection,
parent: &Self::ParentId,
) -> QueryResult<usize>
fn reset_seq( conn: &mut SqliteConnection, parent: &Self::ParentId, ) -> QueryResult<usize>
Renumber by current position and stable item identity; only changed rows are written.
Sourcefn shift_seq(
conn: &mut SqliteConnection,
parent: &Self::ParentId,
range: Range<i32>,
delta: i32,
) -> QueryResult<usize>
fn shift_seq( conn: &mut SqliteConnection, parent: &Self::ParentId, range: Range<i32>, delta: i32, ) -> QueryResult<usize>
Shift members in a half-open range by delta, including backend update metadata.
Provided Methods§
Sourcefn validate_seq_numbers(
conn: &mut SqliteConnection,
parent: &Self::ParentId,
) -> QueryResult<bool>
fn validate_seq_numbers( conn: &mut SqliteConnection, parent: &Self::ParentId, ) -> QueryResult<bool>
Check for gaps, duplicates and incorrect starting positions.
Sourcefn increment_seq_gte(
conn: &mut SqliteConnection,
parent: &Self::ParentId,
seq: i32,
) -> QueryResult<usize>
fn increment_seq_gte( conn: &mut SqliteConnection, parent: &Self::ParentId, seq: i32, ) -> QueryResult<usize>
Open a slot before an insertion.
Sourcefn decrement_seq_gt(
conn: &mut SqliteConnection,
parent: &Self::ParentId,
seq: i32,
) -> QueryResult<usize>
fn decrement_seq_gt( conn: &mut SqliteConnection, parent: &Self::ParentId, seq: i32, ) -> QueryResult<usize>
Close a slot after a deletion or before moving an item to another collection.
Sourcefn increment_seq_gte_lt(
conn: &mut SqliteConnection,
parent: &Self::ParentId,
start: i32,
end: i32,
) -> QueryResult<usize>
fn increment_seq_gte_lt( conn: &mut SqliteConnection, parent: &Self::ParentId, start: i32, end: i32, ) -> QueryResult<usize>
Shift positions start <= position < end upwards.
Sourcefn decrement_seq_gt_lte(
conn: &mut SqliteConnection,
parent: &Self::ParentId,
start: i32,
end: i32,
) -> QueryResult<usize>
fn decrement_seq_gt_lte( conn: &mut SqliteConnection, parent: &Self::ParentId, start: i32, end: i32, ) -> QueryResult<usize>
Shift positions start < position <= end downwards.
Sourcefn update_seq_before_insert(
conn: &mut SqliteConnection,
parent: &Self::ParentId,
seq: Option<i32>,
) -> QueryResult<(i32, usize)>
fn update_seq_before_insert( conn: &mut SqliteConnection, parent: &Self::ParentId, seq: Option<i32>, ) -> QueryResult<(i32, usize)>
Validate an insertion and open its slot. None appends.
Sourcefn update_seq_before_move_to(
conn: &mut SqliteConnection,
old_parent: &Self::ParentId,
parent: &Self::ParentId,
old_seq: i32,
seq: Option<i32>,
) -> QueryResult<Option<(i32, usize)>>
fn update_seq_before_move_to( conn: &mut SqliteConnection, old_parent: &Self::ParentId, parent: &Self::ParentId, old_seq: i32, seq: Option<i32>, ) -> QueryResult<Option<(i32, usize)>>
Prepare a move between collections. The caller must update the item in the same transaction.
Sourcefn update_seq_before_move_in(
conn: &mut SqliteConnection,
parent: &Self::ParentId,
old_seq: i32,
seq: Option<i32>,
) -> QueryResult<Option<(i32, usize)>>
fn update_seq_before_move_in( conn: &mut SqliteConnection, parent: &Self::ParentId, old_seq: i32, seq: Option<i32>, ) -> QueryResult<Option<(i32, usize)>>
Prepare a move within a collection, interpreting the destination as its final position.
Sourcefn update_seq_before_move(
conn: &mut SqliteConnection,
old_parent: &Self::ParentId,
parent: &Self::ParentId,
old_seq: i32,
seq: Option<i32>,
) -> QueryResult<Option<(i32, usize)>>
fn update_seq_before_move( conn: &mut SqliteConnection, old_parent: &Self::ParentId, parent: &Self::ParentId, old_seq: i32, seq: Option<i32>, ) -> QueryResult<Option<(i32, usize)>>
Prepare a move within or between collections.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".