Base Provider
bevy.providers.provider.NotFound
NotFound(message: str = '')
Bases: Null
Null option for when a key isn't found in a provider's cache.
bevy.providers.provider.NotSupported
NotSupported(message: str = '')
Bases: Null
Null option for when a key isn't supported by a provider.
bevy.providers.provider.Provider
Bases: Generic[_K, _V]
The base provider type offers simple implementations of all methods that a provider should have. It does not
offer any way to create new instances in the cache, so it shouldn't be considered a fully functional provider type.
It is necessary for subclasses implement their own factory
method to add support for this missing functionality.
Every provider stores a reference to the repository it is attached to and a key/value cache for storing instances that it creates.
create
create(key: _K, cache: _ProviderState[_K, _V]) -> Option[_V]
Uses a factory function provided by the provider's factory method to get an instance that adheres to the type _V and that corresponds to the key. A Null option (NotSupported) is returned when no factory is available, otherwise a Value option containing the factory's return is returned.
factory
factory(key: _K, cache: _ProviderState[_K, _V]) -> Option[Factory]
The base provider returns a Null option as it does not support creating new instances that adhere to the type _V. This method should be overriden by base classes to create or lookup instances as appropriate that are returned as Value options.
find
find(key: _K, cache: _ProviderState[_K, _V]) -> Option[_V]
Searches the cache for an instance that adheres to the type _V and that corresponds to the key. When a match is found, a Value option containing the instance is returned, otherwise a Null option (NotFound) is returned.
set
set(key: _K, value: _V, cache: _ProviderState[_K, _V]) -> Option[_V]
Sets a value in the cache for the key only if the key is supported by the provider. A Null option (NotSupported) is returned when the key is not supported, otherwise a Value option containing the value placed in the cache is returned.
supports
supports(key: _K, cache: _ProviderState[_K, _V]) -> bool
Determines if the key is supported by the provider. Returns True if the factory
method returns a Value
option, False if it returned a Null option.