pub struct Provider<E, V> { /* private fields */ }Expand description
Key-value container of a V value for every possible E.
Implementations§
Source§impl<E, V> Provider<E, V>where
E: BlockModule,
impl<E, V> Provider<E, V>where
E: BlockModule,
Sourcepub async fn new<F>(
progress: YieldProgress,
definer: F,
) -> Result<Self, GenError>
pub async fn new<F>( progress: YieldProgress, definer: F, ) -> Result<Self, GenError>
Constructs a Provider with values computed by the given function.
This is an async function for the sake of cancellation and optional cooperative
multitasking. It may be blocked on from a synchronous context (but if that is the
only use, consider calling Provider::new_sync() instead).
Source§impl<E: BlockModule> Provider<E, Block>
impl<E: BlockModule> Provider<E, Block>
Sourcepub async fn new_installed_cyclic<F>(
progress: YieldProgress,
txn: &mut UniverseTransaction,
definer: F,
) -> Result<Self, GenError>
pub async fn new_installed_cyclic<F>( progress: YieldProgress, txn: &mut UniverseTransaction, definer: F, ) -> Result<Self, GenError>
Constructs a BlockProvider with BlockDefs whose block values are computed by the
given function.
The module itself is passed to definer, which may be used to create
relationships among the blocks (e.g. one having the behavior of turning into another).
Attempting to read those handles will necessarily fail.
Sourcepub fn install(
&self,
read_ticket: ReadTicket<'_>,
txn: &mut UniverseTransaction,
) -> Result<Self, InsertError>
pub fn install( &self, read_ticket: ReadTicket<'_>, txn: &mut UniverseTransaction, ) -> Result<Self, InsertError>
Add the block definitions stored in this BlockProvider into universe as
BlockDefs, returning a new BlockProvider whose blocks refer to those
definitions (via Primitive::Indirect).
The given read_ticket should be sufficient for evaluating the blocks
in self.
Sourcepub fn using(universe: &Universe) -> Result<Self, ProviderError>
pub fn using(universe: &Universe) -> Result<Self, ProviderError>
Obtain the definitions of E’s blocks from universe, returning a new
BlockProvider whose blocks refer to those definitions (via
Primitive::Indirect).
Returns an error if any of the blocks are not defined in that universe.
Source§impl<E: Exhaust + Debug + Clone + Eq + Hash, V> Provider<E, V>
These methods do not require E to be a BlockModule.
impl<E: Exhaust + Debug + Clone + Eq + Hash, V> Provider<E, V>
These methods do not require E to be a BlockModule.
Sourcepub fn new_sync<F>(definer: F) -> Selfwhere
F: FnMut(E) -> V,
pub fn new_sync<F>(definer: F) -> Selfwhere
F: FnMut(E) -> V,
Alternative to Self::new() which is neither async nor fallible.
Sourcepub fn subset<K>(&self, function: impl Fn(K) -> E) -> Provider<K, V>
pub fn subset<K>(&self, function: impl Fn(K) -> E) -> Provider<K, V>
Create another Provider with different keys that map into a subset of
this provider’s keys.
TODO: add a test
Sourcepub fn map<V2>(&self, function: impl FnMut(&E, &V) -> V2) -> Provider<E, V2>
pub fn map<V2>(&self, function: impl FnMut(&E, &V) -> V2) -> Provider<E, V2>
Create another Provider with a modification to each value.
Sourcepub fn iter(&self) -> ModuleIter<'_, E, V> ⓘ
pub fn iter(&self) -> ModuleIter<'_, E, V> ⓘ
Iterate over the entire contents of this.
Trait Implementations§
Source§impl<'provider, E: Exhaust + Debug + Clone + Eq + Hash, V> IntoIterator for &'provider Provider<E, V>
impl<'provider, E: Exhaust + Debug + Clone + Eq + Hash, V> IntoIterator for &'provider Provider<E, V>
Source§impl<E: Eq + Hash + VisitHandles, V: VisitHandles> VisitHandles for Provider<E, V>
impl<E: Eq + Hash + VisitHandles, V: VisitHandles> VisitHandles for Provider<E, V>
Source§fn visit_handles(&self, visitor: &mut dyn HandleVisitor)
fn visit_handles(&self, visitor: &mut dyn HandleVisitor)
impl<E: Eq + Hash, V: PartialEq> Eq for Provider<E, V>
Auto Trait Implementations§
impl<E, V> Freeze for Provider<E, V>
impl<E, V> RefUnwindSafe for Provider<E, V>where
E: RefUnwindSafe,
V: RefUnwindSafe,
impl<E, V> Send for Provider<E, V>
impl<E, V> Sync for Provider<E, V>
impl<E, V> Unpin for Provider<E, V>
impl<E, V> UnwindSafe for Provider<E, V>where
E: UnwindSafe,
V: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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