Struct InmemoryDatabase

Source
pub struct InmemoryDatabase { /* private fields */ }
Expand description

Represents an in-memory database that performs synchronous insertion, retrieval, and removal. If the feature serde is enabled, this database can be serialized and deserialized.

Implementations§

Source§

impl InmemoryDatabase

Source

pub fn new() -> Self

Creates a new instance of an in-memory database

Source§

impl InmemoryDatabase

Source

pub fn ids(&self) -> HashSet<Id>

Returns ids of all ents stored in the database

Source

pub fn has_id(&self, id: Id) -> bool

Returns true if database contains the provided id

Source

pub fn ids_for_type(&self, type: &str) -> HashSet<Id>

Returns ids of all ents for the given type

Trait Implementations§

Source§

impl Database for InmemoryDatabase

Source§

fn get_all(&self, ids: Vec<Id>) -> DatabaseResult<Vec<Box<dyn Ent>>>

Performs a retrieval of multiple ents of any type
Source§

fn find_all(&self, query: Query) -> DatabaseResult<Vec<Box<dyn Ent>>>

Finds all generic ents that match the query
Source§

fn get(&self, id: Id) -> DatabaseResult<Option<Box<dyn Ent>>>

Retrieves a copy of a single, generic ent with the corresponding id Read more
Source§

fn remove(&self, id: Id) -> DatabaseResult<bool>

Removes the ent with the corresponding id, triggering edge processing for all disconnected ents. Returns a boolean indicating if an ent was removed.
Source§

fn insert(&self, ent: Box<dyn Ent>) -> DatabaseResult<Id>

Inserts a new ent using its id as the primary index, overwriting any ent with a matching id. If the ent’s id is set to the ephemeral id (of 0), a unique id will be assigned to the ent prior to being inserted. Read more
Source§

impl Default for InmemoryDatabase

Source§

fn default() -> Self

Creates a new, empty database entry

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<T> AsAny for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts reference to Any
Source§

fn as_mut_any(&mut self) -> &mut (dyn Any + 'static)

converts mutable reference to Any
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> DatabaseExt for T
where T: Database,

Source§

fn insert_typed<E>(&self, ent: E) -> Result<usize, DatabaseError>
where E: Ent,

Inserts an ent of a specific type
Source§

fn get_typed<E>(&self, id: usize) -> Result<Option<E>, DatabaseError>
where E: Ent,

Retrieves an ent by id with a specific type
Source§

fn get_all_typed<E>(&self, ids: Vec<usize>) -> Result<Vec<E>, DatabaseError>
where E: Ent,

Retrieves ents by id with a specific type
Source§

fn find_all_typed<E>(&self, query: Query) -> Result<Vec<E>, DatabaseError>
where E: Ent,

Finds ents that match the specified query and are of the specified type
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.