pub enum FieldUpdate<T> {
Keep,
Set(T),
Clear,
}Expand description
Tri-state field for UpdateEnvironmentPayload: callers can keep the
existing value, set a new one, or clear an optional field back to None.
Keep maps to the prior None behavior (no change). Set(v) maps to
the prior Some(v). Clear writes None into the persisted field,
which a plain Option<T> patch shape could not express.
§Wire format
Serde mirrors the A8 wire encoding established by the PR-3b client:
Set(v) is {"value": v}, Clear is {"clear": true}, and Keep is
the absent field (every payload field carries
#[serde(default, skip_serializing_if = "FieldUpdate::is_keep")]).
A present-but-{"clear": false} value deserializes to Keep — the
caller said “don’t clear” and named no new value.
Deserialization is strict: a body carrying both value and clear
keys is rejected (contradictory patch intent), and unknown keys are
rejected via deny_unknown_fields. {"value": null} is treated as
absent for T that deserializes from null.
Variants§
Keep
Leave the existing value unchanged (the prior None behavior).
Set(T)
Write a new value.
Clear
Clear an optional field back to None. Only valid for fields that
are Option<T> on the persisted struct.
Implementations§
Source§impl<T> FieldUpdate<T>
impl<T> FieldUpdate<T>
Sourcepub fn from_option(opt: Option<T>) -> Self
pub fn from_option(opt: Option<T>) -> Self
Convert from Option<T> (backward-compat): None → Keep,
Some(v) → Set(v). Existing callers that pass bare None keep
the prior semantics with no code change beyond wrapping.
Sourcepub fn from_double_option(opt: Option<Option<T>>) -> Self
pub fn from_double_option(opt: Option<Option<T>>) -> Self
Convert from Option<Option<T>> (JSON tri-state): outer None →
Keep, Some(None) → Clear, Some(Some(v)) → Set(v).
Trait Implementations§
Source§impl<T: Clone> Clone for FieldUpdate<T>
impl<T: Clone> Clone for FieldUpdate<T>
Source§fn clone(&self) -> FieldUpdate<T>
fn clone(&self) -> FieldUpdate<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T: Debug> Debug for FieldUpdate<T>
impl<T: Debug> Debug for FieldUpdate<T>
Source§impl<T> Default for FieldUpdate<T>
impl<T> Default for FieldUpdate<T>
Source§fn default() -> FieldUpdate<T>
fn default() -> FieldUpdate<T>
Source§impl<'de, T: Deserialize<'de>> Deserialize<'de> for FieldUpdate<T>
impl<'de, T: Deserialize<'de>> Deserialize<'de> for FieldUpdate<T>
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
impl<T: Eq> Eq for FieldUpdate<T>
Source§impl<T: PartialEq> PartialEq for FieldUpdate<T>
impl<T: PartialEq> PartialEq for FieldUpdate<T>
Source§fn eq(&self, other: &FieldUpdate<T>) -> bool
fn eq(&self, other: &FieldUpdate<T>) -> bool
self and other values to be equal, and is used by ==.Source§impl<T: Serialize> Serialize for FieldUpdate<T>
impl<T: Serialize> Serialize for FieldUpdate<T>
impl<T: PartialEq> StructuralPartialEq for FieldUpdate<T>
Auto Trait Implementations§
impl<T> Freeze for FieldUpdate<T>where
T: Freeze,
impl<T> RefUnwindSafe for FieldUpdate<T>where
T: RefUnwindSafe,
impl<T> Send for FieldUpdate<T>where
T: Send,
impl<T> Sync for FieldUpdate<T>where
T: Sync,
impl<T> Unpin for FieldUpdate<T>where
T: Unpin,
impl<T> UnsafeUnpin for FieldUpdate<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for FieldUpdate<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
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,
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.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request