Struct StorageManager

pub struct StorageManager<Id, Element> { /* private fields */ }
Expand description

This manager handles if multiple storage options have been specified It can load resources from one storage aspect and will

Implementations§

§

impl<Id, Element> StorageManager<Id, Element>

pub fn open_or_create( storage_builder: StorageBuilder<true>, instance: u64, ) -> Result<StorageManager<Id, Element>, StorageError>

Available on crate feature cpu_os_threads only.

Constructs the StorageManager from the instance identifier and the settings given by the StorageBuilder.

use cellular_raza_core::storage::*;
let builder = StorageBuilder::new()
    .location("/tmp")
    .init();

let manager = StorageManager::<usize, f64>::open_or_create(builder, 0)?;

pub fn extract_builder(&self) -> StorageBuilder<true>

Available on crate feature cpu_os_threads only.

Extracts all information given by the StorageBuilder when constructing

pub fn get_instance(&self) -> u64

Available on crate feature cpu_os_threads only.

Get the instance of this object.

These instances should not be overlapping, ie. there should not be two objects existing in parallel with the same instance number.

Trait Implementations§

§

impl<Id, Element> Clone for StorageManager<Id, Element>
where Id: Clone, Element: Clone,

§

fn clone(&self) -> StorageManager<Id, Element>

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

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

Performs copy-assignment from source. Read more
§

impl<Id, Element> Debug for StorageManager<Id, Element>
where Id: Debug, Element: Debug,

§

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

Formats the value using the given formatter. Read more
§

impl<Id, Element> StorageInterfaceLoad<Id, Element> for StorageManager<Id, Element>
where Id: Hash + Eq + Clone, Element: Clone,

§

fn load_single_element( &self, iteration: u64, identifier: &Id, ) -> Result<Option<Element>, StorageError>
where Id: Serialize + for<'a> Deserialize<'a>, Element: for<'a> Deserialize<'a>,

Loads a single element from the storage solution if the element exists.
§

fn load_all_elements_at_iteration( &self, iteration: u64, ) -> Result<HashMap<Id, Element>, StorageError>
where Id: Hash + Eq + for<'a> Deserialize<'a>, Element: for<'a> Deserialize<'a>,

Gets a snapshot of all elements at a given iteration. Read more
§

fn get_all_iterations(&self) -> Result<Vec<u64>, StorageError>

Get all iteration values which have been saved.
§

fn load_element_history( &self, identifier: &Id, ) -> Result<HashMap<u64, Element>, StorageError>
where Id: Eq + Serialize + for<'a> Deserialize<'a>, Element: for<'a> Deserialize<'a>,

Loads the elements history, meaning every occurrence of the element in the storage. This function by default provides the results in ordered fashion such that the time direction is retained. Furthermore this function assumes that a given index occurs over the course of a complete time segment with no interceptions. Read more
§

fn load_all_elements( &self, ) -> Result<BTreeMap<u64, HashMap<Id, Element>>, StorageError>
where Id: Hash + Eq + for<'a> Deserialize<'a>, Element: for<'a> Deserialize<'a>,

Loads all elements for every iteration. This will yield the complete storage and may result in extremely large allocations of memory.
§

fn load_all_element_histories( &self, ) -> Result<HashMap<Id, BTreeMap<u64, Element>>, StorageError>
where Id: Hash + Eq + for<'a> Deserialize<'a>, Element: for<'a> Deserialize<'a>,

Similarly to the load_all_elements function, but this function returns all elements as their histories.
§

impl<Id, Element> StorageInterfaceStore<Id, Element> for StorageManager<Id, Element>
where Id: Hash + Eq + Clone, Element: Clone,

§

fn store_single_element( &mut self, iteration: u64, identifier: &Id, element: &Element, ) -> Result<(), StorageError>
where Id: Serialize, Element: Serialize,

Saves a single element at given iteration.
§

fn store_batch_elements<'a, I>( &'a mut self, iteration: u64, identifiers_elements: I, ) -> Result<(), StorageError>
where Id: 'a + Serialize, Element: 'a + Serialize, I: Clone + IntoIterator<Item = (&'a Id, &'a Element)>,

Stores a batch of multiple elements with identifiers all at the same iteration.

Auto Trait Implementations§

§

impl<Id, Element> Freeze for StorageManager<Id, Element>

§

impl<Id, Element> !RefUnwindSafe for StorageManager<Id, Element>

§

impl<Id, Element> Send for StorageManager<Id, Element>
where Id: Send, Element: Send,

§

impl<Id, Element> Sync for StorageManager<Id, Element>
where Id: Sync, Element: Sync,

§

impl<Id, Element> Unpin for StorageManager<Id, Element>
where Id: Unpin, Element: Unpin,

§

impl<Id, Element> !UnwindSafe for StorageManager<Id, Element>

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

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<T> InteractionInformation for T
where T: Send + Sync + Clone + Debug,

§

impl<T> Ungil for T
where T: Send,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,