Skip to main content

Object

Struct Object 

Source
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), inner VecMap written via the indexed-map prologue past OFFSET_TABLE_MIN_LEN = 8. Walker descent stays zero-allocation: walk_field_0() on a Wire-repr parent borrows the field bytes directly by bracketing skip_indexed_map with BorrowedReader::remaining() snapshots, no decode + re-encode required.

Tuple Fields§

§0: VecMap<Strand, Value>

Implementations§

Source§

impl Object

Source

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

Source

pub const REVISION: u16 = 2u16

The revision number of this type, as declared via #[revisioned(revision = N)].

Source§

impl Object

Source

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.

Source

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.

Source

pub fn get_mut(&mut self, key: &str) -> Option<&mut Value>

Look up a value by key for mutation.

Source

pub fn contains_key(&self, key: &str) -> bool

Check whether the object contains a given key.

Source

pub fn remove(&mut self, key: &str) -> Option<Value>

Remove and return the value for key.

Source

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.

Source

pub fn rid(&self) -> Option<RecordId>

Fetch the record id if there is one

Source

pub fn into_literal(self) -> Vec<ObjectEntry>

Methods from Deref<Target = VecMap<Strand, Value>>§

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn clear(&mut self)

Source

pub fn get<Q>(&self, key: &Q) -> Option<&V>
where Q: Ord + ?Sized, K: Borrow<Q>,

Source

pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
where Q: Ord + ?Sized, K: Borrow<Q>,

Source

pub fn contains_key<Q>(&self, key: &Q) -> bool
where Q: Ord + ?Sized, K: Borrow<Q>,

Source

pub fn insert(&mut self, key: K, value: V) -> Option<V>
where K: Ord,

Source

pub fn remove<Q>(&mut self, key: &Q) -> Option<V>
where Q: Ord + ?Sized, K: Borrow<Q>,

Source

pub fn retain<F>(&mut self, f: F)
where F: FnMut(&K, &mut V) -> bool,

Source

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).

Source

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).

Source

pub fn iter(&self) -> Iter<'_, K, V>

Source

pub fn iter_mut(&mut self) -> IterMut<'_, K, V>

Source

pub fn keys(&self) -> impl Iterator<Item = &K>

Source

pub fn values(&self) -> impl Iterator<Item = &V>

Source

pub fn values_mut(&mut self) -> impl Iterator<Item = &mut V>

Source

pub fn first_key_value(&self) -> Option<(&K, &V)>

Source

pub fn last_key_value(&self) -> Option<(&K, &V)>

Source

pub fn entry(&mut self, key: K) -> Entry<'_, K, V>
where K: Ord,

Trait Implementations§

Source§

impl Add for Object

Source§

type Output = Object

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<'de> BorrowDecode<'de, IndexFormat> for Object

Source§

impl<'de> BorrowDecode<'de> for Object

Source§

impl Cast for Object

Source§

fn can_cast(v: &Value) -> bool

Returns true if calling cast on the value will succeed. Read more
Source§

fn cast(v: Value) -> Result<Self, CastError>

Cast a value to the self type.
Source§

impl Clone for Object

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Coerce for Object

Source§

fn can_coerce(v: &Value) -> bool

Returns if calling coerce on the value will succeed or not. Read more
Source§

fn coerce(v: Value) -> Result<Self, CoerceError>

Coerce a value.
Source§

impl Debug for Object

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Object

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Deref for Object

Source§

type Target = VecMap<Strand, Value>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for Object

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl DeserializeRevisioned for Object

Source§

fn deserialize_revisioned<R: Read>(reader: &mut R) -> Result<Self, Error>

Deserializes a new instance of the struct from the specified reader.
Source§

impl Encode for Object

Source§

fn encode<W: Write>(&self, _w: &mut Writer<W>) -> Result<(), EncodeError>

Source§

impl Encode<IndexFormat> for Object

Source§

fn encode<W: Write>(&self, _w: &mut Writer<W>) -> Result<(), EncodeError>

Source§

impl Eq for Object

Source§

impl From<BTreeMap<&str, Value>> for Object

Source§

fn from(v: BTreeMap<&str, Value>) -> Self

Converts to this type from the input type.
Source§

impl From<BTreeMap<Strand, Value>> for Object

Source§

fn from(v: BTreeMap<Strand, Value>) -> Self

Converts to this type from the input type.
Source§

impl From<BTreeMap<String, String>> for Object

Source§

