pub enum ActiveBelongsTo<T>where
T: BelongsToCardinality,{
NotSet,
Set(<T as BelongsToCardinality>::Set),
}Expand description
State carried by a belongs_to field on an
ActiveModelEx. Mirrors the
NotSet / Set shape of ActiveValue but for a
related model.
Unstable: nested-ActiveModel relation mutation is exempt from semver โ the
semantics of setting or removing related records may change in a minor (2.x) release.
Variantsยง
NotSet
Field is absent; the related model is left as-is on save.
Set(<T as BelongsToCardinality>::Set)
Set the related ActiveModel on save.
Implementationsยง
Sourceยงimpl<T> ActiveBelongsTo<T>where
T: BelongsToCardinality,
impl<T> ActiveBelongsTo<T>where
T: BelongsToCardinality,
Sourcepub fn set<M>(model: T::Value<M>) -> Self
pub fn set<M>(model: T::Value<M>) -> Self
Construct an ActiveBelongsTo::Set. Accepts a bare active model for a
required relation, or an Option<active model> for an optional one.
Sourcepub fn is_not_set(&self) -> bool
pub fn is_not_set(&self) -> bool
Return true if self is NotSet
Sourceยงimpl<E> ActiveBelongsTo<E>where
E: EntityTrait,
impl<E> ActiveBelongsTo<E>where
E: EntityTrait,
Sourcepub fn as_ref(&self) -> Option<&E::ActiveModelEx>
pub fn as_ref(&self) -> Option<&E::ActiveModelEx>
Get a reference, if set
Sourcepub fn as_mut(&mut self) -> Option<&mut E::ActiveModelEx>
pub fn as_mut(&mut self) -> Option<&mut E::ActiveModelEx>
Get a mutable reference, if set
Sourcepub fn is_changed(&self) -> bool
pub fn is_changed(&self) -> bool
Return true if the containing model is set and changed
Sourcepub fn into_option(self) -> Option<E::ActiveModelEx>
pub fn into_option(self) -> Option<E::ActiveModelEx>
Convert into an Option<ActiveModelEx>
Sourcepub fn try_into_model(self) -> Result<BelongsTo<E>, DbErr>
pub fn try_into_model(self) -> Result<BelongsTo<E>, DbErr>
Convert this back to a ModelEx container
Sourceยงimpl<E> ActiveBelongsTo<Option<E>>where
E: EntityTrait,
impl<E> ActiveBelongsTo<Option<E>>where
E: EntityTrait,
Sourcepub fn as_ref(&self) -> Option<&E::ActiveModelEx>
pub fn as_ref(&self) -> Option<&E::ActiveModelEx>
Get a reference, if set
Sourcepub fn as_mut(&mut self) -> Option<&mut E::ActiveModelEx>
pub fn as_mut(&mut self) -> Option<&mut E::ActiveModelEx>
Get a mutable reference, if set
Sourcepub fn is_changed(&self) -> bool
pub fn is_changed(&self) -> bool
Return true if the containing model is set and changed
Sourcepub fn into_option(self) -> Option<E::ActiveModelEx>
pub fn into_option(self) -> Option<E::ActiveModelEx>
Convert into an Option<ActiveModelEx>
Trait Implementationsยง
Sourceยงimpl<T> Clone for ActiveBelongsTo<T>where
T: BelongsToCardinality,
<T as BelongsToCardinality>::Set: Clone,
impl<T> Clone for ActiveBelongsTo<T>where
T: BelongsToCardinality,
<T as BelongsToCardinality>::Set: Clone,
Sourceยงimpl<T> Debug for ActiveBelongsTo<T>where
T: BelongsToCardinality,
<T as BelongsToCardinality>::Set: Debug,
impl<T> Debug for ActiveBelongsTo<T>where
T: BelongsToCardinality,
<T as BelongsToCardinality>::Set: Debug,
Sourceยงimpl<T> Default for ActiveBelongsTo<T>where
T: BelongsToCardinality,
impl<T> Default for ActiveBelongsTo<T>where
T: BelongsToCardinality,
Sourceยงfn default() -> ActiveBelongsTo<T>
fn default() -> ActiveBelongsTo<T>
impl<T> Eq for ActiveBelongsTo<T>where
T: BelongsToCardinality,
<T as BelongsToCardinality>::Set: Eq,
Auto Trait Implementationsยง
impl<T> Freeze for ActiveBelongsTo<T>where
<T as BelongsToCardinality>::Set: Freeze,
impl<T> RefUnwindSafe for ActiveBelongsTo<T>where
<T as BelongsToCardinality>::Set: RefUnwindSafe,
impl<T> Send for ActiveBelongsTo<T>where
<T as BelongsToCardinality>::Set: Send,
impl<T> Sync for ActiveBelongsTo<T>where
<T as BelongsToCardinality>::Set: Sync,
impl<T> Unpin for ActiveBelongsTo<T>where
<T as BelongsToCardinality>::Set: Unpin,
impl<T> UnsafeUnpin for ActiveBelongsTo<T>where
<T as BelongsToCardinality>::Set: UnsafeUnpin,
impl<T> UnwindSafe for ActiveBelongsTo<T>where
<T as BelongsToCardinality>::Set: UnwindSafe,
Blanket Implementationsยง
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Sourceยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Sourceยงimpl<T> Instrument for T
impl<T> Instrument for T
Sourceยงfn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Sourceยงfn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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