[][src]Trait entity::Database

pub trait Database: AsAny + Send + Sync {
    pub fn get(&self, id: Id) -> DatabaseResult<Option<Box<dyn Ent>>>;
pub fn remove(&self, id: Id) -> DatabaseResult<bool>;
pub fn insert(&self, ent: Box<dyn Ent>) -> DatabaseResult<Id>;
pub fn get_all(&self, ids: Vec<Id>) -> DatabaseResult<Vec<Box<dyn Ent>>>;
pub fn find_all(&self, query: Query) -> DatabaseResult<Vec<Box<dyn Ent>>>; }

Represents a synchronous database, which performs blocking CRUD operations using ents. Given that many database implementations handle interior mutability themselves, the API of this trait does not provide any mut guarantees itself.

Required methods

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

Retrieves a copy of a single, generic ent with the corresponding id

This should not connect the ent back to the database upon return as that decision should be made outside of the database itself.

pub fn remove(&self, id: Id) -> DatabaseResult<bool>[src]

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

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

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.

The ent's id is returned after being inserted.

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

Performs a retrieval of multiple ents of any type

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

Finds all generic ents that match the query

Loading content...

Implementations

impl dyn Database[src]

Implementation for a generic trait object of Database that provides methods to downcast into a concrete type

pub fn as_database<D: Database>(&self) -> Option<&D>[src]

Attempts to convert this dynamic Database ref into a concrete Database ref by downcasting

pub fn as_mut_database<D: Database>(&mut self) -> Option<&mut D>[src]

Attempts to convert this dynamic Database mutable ref into a concrete Database mutable ref by downcasting

Trait Implementations

impl DatabaseExt for dyn Database[src]

Implementors

Loading content...