Skip to main content

RelationRef

Struct RelationRef 

Source
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>

Source

pub fn new(field: Field<S, P, Many<T>>) -> Self

Source

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.

Source

pub fn count(&self) -> usize

The count, tracked like RelationRef::ids.

Source

pub fn is_empty(&self) -> bool

Source

pub fn contains(&self, id: impl Into<ModelId<T>>) -> bool

Tracked membership test.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

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>
where Field<S, P, Many<T>>: Freeze,

§

impl<S, P, T> Move for RelationRef<S, P, T>

§

impl<S, P, T> RefUnwindSafe for RelationRef<S, P, T>
where Field<S, P, Many<T>>: RefUnwindSafe,

§

impl<S, P, T> Send for RelationRef<S, P, T>
where Field<S, P, Many<T>>: Send,

§

impl<S, P, T> Sync for RelationRef<S, P, T>
where Field<S, P, Many<T>>: Sync,

§

impl<S, P, T> Unpin for RelationRef<S, P, T>
where Field<S, P, Many<T>>: Unpin,

§

impl<S, P, T> UnsafeUnpin for RelationRef<S, P, T>
where Field<S, P, Many<T>>: UnsafeUnpin,

§

impl<S, P, T> UnwindSafe for RelationRef<S, P, T>
where Field<S, P, Many<T>>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> IntoReactive<T, StaticMark> for T
where T: Clone + 'static,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.