Skip to main content

Props

Struct Props 

Source
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

Source

pub fn new() -> Props

An empty store.

Source

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.

Source

pub fn put_value(&mut self, id: u64, value: Value<'_>) -> Result<bool>

The same from a value that is already read.

§Errors

The same as Props::put.

Source

pub fn get(&self, id: u64) -> Option<Doc<'_>>

What is stored under id.

Source

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.

Source

pub fn contains(&self, id: u64) -> bool

Whether anything is stored under id.

Source

pub fn remove(&mut self, id: u64) -> bool

Takes out what is under id, and says whether there was anything.

Source

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.

Source

pub fn is_empty(&self) -> bool

Whether nothing has properties.

Source

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.

Source

pub fn drop_index(&mut self, path: &str) -> bool

Drops the index over path, and says whether there was one.

Source

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.

Source

pub fn count(&self, path: &str, key: &Key) -> Result<usize>

How many ids have key under path, without reading any of them.

§Errors

The same as Props::find.

Source

pub fn iter(&self) -> impl Iterator<Item = (u64, Doc<'_>)>

Every id with properties, and what they are.

Source

pub fn keys(&self) -> &Keys

The key table, which is where the field names went.

Source

pub fn clear(&mut self)

Takes everything out.

Source

pub fn memory_bytes(&self) -> usize

What this store weighs.

Source

pub fn docs(&self) -> &Docs

The collection underneath, for the range and scan operations that are the document model’s rather than the graph’s.

Trait Implementations§

Source§

impl Debug for Props

Source§

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

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

impl Default for Props

Source§

fn default() -> Props

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

Auto Trait Implementations§

§

impl Freeze for Props

§

impl RefUnwindSafe for Props

§

impl Send for Props

§

impl Sync for Props

§

impl Unpin for Props

§

impl UnsafeUnpin for Props

§

impl UnwindSafe for Props

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 = !

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.