SledDatabase

Struct SledDatabase 

Source
pub struct SledDatabase(/* private fields */);
Expand description

Represents a sled database that performs synchronous insertion, retrieval, and removal. Sled maintains disk-backed data, so the serde feature has no purpose with this database.

Sled itself is thread-safe, maintaining an internal Arc for each tree; therefore, this database can be cloned to increment those counters.

Implementations§

Source§

impl SledDatabase

Source

pub fn new(db: Db) -> Self

Creates a new instance of the database wrapping a sled::Db

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 Clone for SledDatabase

Source§

fn clone(&self) -> SledDatabase

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Database for SledDatabase

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

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.