pub struct Object(pub VecMap<Strand, Value>);Expand description
Invariant: Keys never contain NUL bytes.
- Rev 1 —
u16 revision || VecMap<Strand, Value>(length-prefixed sorted entries). Byte-identical to the legacy on-disk encoding. - Rev 2 — optimised envelope (
u16 revision || u32_le payload_length), innerVecMapwritten via the indexed-map prologue pastOFFSET_TABLE_MIN_LEN = 8. Walker descent stays zero-allocation:walk_field_0()on aWire-repr parent borrows the field bytes directly by bracketingskip_indexed_mapwithBorrowedReader::remaining()snapshots, no decode + re-encode required.
Tuple Fields§
§0: VecMap<Strand, Value>Implementations§
Source§impl Object
impl Object
Sourcepub fn walk_revisioned_field_names(
wire_revision: u16,
) -> &'static [&'static str]
pub fn walk_revisioned_field_names( wire_revision: u16, ) -> &'static [&'static str]
Field names at the given wire revision in declaration order.
Returns an empty slice if the revision is unknown. Generated
by the revisioned derive.
Source§impl Object
impl Object
Sourcepub fn insert(&mut self, key: impl Into<Strand>, value: Value) -> Option<Value>
pub fn insert(&mut self, key: impl Into<Strand>, value: Value) -> Option<Value>
Insert a key-value pair into the object.
The key is accepted as anything convertible to Strand
(including String, &str, and Strand), which keeps call
sites ergonomic.
Sourcepub fn get(&self, key: &str) -> Option<&Value>
pub fn get(&self, key: &str) -> Option<&Value>
Look up a value by key.
Takes &str, so &String callers work transparently via deref
coercion — avoiding the Borrow<String> trait bound that would
otherwise be required on Strand.
Sourcepub fn get_mut(&mut self, key: &str) -> Option<&mut Value>
pub fn get_mut(&mut self, key: &str) -> Option<&mut Value>
Look up a value by key for mutation.
Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Check whether the object contains a given key.
Sourcepub fn entry(
&mut self,
key: impl Into<Strand>,
) -> VecMapEntry<'_, Strand, Value>
pub fn entry( &mut self, key: impl Into<Strand>, ) -> VecMapEntry<'_, Strand, Value>
Return the map entry for key, so callers can use the
Entry API without manual interning.
pub fn into_literal(self) -> Vec<ObjectEntry>
Methods from Deref<Target = VecMap<Strand, Value>>§
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn clear(&mut self)
pub fn get<Q>(&self, key: &Q) -> Option<&V>
pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
pub fn contains_key<Q>(&self, key: &Q) -> bool
pub fn insert(&mut self, key: K, value: V) -> Option<V>where
K: Ord,
pub fn remove<Q>(&mut self, key: &Q) -> Option<V>
pub fn retain<F>(&mut self, f: F)
Sourcepub fn append(&mut self, other: &mut VecMap<K, V>)where
K: Ord,
pub fn append(&mut self, other: &mut VecMap<K, V>)where
K: Ord,
Moves all elements from other into self, leaving other empty.
This matches BTreeMap::append: both maps must already be sorted by key with no
duplicates within each map. If the same key appears in both, the value from other
replaces the value in self (the key slot from self is dropped, as with
BTreeMap::insert).
Sourcepub fn push(&mut self, key: K, value: V)where
K: Ord,
pub fn push(&mut self, key: K, value: V)where
K: Ord,
Appends (key, value) in O(1) amortized time without searching.
§Ordering
key must be strictly greater than every existing key (or the map
must be empty). Violating this breaks sorted-map invariants; it is checked
with debug_assert! only (see append).
pub fn iter(&self) -> Iter<'_, K, V>
pub fn iter_mut(&mut self) -> IterMut<'_, K, V>
pub fn keys(&self) -> impl Iterator<Item = &K>
pub fn values(&self) -> impl Iterator<Item = &V>
pub fn values_mut(&mut self) -> impl Iterator<Item = &mut V>
pub fn first_key_value(&self) -> Option<(&K, &V)>
pub fn last_key_value(&self) -> Option<(&K, &V)>
pub fn entry(&mut self, key: K) -> Entry<'_, K, V>where
K: Ord,
Trait Implementations§
Source§impl<'de> BorrowDecode<'de, IndexFormat> for Object
impl<'de> BorrowDecode<'de, IndexFormat> for Object
fn borrow_decode(_r: &mut BorrowReader<'de>) -> Result<Self, DecodeError>
Source§impl<'de> BorrowDecode<'de> for Object
impl<'de> BorrowDecode<'de> for Object
fn borrow_decode(_r: &mut BorrowReader<'de>) -> Result<Self, DecodeError>
Source§impl DeserializeRevisioned for Object
impl DeserializeRevisioned for Object
Source§impl Encode<IndexFormat> for Object
impl Encode<IndexFormat> for Object
impl Eq for Object
Source§impl From<Object> for Object
impl From<Object> for Object
Source§fn from(s: PublicObject) -> Self
fn from(s: PublicObject) -> Self
Source§impl From<Object> for RecordIdKey
impl From<Object> for RecordIdKey
Source§impl IntoIterator for Object
impl IntoIterator for Object
Source§impl Ord for Object
impl Ord for Object
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Object
impl PartialOrd for Object
Source§impl Revisioned for Object
impl Revisioned for Object
Source§impl SerializeRevisioned for Object
impl SerializeRevisioned for Object
Source§impl SkipCheckRevisioned for Object
impl SkipCheckRevisioned for Object
Source§impl SkipRevisioned for Object
impl SkipRevisioned for Object
fn skip_revisioned<R: Read>(reader: &mut R) -> Result<(), Error>
Source§fn skip_revisioned_slice(reader: &mut SliceReader<'_>) -> Result<(), Error>
fn skip_revisioned_slice(reader: &mut SliceReader<'_>) -> Result<(), Error>
SliceReader without allocating a buffer for bulk segments. Read moreimpl StructuralPartialEq for Object
Source§impl TryFrom<Object> for PublicObject
impl TryFrom<Object> for PublicObject
Source§impl WalkRevisioned for Object
impl WalkRevisioned for Object
Source§type Walker<'r, R: BorrowedReader + 'r> = ObjectWalker<'r, R>
type Walker<'r, R: BorrowedReader + 'r> = ObjectWalker<'r, R>
walk_revisioned. Read moreSource§fn walk_revisioned<'r, R: BorrowedReader>(
reader: &'r mut R,
) -> Result<Self::Walker<'r, R>, Error>
fn walk_revisioned<'r, R: BorrowedReader>( reader: &'r mut R, ) -> Result<Self::Walker<'r, R>, Error>
Auto Trait Implementations§
impl !RefUnwindSafe for Object
impl !UnwindSafe for Object
impl Freeze for Object
impl Send for Object
impl Sync for Object
impl Unpin for Object
impl UnsafeUnpin for Object
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,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<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.