pub struct ValueDict {
pub map: BTreeMap<SmolStr, Value>,
pub brand: Option<String>,
pub variant_of: Option<String>,
}Fields§
§map: BTreeMap<SmolStr, Value>P2-17: dict keys land in a SmolStr so ≤ 22-byte field names
(the overwhelming majority — see corpus telemetry) ride the
inline slot and skip the per-key String allocation. SmolStr
implements Borrow<str> so existing .get(&str) /
.contains_key(&str) callsites keep working unchanged.
brand: Option<String>§variant_of: Option<String>Name of the parent sum-type Enum when this dict is a tagged-enum
variant. Some("Notification") distinguishes a Notification.Email
payload from a plain #schema Email { ... } value (both have
brand = Some("Email")); the JSON serializer uses it to wrap the
payload as { Email: { ... } } only for the variant case.
Implementations§
Source§impl ValueDict
impl ValueDict
Sourcepub fn new<K, I>(map: I) -> Self
pub fn new<K, I>(map: I) -> Self
Build a ValueDict from any iterable of key/value pairs. Accepts
both SmolStr (zero-cost) and String (consumed and SSO’d via
SmolStr::from) keys; see Value::dict for the wider
constructor.
Sourcepub fn with_brand<K, I>(map: I, brand: Option<String>) -> Self
pub fn with_brand<K, I>(map: I, brand: Option<String>) -> Self
Build a branded ValueDict. See ValueDict::new for the
key-type contract.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ValueDict
impl<'de> Deserialize<'de> for ValueDict
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>,
Auto Trait Implementations§
impl Freeze for ValueDict
impl RefUnwindSafe for ValueDict
impl Send for ValueDict
impl Sync for ValueDict
impl Unpin for ValueDict
impl UnsafeUnpin for ValueDict
impl UnwindSafe for ValueDict
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<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