Trait persian_rug::Owner

source ·
pub trait Owner<T>: Context
where T: Contextual<Context = Self>,
{ // Required methods fn add(&mut self, value: T) -> Proxy<T>; fn get(&self, proxy: &Proxy<T>) -> &T; fn get_mut(&mut self, proxy: &Proxy<T>) -> &mut T; fn get_iter(&self) -> TableIterator<'_, T> ; fn get_iter_mut(&mut self) -> TableMutIterator<'_, T> ; fn get_proxy_iter(&self) -> TableProxyIterator<'_, T> ; }
Expand description

A type that owns (is the exclusive holder of) a Contextual type.

Implementations of this trait are normally provided for you by the persian_rug attribute macro. You should rarely, if ever, need to implement it yourself.

Each Contextual type has a single Context that owns it. Only that context may implement this trait for the type, which provides the standard API for Context objects, specialised to a single type. The polymorphic interface for contexts calls through to the functions defined in this trait, and you should never need to call them directly; it is preferable to use the Context interface.

The main place in which Owner shows up in code written using this crate is when specifying the constraints on what contexts are permitted to call a given generic function. In general, those uses of Owner can also be generated for you, using the constraints attribute macro, but there are cases where you may need to refer to it yourself: essentially whenever you need to assert that you will be able to interact with a type T or a proxy for it, via some context, then you can assert that the context implements Owner<T>.

Required Methods§

source

fn add(&mut self, value: T) -> Proxy<T>

Insert the given value, obtaining a Proxy for it.

source

fn get(&self, proxy: &Proxy<T>) -> &T

Get a shared reference to a value from a Proxy for it.

source

fn get_mut(&mut self, proxy: &Proxy<T>) -> &mut T

Get an exclusive reference to a value from a Proxy for it.

source

fn get_iter(&self) -> TableIterator<'_, T>

Iterate over shared references to the stored values.

source

fn get_iter_mut(&mut self) -> TableMutIterator<'_, T>

Iterate over exclusive references to the stored values.

source

fn get_proxy_iter(&self) -> TableProxyIterator<'_, T>

Iterate over shared references to Proxy objects for the stored values.

Object Safety§

This trait is not object safe.

Implementors§