UuidMapTensorLibrary

Struct UuidMapTensorLibrary 

Source
pub struct UuidMapTensorLibrary<B: Backend> { /* private fields */ }
Expand description

A TensorLibrary backed by a uuid::Uuid keyed HashMap.

Implementations§

Source§

impl<B: Backend> UuidMapTensorLibrary<B>

Source

pub fn new() -> Self

Create an empty library.

Source

pub fn hash_map(&self) -> &HashMap<Uuid, DynTensor<B>>

Get a reference to the internal map.

Source

pub fn hash_map_mut(&mut self) -> &mut HashMap<Uuid, DynTensor<B>>

Get a mutable reference to the internal map.

Source

pub fn insert<T: Into<DynTensor<B>>>( &mut self, key: Uuid, value: T, ) -> Option<DynTensor<B>>

Insert a tensor into the library. If a tensor with the same UUID already exists, it will be replaced.

§Returns

The previous value, if any.

Source

pub fn bind<T: Into<DynTensor<B>>>(&mut self, value: T) -> Uuid

Bind a tensor into the library. Returns the generated UUID.

Source

pub fn remove(&mut self, key: &Uuid) -> Option<DynTensor<B>>

Remove a tensor from the library. Returns None if the tensor was not found.

Source

pub fn clear(&mut self)

Clear the library.

Source

pub fn len(&self) -> usize

Returns the number of tensors in the library.

Source

pub fn is_empty(&self) -> bool

Returns true if the library contains no tensors.

Source

pub fn size_estimate(&self) -> usize

Returns the size estimate of the library in bytes.

Source

pub fn get(&self, key: &Uuid) -> Option<&DynTensor<B>>

Get a tensor ref from the library.

Trait Implementations§

Source§

impl<B: Clone + Backend> Clone for UuidMapTensorLibrary<B>

Source§

fn clone(&self) -> UuidMapTensorLibrary<B>

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<B: Debug + Backend> Debug for UuidMapTensorLibrary<B>

Source§

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

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

impl<B: Backend> Default for UuidMapTensorLibrary<B>

Source§

fn default() -> Self

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

impl<B: Backend> From<HashMap<Uuid, DynTensor<B>>> for UuidMapTensorLibrary<B>

Source§

fn from(hash_map: HashMap<Uuid, DynTensor<B>>) -> Self

Converts to this type from the input type.
Source§

impl<B: Backend> TensorLibrary<B> for UuidMapTensorLibrary<B>

Source§

fn query<'a>( &'a mut self, query: TensorLibraryQuery, ) -> Pin<Box<dyn Future<Output = Result<Option<DynTensor<B>>, TensorLibraryError>> + Send + 'a>>

Query a tensor from the library.

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> 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> CloneBox for T
where T: 'static + Any + Debug + Clone + Send + Sync,

Source§

fn clone_box(&self) -> Box<dyn CloneBox>

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> 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> 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.
Source§

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

Source§

fn vzip(self) -> V