pub struct Props { /* private fields */ }Expand description
The properties of a set of nodes, or of a set of edges.
One of these holds documents under integer ids, with whatever path indexes
the caller declared. A crate::Graph has two: one keyed by node id and one
keyed by edge slot.
Implementations§
Source§impl Props
impl Props
Sourcepub fn put(&mut self, id: u64, doc: &[u8]) -> Result<bool>
pub fn put(&mut self, id: u64, doc: &[u8]) -> Result<bool>
Stores doc under id, replacing whatever was there.
Answers whether this was new, which is what a caller counting nodes wants and what an overwrite is not.
§Errors
Whatever Docs::put_bytes answers: the document is malformed, or a
value that an index covers is too long to be an index key. In the second
case nothing is stored, so a document is never in the collection and out
of its own indexes.
Sourcepub fn bytes(&self, id: u64) -> Option<&[u8]>
pub fn bytes(&self, id: u64) -> Option<&[u8]>
The stored bytes, for a caller that is about to write them somewhere rather than read them.
Sourcepub fn remove(&mut self, id: u64) -> bool
pub fn remove(&mut self, id: u64) -> bool
Takes out what is under id, and says whether there was anything.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
How many ids have properties.
Not how many nodes the graph has. A node with no properties is a node, and it is not in here.
Sourcepub fn create_index(&mut self, path: &str, kind: IndexKind) -> Result<()>
pub fn create_index(&mut self, path: &str, kind: IndexKind) -> Result<()>
Declares an index over path, and backfills it over what is already
stored.
§Errors
Whatever Docs::create_index_bytes answers: the path does not parse,
it is already indexed, or a document already here has a value under it
that cannot be an index key.
Sourcepub fn drop_index(&mut self, path: &str) -> bool
pub fn drop_index(&mut self, path: &str) -> bool
Drops the index over path, and says whether there was one.
Sourcepub fn find(
&self,
path: &str,
key: &Key,
f: impl FnMut(u64, Doc<'_>),
) -> Result<usize>
pub fn find( &self, path: &str, key: &Key, f: impl FnMut(u64, Doc<'_>), ) -> Result<usize>
Calls f for every id whose document has key under path, and
answers how many that was.
§Errors
yo_common::Code::Invalid if path is not indexed, because a query
that would have to scan the whole store is a mistake rather than a slow
answer.
Sourcepub fn iter(&self) -> impl Iterator<Item = (u64, Doc<'_>)>
pub fn iter(&self) -> impl Iterator<Item = (u64, Doc<'_>)>
Every id with properties, and what they are.
Sourcepub fn memory_bytes(&self) -> usize
pub fn memory_bytes(&self) -> usize
What this store weighs.