pub struct NestedOpt<T>(pub Option<T>);Expand description
A Daml Optional nested inside another Optional. Same runtime meaning
as Option, but its LF-JSON encoding is the nested-optional list form
(None → [], Some(x) → [x]) instead of null/value.
The Daml-LF JSON spec keeps the top-level Optional as null/value, and uses
the list form for an Optional directly inside another, so Some None
(encoded []) is distinguishable from None (encoded null).
“Directly” is the whole rule: nesting resets as soon as anything else
intervenes. In Optional (List (Optional Text)) the inner Optional is a
plain null/value again, because the List broke the chain — the same for
a TextMap, a GenMap, or a record field. Only Optional (Optional a)
puts the inner one in list form. Codegen applies exactly that rule
(map.rs recurses through Optional and nothing else), so wrap a layer in
NestedOpt only where its parent is itself an Optional.
The gRPC (Value) encoding is identical to Option (a proto Optional),
so only the JSON form differs.
Tuple Fields§
§0: Option<T>Implementations§
Trait Implementations§
Source§impl<'de, T: Deserialize<'de>> Deserialize<'de> for NestedOpt<T>
impl<'de, T: Deserialize<'de>> Deserialize<'de> for NestedOpt<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 NestedOpt<T>
Source§impl<T: FromValue> FromValue for NestedOpt<T>
impl<T: FromValue> FromValue for NestedOpt<T>
Source§fn from_value(value: &Value) -> Result<Self, ValueError>
fn from_value(value: &Value) -> Result<Self, ValueError>
impl<T: PartialEq> StructuralPartialEq for NestedOpt<T>
Auto Trait Implementations§
impl<T> Freeze for NestedOpt<T>
impl<T> RefUnwindSafe for NestedOpt<T>where
Option<T>: RefUnwindSafe,
impl<T> Send for NestedOpt<T>
impl<T> Sync for NestedOpt<T>
impl<T> Unpin for NestedOpt<T>
impl<T> UnsafeUnpin for NestedOpt<T>where
Option<T>: UnsafeUnpin,
impl<T> UnwindSafe for NestedOpt<T>where
Option<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.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