Trait persian_rug::Owner
source · [−]pub trait Owner<T>: Context where
T: Contextual<Context = Self>, {
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>ⓘNotable traits for TableIterator<'a, T>impl<'a, T> Iterator for TableIterator<'a, T> type Item = &'a T;
;
fn get_iter_mut(&mut self) -> TableMutIterator<'_, T>ⓘNotable traits for TableMutIterator<'a, T>impl<'a, T> Iterator for TableMutIterator<'a, T> type Item = &'a mut T;
;
fn get_proxy_iter(&self) -> TableProxyIterator<'_, T>ⓘNotable traits for TableProxyIterator<'a, T>impl<'a, T> Iterator for TableProxyIterator<'a, T> type Item = &'a Proxy<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
Get an exclusive reference to a value from a Proxy
for it.
fn get_iter(&self) -> TableIterator<'_, T>ⓘNotable traits for TableIterator<'a, T>impl<'a, T> Iterator for TableIterator<'a, T> type Item = &'a T;
fn get_iter(&self) -> TableIterator<'_, T>ⓘNotable traits for TableIterator<'a, T>impl<'a, T> Iterator for TableIterator<'a, T> type Item = &'a T;
Iterate over shared references to the stored values.
fn get_iter_mut(&mut self) -> TableMutIterator<'_, T>ⓘNotable traits for TableMutIterator<'a, T>impl<'a, T> Iterator for TableMutIterator<'a, T> type Item = &'a mut T;
fn get_iter_mut(&mut self) -> TableMutIterator<'_, T>ⓘNotable traits for TableMutIterator<'a, T>impl<'a, T> Iterator for TableMutIterator<'a, T> type Item = &'a mut T;
Iterate over exclusive references to the stored values.
fn get_proxy_iter(&self) -> TableProxyIterator<'_, T>ⓘNotable traits for TableProxyIterator<'a, T>impl<'a, T> Iterator for TableProxyIterator<'a, T> type Item = &'a Proxy<T>;
fn get_proxy_iter(&self) -> TableProxyIterator<'_, T>ⓘNotable traits for TableProxyIterator<'a, T>impl<'a, T> Iterator for TableProxyIterator<'a, T> type Item = &'a Proxy<T>;
Iterate over shared references to Proxy
objects for the
stored values.