pub enum UpdateNullable<T> {
Keep,
Unset,
Change(T),
}
Expand description
Clearer representation of an optional nullable field.
Requires #[serde(default, skip_serializing_if = "Update::is_keep")]
to be applied to
fields which use this type.
Variants§
Keep
Use the current value stored in the database. Equivalent of undefined
in JS.
Unset
Set the value to null
or the equivalent.
Change(T)
Use the given value.
Implementations§
Source§impl<T> UpdateNullable<T>
impl<T> UpdateNullable<T>
Sourcepub fn into_option(self) -> Option<T>
pub fn into_option(self) -> Option<T>
Similar to Option<Option<T>>::flatten()
, this converts the variant into an Option<T>
.
Useful for coalesce updates.
Trait Implementations§
Source§impl<T: Clone> Clone for UpdateNullable<T>
impl<T: Clone> Clone for UpdateNullable<T>
Source§fn clone(&self) -> UpdateNullable<T>
fn clone(&self) -> UpdateNullable<T>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T: Debug> Debug for UpdateNullable<T>
impl<T: Debug> Debug for UpdateNullable<T>
Source§impl<T> Default for UpdateNullable<T>
impl<T> Default for UpdateNullable<T>
Source§fn default() -> UpdateNullable<T>
fn default() -> UpdateNullable<T>
Returns the “default value” for a type. Read more
Source§impl<'de, T> Deserialize<'de> for UpdateNullable<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for UpdateNullable<T>where
T: Deserialize<'de>,
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T> From<Option<T>> for UpdateNullable<T>
impl<T> From<Option<T>> for UpdateNullable<T>
Auto Trait Implementations§
impl<T> Freeze for UpdateNullable<T>where
T: Freeze,
impl<T> RefUnwindSafe for UpdateNullable<T>where
T: RefUnwindSafe,
impl<T> Send for UpdateNullable<T>where
T: Send,
impl<T> Sync for UpdateNullable<T>where
T: Sync,
impl<T> Unpin for UpdateNullable<T>where
T: Unpin,
impl<T> UnwindSafe for UpdateNullable<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