Skip to main content

Metadata

Struct Metadata 

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

A type-erased container for metadata that can be associated with computation results.

Metadata allows attaching arbitrary typed information to computation results and passing it through the computation pipeline.

It holds at most a handful of entries (typically none, sometimes an animation), so it is a boxed slice searched linearly: an empty Metadata does not allocate, and cloning an empty one is free.

Implementations§

Source§

impl Metadata

Source

pub fn new() -> Metadata

Creates a new, empty metadata container.

Source

pub fn get<T>(&self) -> T
where T: 'static + Clone,

Gets a value of type T from the metadata.

§Panics

Panics if no value of type T is present in the metadata.

Source

pub fn try_get<T>(&self) -> Option<T>
where T: 'static + Clone,

Attempts to get a value of type T from the metadata.

Returns None if no value of the requested type is present.

Source

pub fn with<T>(self, value: T) -> Metadata
where T: 'static + Clone,

Adds a value to the metadata and returns the updated metadata.

A value of the same type that is already present is replaced. This method is chainable for fluent API usage.

Source

pub fn merge(self, other: Metadata) -> Metadata

Merges other into self, returning the union: a value already present under the same type is replaced by other’s.

Deferred notifications (such as a batched List change) compose their metadata this way, so the single notification they finally send carries what the individual ones would have.

Source

pub fn is_empty(&self) -> bool

Checks if the metadata container is empty.

Trait Implementations§

Source§

impl Clone for Metadata

Source§

fn clone(&self) -> Metadata

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Metadata

Source§

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

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

impl Default for Metadata

Source§

fn default() -> Metadata

Returns the “default value” for a type. 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> 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> IdentifiableExt for T

Source§

fn use_id<F, Id>(self, f: F) -> UseId<Self, F>
where F: Fn(&Self) -> Id, Id: Ord + Clone,

Wraps the value in a UseId with the provided identification function.
Source§

fn self_id(self) -> SelfId<Self>

Wraps the value in a SelfId, making the value serve as its own identifier.
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.