pub struct RelationRef<S: Copy + 'static, P: 'static, T: 'static> { /* private fields */ }Expand description
What the generated accessor for a Many field returns: the relation, addressed from one
parent. Reads are tracked through the parent’s field path (membership changes wake
exactly the readers of this parent’s relation), and writes go through the children’s
foreign keys, where membership is stored.
Implementations§
Source§impl<S: Source<P>, P: 'static, T: 'static> RelationRef<S, P, T>
impl<S: Source<P>, P: 'static, T: 'static> RelationRef<S, P, T>
pub fn new(field: Field<S, P, Many<T>>) -> Self
Sourcepub fn ids(&self) -> Vec<ModelId<T>>
pub fn ids(&self) -> Vec<ModelId<T>>
The children’s ids, in relation order, tracked: the caller re-runs when membership (or order) changes, and not when a child’s other fields do.
Sourcepub fn count(&self) -> usize
pub fn count(&self) -> usize
The count, tracked like RelationRef::ids.
pub fn is_empty(&self) -> bool
Sourcepub fn add(&self, child: impl Into<ModelId<T>>) -> bool
pub fn add(&self, child: impl Into<ModelId<T>>) -> bool
Take child into this relation by writing its foreign key (reparenting it away from
any previous parent, whose readers wake too). On an ordered relation the child lands
last, its order field written past the current end. Returns false when the relation
is unwired or the child is gone.
Sourcepub fn insert_at(&self, child: impl Into<ModelId<T>>, index: usize) -> bool
pub fn insert_at(&self, child: impl Into<ModelId<T>>, index: usize) -> bool
Ordered relations: place child at index among the current children, normally one
write of the child’s order field (fractional keying), plus the adopt when it was not
yet this parent’s. When the gap between neighbors has bisected away, the siblings
rebalance to whole numbers first (O(n), rare, and every write still takes the front
door). Returns false on an unordered or unwired relation.
Sourcepub fn move_to(&self, child: impl Into<ModelId<T>>, index: usize) -> bool
pub fn move_to(&self, child: impl Into<ModelId<T>>, index: usize) -> bool
Move an existing child to index: RelationRef::insert_at, reading as intent.
Sourcepub fn remove(&self, child: impl Into<ModelId<T>>) -> bool
pub fn remove(&self, child: impl Into<ModelId<T>>) -> bool
Clear child’s reference; it leaves this relation and belongs to no parent. On a
required (One<…>, non-Option) inverse the cleared reference is a constraint
violation at flush: reparent or delete the child instead.
Sourcepub fn clear(&self)
pub fn clear(&self)
RelationRef::remove for every current child.
Trait Implementations§
Source§impl<S: Copy + 'static, P: 'static, T: 'static> Clone for RelationRef<S, P, T>
impl<S: Copy + 'static, P: 'static, T: 'static> Clone for RelationRef<S, P, T>
impl<S: Copy + 'static, P: 'static, T: 'static> Copy for RelationRef<S, P, T>
Auto Trait Implementations§
impl<S, P, T> Forget for RelationRef<S, P, T>
impl<S, P, T> Freeze for RelationRef<S, P, T>
impl<S, P, T> RefUnwindSafe for RelationRef<S, P, T>
impl<S, P, T> Send for RelationRef<S, P, T>
impl<S, P, T> Sync for RelationRef<S, P, T>
impl<S, P, T> Unpin for RelationRef<S, P, T>
impl<S, P, T> UnsafeUnpin for RelationRef<S, P, T>
impl<S, P, T> UnwindSafe for RelationRef<S, P, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more