pub enum Patch<T> {
Keep,
Set(T),
Clear,
}Expand description
Three-way patch value for nullable JMAP fields.
Keep(default): the field is omitted from the patch — server leaves it unchanged.Set(v): the field is included with valuev.Clear: the field is included as JSONnull(clears the server-side value).
Use Patch::from(v) to construct Set(v). Use Default::default() or
Patch::Keep to leave the field unchanged. Use Patch::Clear to set a
nullable field to null explicitly.
§Serde usage
Fields of type Patch<T> must carry both attributes:
ⓘ
#[serde(default, skip_serializing_if = "Patch::is_keep")]
pub my_field: Patch<String>,default: absent JSON key →Patch::Keep(no change).skip_serializing_if: omits the key from the output when the value isKeep.
Without skip_serializing_if, Patch::Keep serializes as a runtime error.
§Deserialization
Patch::Keep is not reachable from JSON deserialization. The custom
Deserialize impl maps JSON null → Clear and a JSON value → Set(v).
An absent key (via #[serde(default)]) produces Keep via Default.
Variants§
Keep
Omit the field from the patch — server leaves it unchanged.
Set(T)
Include the field with value T.
Clear
Include the field as JSON null (clears the server-side value).
Implementations§
Trait Implementations§
Source§impl<'de, T: Deserialize<'de>> Deserialize<'de> for Patch<T>
impl<'de, T: Deserialize<'de>> Deserialize<'de> for Patch<T>
Source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
impl<T> StructuralPartialEq for Patch<T>
Auto Trait Implementations§
impl<T> Freeze for Patch<T>where
T: Freeze,
impl<T> RefUnwindSafe for Patch<T>where
T: RefUnwindSafe,
impl<T> Send for Patch<T>where
T: Send,
impl<T> Sync for Patch<T>where
T: Sync,
impl<T> Unpin for Patch<T>where
T: Unpin,
impl<T> UnsafeUnpin for Patch<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Patch<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