pub enum ActiveValue<T> {
Set(T),
Unchanged(T),
NotSet,
}Expand description
The state of one attribute of an active model.
Variants§
Set(T)
A new value that will be written on the next insert or update.
Unchanged(T)
The value currently stored; it is read back but never written.
NotSet
No value; the database default applies on insert.
Implementations§
Source§impl<T> ActiveValue<T>
impl<T> ActiveValue<T>
Sourcepub fn is_unchanged(&self) -> bool
pub fn is_unchanged(&self) -> bool
Whether the attribute is Unchanged.
Sourcepub fn is_not_set(&self) -> bool
pub fn is_not_set(&self) -> bool
Whether the attribute is NotSet.
Sourcepub fn into_value(self) -> Option<T>
pub fn into_value(self) -> Option<T>
Consumes the attribute and returns its value, whether Set or Unchanged.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Marks the attribute Unchanged, keeping its value; used after a successful write.
Sourcepub fn map<U>(self, f: impl FnOnce(T) -> U) -> ActiveValue<U>
pub fn map<U>(self, f: impl FnOnce(T) -> U) -> ActiveValue<U>
Maps the inner value, preserving the attribute state.
Source§impl<T: PartialEq> ActiveValue<T>
impl<T: PartialEq> ActiveValue<T>
Sourcepub fn set_if_not_equals(&mut self, value: T)
pub fn set_if_not_equals(&mut self, value: T)
Sets value unless it equals the current Unchanged value, in which
case the attribute stays Unchanged and is not written back.
Trait Implementations§
Source§impl<T: Clone> Clone for ActiveValue<T>
impl<T: Clone> Clone for ActiveValue<T>
Source§impl<T: Debug> Debug for ActiveValue<T>
impl<T: Debug> Debug for ActiveValue<T>
Source§impl<T> Default for ActiveValue<T>
impl<T> Default for ActiveValue<T>
impl<T: Eq> Eq for ActiveValue<T>
Source§impl<T> From<T> for ActiveValue<T>
impl<T> From<T> for ActiveValue<T>
Source§impl<T: PartialEq> PartialEq for ActiveValue<T>
impl<T: PartialEq> PartialEq for ActiveValue<T>
impl<T: PartialEq> StructuralPartialEq for ActiveValue<T>
Auto Trait Implementations§
impl<T> Freeze for ActiveValue<T>where
T: Freeze,
impl<T> RefUnwindSafe for ActiveValue<T>where
T: RefUnwindSafe,
impl<T> Send for ActiveValue<T>where
T: Send,
impl<T> Sync for ActiveValue<T>where
T: Sync,
impl<T> Unpin for ActiveValue<T>where
T: Unpin,
impl<T> UnsafeUnpin for ActiveValue<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for ActiveValue<T>where
T: UnwindSafe,
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
Mutably borrows from an owned value. Read more
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<K, Q> Equivalent<Q> for K
impl<K, Q> Equivalent<Q> for K
Source§fn equivalent(&self, key: &Q) -> bool
fn equivalent(&self, key: &Q) -> bool
Compare self to
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
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> ⓘ
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 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> ⓘ
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