fn from(v: BTreeMap<String, String>) -> Self

Converts to this type from the input type.
Source§

impl From<BTreeMap<String, Value>> for Object

Source§

fn from(v: BTreeMap<String, Value>) -> Self

Converts to this type from the input type.
Source§

impl From<HashMap<&str, Value>> for Object

Source§

fn from(v: HashMap<&str, Value>) -> Self

Converts to this type from the input type.
Source§

impl From<HashMap<String, Value>> for Object

Source§

fn from(v: HashMap<String, Value>) -> Self

Converts to this type from the input type.
Source§

impl From<Object> for Variables

Source§

fn from(obj: Object) -> Self

Converts to this type from the input type.
Source§

impl From<Object> for Object

Source§

fn from(s: PublicObject) -> Self

Converts to this type from the input type.
Source§

impl From<Object> for RecordIdKey

Source§

fn from(value: Object) -> Self

Converts to this type from the input type.
Source§

impl From<Object> for Value

Source§

fn from(v: Object) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<(String, Value)>> for Object

Source§

fn from(v: Vec<(String, Value)>) -> Self

Converts to this type from the input type.
Source§

impl From<VecMap<&str, Value>> for Object

Source§

fn from(v: VecMap<&str, Value>) -> Self

Converts to this type from the input type.
Source§

impl From<VecMap<Strand, Value>> for Object

Source§

fn from(v: VecMap<Strand, Value>) -> Self

Converts to this type from the input type.
Source§

impl From<VecMap<String, Value>> for Object

Source§

fn from(v: VecMap<String, Value>) -> Self

Converts to this type from the input type.
Source§

impl<'a> FromIterator<(&'a str, Value)> for Object

Source§

fn from_iter<T: IntoIterator<Item = (&'a str, Value)>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl FromIterator<(Strand, Value)> for Object

Source§

fn from_iter<T: IntoIterator<Item = (Strand, Value)>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl FromIterator<(String, Value)> for Object

Source§

fn from_iter<T: IntoIterator<Item = (String, Value)>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl HasKind for Object

Source§

impl Hash for Object

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl IntoIterator for Object

Source§

type Item = (Strand, Value)

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<Strand, Value>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl Ord for Object

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for Object

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for Object

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Revisioned for Object

Source§

fn revision() -> u16

Returns the current revision of this type.
Source§

fn type_id() -> TypeId
where Self: 'static,

Returns the type id of this type.
Source§

impl SerializeRevisioned for Object

Source§

fn serialize_revisioned<W: Write>(&self, writer: &mut W) -> Result<(), Error>

Serializes the struct using the specified writer.
Source§

impl SkipCheckRevisioned for Object

Source§

impl SkipRevisioned for Object

Source§

fn skip_revisioned<R: Read>(reader: &mut R) -> Result<(), Error>

Source§

fn skip_revisioned_slice(reader: &mut SliceReader<'_>) -> Result<(), Error>

Consume through bytes backed by SliceReader without allocating a buffer for bulk segments. Read more
Source§

impl StructuralPartialEq for Object

Source§

impl ToSql for Object

Source§

fn fmt_sql(&self, f: &mut String, sql_fmt: SqlFormat)

Format the type to a SQL string.
Source§

fn to_sql(&self) -> String

Convert the type to a SQL string.
Source§

fn to_sql_pretty(&self) -> String

Convert the type to a pretty-printed SQL string with indentation.
Source§

impl TryFrom<Object> for PublicObject

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(s: Object) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryInto<BTreeMap<String, String>> for Object

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<BTreeMap<String, String>, Self::Error>

Performs the conversion.
Source§

impl TryInto<HeaderMap> for Object

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<HeaderMap, Self::Error>

Performs the conversion.
Source§

impl WalkRevisioned for Object

Source§

type Walker<'r, R: BorrowedReader + 'r> = ObjectWalker<'r, R>

Walker produced by walk_revisioned. Read more
Source§

fn walk_revisioned<'r, R: BorrowedReader>( reader: &'r mut R, ) -> Result<Self::Walker<'r, R>, Error>

Read the type’s revision-level prefix and return a walker positioned at the start of the body. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<U> As for U

Source§

fn as_<T>(self) -> T
where T: CastFrom<U>, U: Sized,

Casts self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SetEntry<T> for T
where T: Hash + Eq,

Source§

fn into_owned(self) -> T

Source§

fn equal(&self, other: &T) -> bool

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool