Skip to main content

ObjectView

Struct ObjectView 

Source
pub struct ObjectView<'a> { /* private fields */ }
Expand description

Borrowed view over an object (JSONParser.h:239 JSONObject). Grown in B3 with name lookups + iteration.

Implementations§

Source§

impl<'a> ObjectView<'a>

Source

pub fn size(&self) -> usize

Number of members (faithful to C++ JSONObject::size).

Source

pub fn get_hidden_class(&self) -> &'a JSONHiddenClass<'a>

Returns the hidden class descriptor shared among same-shape objects.

Source

pub fn get(&self, name: &str, atoms: &AtomTable) -> Option<&'a JSONValue<'a>>

JSONParser.h:286 — value for name, or None.

Source

pub fn at(&self, name: &str, atoms: &AtomTable) -> &'a JSONValue<'a>

JSONParser.h:295 — value for name; panics if absent (C++ asserts).

Source

pub fn count(&self, name: &str, atoms: &AtomTable) -> usize

JSONParser.h:323 — 1 if present else 0.

Source

pub fn value_at(&self, index: usize) -> &'a JSONValue<'a>

Value by position (0..size). Panics if out of range.

Source

pub fn key_at(&self, index: usize) -> AtomBytes

Key (interned handle) by position. Panics if out of range.

Source

pub fn find(&self, name: &str, atoms: &AtomTable) -> Option<usize>

JSONParser.h:440 — index of name in the (sorted) members, or None. (C++ returns an iterator; we return the positional index for use with value_at/key_at.)

Source

pub fn iter(&self) -> impl Iterator<Item = (AtomBytes, &'a JSONValue<'a>)> + '_

JSONParser.h:330 — (key, value) pairs, in the hidden class’s sorted order.

Auto Trait Implementations§

§

impl<'a> Freeze for ObjectView<'a>

§

impl<'a> RefUnwindSafe for ObjectView<'a>

§

impl<'a> Send for ObjectView<'a>

§

impl<'a> Sync for ObjectView<'a>

§

impl<'a> Unpin for ObjectView<'a>

§

impl<'a> UnsafeUnpin for ObjectView<'a>

§

impl<'a> UnwindSafe for ObjectView<'a>

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<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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.