pub enum Field<T> {
Absent,
Null,
Value(T),
}Expand description
A key with three states: absent, null or a value.
Used for content and sentiment, whose presence depends on your plan and on include:
Field::Absent: the key was not in the JSON (not entitled, not requested, or raw).Field::Null: the key was there withnull(entitled and requested, but no value).Field::Value: the key carried a value.
When written back with serde, an absent field stays absent and null stays null.
Variants§
Absent
The key was not in the JSON.
Null
The key was in the JSON with null.
Value(T)
The key carried a value.
Implementations§
Source§impl<T> Field<T>
impl<T> Field<T>
Sourcepub fn is_present(&self) -> bool
pub fn is_present(&self) -> bool
true when the key was in the JSON, null included.
Sourcepub fn into_value(self) -> Option<T>
pub fn into_value(self) -> Option<T>
Converts into the value, or None when absent or null.
Trait Implementations§
Source§impl<'de, T: Deserialize<'de>> Deserialize<'de> for Field<T>
impl<'de, T: Deserialize<'de>> Deserialize<'de> for Field<T>
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
impl<T: Eq> Eq for Field<T>
impl<T: PartialEq> StructuralPartialEq for Field<T>
Auto Trait Implementations§
impl<T> Forget for Field<T>
impl<T> Freeze for Field<T>where
T: Freeze,
impl<T> Move for Field<T>
impl<T> RefUnwindSafe for Field<T>where
T: RefUnwindSafe,
impl<T> Send for Field<T>where
T: Send,
impl<T> Sync for Field<T>where
T: Sync,
impl<T> Unpin for Field<T>where
T: Unpin,
impl<T> UnsafeUnpin for Field<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Field<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