pub enum Patch<T> {
Missing,
Null,
Value(T),
}Expand description
A field of a merge patch that may also be cleared: absent from the patch,
set to null, or given a value.
With the serde feature, it deserializes null as Patch::Null and a
value as Patch::Value; an absent field takes the default,
Patch::Missing, so put #[serde(default)] on the struct (or the
field). To document it with utoipa, give the field
#[schema(value_type = Option<T>)]: a nullable T, as clients send it.
Variants§
Missing
Absent from the patch: the field is left unchanged.
Null
Set to null: the field is cleared.
Value(T)
Given a value: the field is replaced.
Implementations§
Trait Implementations§
impl<T> Copy for Patch<T>where
T: Copy,
Source§impl<'de, T> Deserialize<'de> for Patch<T>where
T: Deserialize<'de>,
null is Patch::Null, a value Patch::Value; an absent field is
the default, Patch::Missing, through #[serde(default)].
impl<'de, T> Deserialize<'de> for Patch<T>where
T: Deserialize<'de>,
null is Patch::Null, a value Patch::Value; an absent field is
the default, Patch::Missing, through #[serde(default)].
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Patch<T>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Patch<T>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
impl<T> Eq for Patch<T>where
T: Eq,
Source§impl<T> JsonSchema for Patch<T>where
T: JsonSchema,
Documented as a nullable T, as clients send it: an absent field is
not in the request at all.
impl<T> JsonSchema for Patch<T>where
T: JsonSchema,
Documented as a nullable T, as clients send it: an absent field is
not in the request at all.
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§impl<T> Serialize for Patch<T>where
T: Serialize,
A value as itself, null (and an absent field, which a struct skips
with #[serde(skip_serializing_if = "Patch::is_missing")]) as null.
impl<T> Serialize for Patch<T>where
T: Serialize,
A value as itself, null (and an absent field, which a struct skips
with #[serde(skip_serializing_if = "Patch::is_missing")]) as null.
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl<T> StructuralPartialEq for Patch<T>where
T: PartialEq,
Source§impl<T> ValidateRange<T> for Patch<T>where
T: ValidateRange<T>,
validator’s range rule checks a given value, and passes an absent
field or a null (which ValidateNonNullable checks), as it does an
Option.
Delegates to the value’s own check, so every type validator ranges
over works.
impl<T> ValidateRange<T> for Patch<T>where
T: ValidateRange<T>,
validator’s range rule checks a given value, and passes an absent
field or a null (which ValidateNonNullable checks), as it does an
Option.
Delegates to the value’s own check, so every type validator ranges
over works.
Auto Trait Implementations§
impl<T> Forget for Patch<T>
impl<T> Freeze for Patch<T>where
T: Freeze,
impl<T> Move for Patch<T>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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
key and return true if they are equal.