pub struct AdditionalParams(/* private fields */);Expand description
Provider extras on a content block: a non-empty JSON object, by construction.
The serialized form is the bare object (#[serde(transparent)]), so the
wire shape of an additional_params field is a named key carrying an
object — never flattened into the block’s own key namespace. The type
carries the whole params contract, so no call-site convention is needed:
Some(AdditionalParams)always carries data. The constructors collapse an empty map toNoneand the inner map is private, so emptiness checks on a params field are a plainis_none()/is_some()— no tolerant shim, in-tree or out.- A non-object params value is unrepresentable in memory, so serialization can never emit a value deserialization rejects: what a live run writes, a restored run loads.
- On decode,
nulland{}canonicalize to an absent field (seeoptional_additional_params) and any other non-object value is a loud error.
The block structs themselves follow the complementary tolerance doctrine: a known field with the wrong shape is a loud decode error, an unknown key on a block is ignored (never captured, never replayed), and an unknown content-block tag is a loud error. The params are provider-specific: a serializer replays only params it recognizes as its own wire’s.
Implementations§
Source§impl AdditionalParams
impl AdditionalParams
Sourcepub fn new(map: Map<String, Value>) -> Option<Self>
pub fn new(map: Map<String, Value>) -> Option<Self>
The canonical constructor: None when the map is empty.
Sourcepub fn from_entries<K, I>(entries: I) -> Option<Self>
pub fn from_entries<K, I>(entries: I) -> Option<Self>
Build from (key, value) entries; None when the iterator yields
none. Option<(K, Value)> is such an iterator, so a conditional
single-key params reads as
AdditionalParams::from_entries(guard.then(|| (key, value))).
Sourcepub fn into_value(self) -> Value
pub fn into_value(self) -> Value
The params as a bare JSON object value.
Sourcepub fn merge(&mut self, incoming: Self)
pub fn merge(&mut self, incoming: Self)
Deep-merge incoming into self: arrays concatenate (streamed
citation deltas), objects merge recursively, scalars take the
incoming value.
Sourcepub fn wire_extras(&self, wire_key: &str) -> Option<&Map<String, Value>>
pub fn wire_extras(&self, wire_key: &str) -> Option<&Map<String, Value>>
The extras stored under a wire’s own key, when present — the
replay-side gate: a serializer asks for its key and never sees
another wire’s extras (capture is unconditional at ingest; replay is
gated here). A non-object value under the key yields None (it is
not that wire’s extras); a caller that must distinguish malformed
from absent — a warn path — pairs this with Self::get. Never a
hard error: extras were written by a previous turn, and failing
serialization over them would turn a persistence blemish into a
broken conversation.
Sourcepub fn into_wire_extras(self, wire_key: &str) -> Option<Map<String, Value>>
pub fn into_wire_extras(self, wire_key: &str) -> Option<Map<String, Value>>
Owned counterpart of Self::wire_extras for serialization paths
that already own the params (the common replay case): extracts the
wire’s object without cloning. Same gate semantics.
Sourcepub fn try_from_value(value: Value) -> Result<Option<Self>, Value>
pub fn try_from_value(value: Value) -> Result<Option<Self>, Value>
Build from a JSON value: Ok(None) for null and the empty object
(canonical absence), Ok(Some) for a non-empty object, and Err
handing the value back otherwise — a non-object is never silently
swallowed; the caller decides loud versus lossy.
Trait Implementations§
Source§impl Clone for AdditionalParams
impl Clone for AdditionalParams
Source§fn clone(&self) -> AdditionalParams
fn clone(&self) -> AdditionalParams
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AdditionalParams
impl Debug for AdditionalParams
Source§impl<'de> Deserialize<'de> for AdditionalParams
impl<'de> Deserialize<'de> for AdditionalParams
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl From<AdditionalParams> for Value
impl From<AdditionalParams> for Value
Source§fn from(params: AdditionalParams) -> Self
fn from(params: AdditionalParams) -> Self
Source§impl Index<&str> for AdditionalParams
impl Index<&str> for AdditionalParams
Source§impl PartialEq for AdditionalParams
impl PartialEq for AdditionalParams
Source§impl Serialize for AdditionalParams
impl Serialize for AdditionalParams
impl StructuralPartialEq for AdditionalParams
Auto Trait Implementations§
impl Freeze for AdditionalParams
impl RefUnwindSafe for AdditionalParams
impl Send for AdditionalParams
impl Sync for AdditionalParams
impl Unpin for AdditionalParams
impl UnsafeUnpin for AdditionalParams
impl UnwindSafe for AdditionalParams
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<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> 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more