pub trait ModelTree: OrderedModel<ParentId = <Self as Model>::Id> {
// Required method
fn move_to(
conn: &mut SqliteConnection,
id: &Self::Id,
parent_id: Option<&Self::Id>,
seq: Option<i32>,
) -> QueryResult<usize>;
// Provided methods
fn validate_destination(
conn: &mut SqliteConnection,
id: &Self::Id,
parent: &Self::Id,
) -> QueryResult<()> { ... }
fn move_all_to(
conn: &mut SqliteConnection,
ids: &[&Self::Id],
parent_id: &Self::Id,
start_seq: Option<i32>,
) -> QueryResult<usize> { ... }
}Expand description
Tree operations add ancestry validation to collection ordering.
Required Methods§
Sourcefn move_to(
conn: &mut SqliteConnection,
id: &Self::Id,
parent_id: Option<&Self::Id>,
seq: Option<i32>,
) -> QueryResult<usize>
fn move_to( conn: &mut SqliteConnection, id: &Self::Id, parent_id: Option<&Self::Id>, seq: Option<i32>, ) -> QueryResult<usize>
Move one item atomically; None keeps the parent or appends within the destination.
Provided Methods§
Sourcefn validate_destination(
conn: &mut SqliteConnection,
id: &Self::Id,
parent: &Self::Id,
) -> QueryResult<()>
fn validate_destination( conn: &mut SqliteConnection, id: &Self::Id, parent: &Self::Id, ) -> QueryResult<()>
Reject invalid folders, self-parenting, descendant targets and existing ancestry cycles.
Sourcefn move_all_to(
conn: &mut SqliteConnection,
ids: &[&Self::Id],
parent_id: &Self::Id,
start_seq: Option<i32>,
) -> QueryResult<usize>
fn move_all_to( conn: &mut SqliteConnection, ids: &[&Self::Id], parent_id: &Self::Id, start_seq: Option<i32>, ) -> QueryResult<usize>
Move distinct items as a block, preserving caller order. The start position is measured after removing selected destination members. Empty input is a no-op. The whole batch rolls back on failure, and unchanged rows retain their update metadata.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".