pub struct Doc<'a> { /* private fields */ }Expand description
A value with the key table its keys are interned against.
Everything a Value offers is here too, and the things that need a name
rather than an id, which are a lookup, a walk over the members and printing
the thing, go through the table. A document whose keys are bytes works the
same way and simply never asks the table anything, so a caller does not have
to know which kind it is holding.
Implementations§
Source§impl<'a> Doc<'a>
impl<'a> Doc<'a>
Sourcepub fn value(&self) -> Value<'a>
pub fn value(&self) -> Value<'a>
The value underneath, for the accessors that never need a name.
Sourcepub fn as_text(&self) -> Option<&'a str>
pub fn as_text(&self) -> Option<&'a str>
The string this holds, if it holds one and it is UTF-8.
Sourcepub fn text_bytes(&self) -> Option<&'a [u8]>
pub fn text_bytes(&self) -> Option<&'a [u8]>
The string this holds as it is stored, without the UTF-8 check.
Sourcepub fn get(&self, key: &[u8]) -> Option<Doc<'a>>
pub fn get(&self, key: &[u8]) -> Option<Doc<'a>>
The value stored under key.
For an interned object this is a name to id lookup in the table and then
a binary search over integers. A name the table has never seen cannot be
in the document, so it answers None without touching the document at
all.
Sourcepub fn at(&self, i: usize) -> Option<Doc<'a>>
pub fn at(&self, i: usize) -> Option<Doc<'a>>
Element i of a container, in the container’s own order.
Sourcepub fn key_at(&self, i: usize) -> Option<&'a [u8]>
pub fn key_at(&self, i: usize) -> Option<&'a [u8]>
The name of member i of an object, whichever way the keys are stored.
Sourcepub fn members(&self) -> DocMembers<'a> ⓘ
pub fn members(&self) -> DocMembers<'a> ⓘ
Every member of an object, name first, in the order the document stores them.
That order is by key id for an interned object and by key bytes for one whose keys are bytes, so it is stable for a given collection and it is not alphabetical. Sort it if the order is part of the answer.
Sourcepub fn iter(&self) -> DocElems<'a> ⓘ
pub fn iter(&self) -> DocElems<'a> ⓘ
Every element of a container, in the container’s own order.