ResourceDictionary
struct · ferroui-base · v0.5.0
struct ResourceDictionary
An indexed dictionary of resources.
Members
TYPEto_refconstructconstruct_with_ownernewwith_ownercountgetsetkeysmerged_dictionariesadd_merged_dictionaryremove_merged_dictionarytheme_dictionariestheme_dictionaries_snapshottheme_dictionaryadd_theme_dictionaryset_theme_dictionaryremove_theme_dictionarykeyset_keyaddadd_valueadd_deferred_fnadd_deferredadd_not_shared_deferredset_itemsclearcontains_keyremovetry_get_valueensure_capacitycontains_deferred_key
TYPE
const TYPE: &'static $crate::TypeInfo
The runtime type of this class.
to_ref
fn to_ref(self: &Self) -> $crate::Ref<ResourceDictionary>
Returns a strong reference to this object.
construct
fn construct() -> Self
Creates the class data; see FerroObject::construct.
construct_with_owner
fn construct_with_owner(owner: &ResourceHostRef) -> Self
Creates the class data of a dictionary that belongs to owner.
new
fn new() -> Ref<Self>
Creates an empty resource dictionary.
with_owner
fn with_owner(owner: impl Into<ResourceHostRef>) -> Ref<Self>
Creates an empty resource dictionary that belongs to owner.
count
fn count(self: &Self) -> usize
The number of resources in the dictionary itself.
get
fn get(self: &Self, key: &ResourceKey) -> ResourceValue
Gets a resource of the dictionary itself; None (a null value) if the
key is not present.
set
fn set(self: &Self, key: impl Into<ResourceKey>, value: ResourceValue)
Adds or replaces a resource.
keys
fn keys(self: &Self) -> Vec<ResourceKey>
The keys of the resources in the dictionary itself.
merged_dictionaries
fn merged_dictionaries(self: &Self) -> FerroList<Rc<dyn IResourceProvider>>
The child resource dictionaries.
The list is returned by handle: clones refer to the same list.
add_merged_dictionary
fn add_merged_dictionary(self: &Self, provider: impl Into<Rc<dyn IResourceProvider>>)
Adds a child resource dictionary.
remove_merged_dictionary
fn remove_merged_dictionary(self: &Self, provider: &Rc<dyn IResourceProvider>) -> bool
Removes a child resource dictionary. Returns whether it was present.
theme_dictionaries
fn theme_dictionaries(self: &Self) -> FerroDictionary<ThemeVariant, Rc<dyn IThemeVariantProvider>>
The resource providers used for specific theme variants.
The dictionary is returned by handle: clones refer to the same dictionary. A provider added to it gets the owner of this dictionary; a removed one loses it.
theme_dictionaries_snapshot
fn theme_dictionaries_snapshot(self: &Self) -> Vec<(ThemeVariant, Rc<dyn IThemeVariantProvider>)>
A snapshot of the resource providers used for specific theme variants.
theme_dictionary
fn theme_dictionary(self: &Self, variant: &ThemeVariant) -> Option<Rc<dyn IThemeVariantProvider>>
The resource provider used for the given theme variant.
add_theme_dictionary
fn add_theme_dictionary(self: &Self, variant: ThemeVariant, provider: impl Into<Rc<dyn IThemeVariantProvider>>)
Adds a resource provider for a theme variant. Panics if the variant already has one.
set_theme_dictionary
fn set_theme_dictionary(self: &Self, variant: ThemeVariant, provider: impl Into<Rc<dyn IThemeVariantProvider>>)
Adds or replaces the resource provider of a theme variant.
remove_theme_dictionary
fn remove_theme_dictionary(self: &Self, variant: &ThemeVariant) -> bool
Removes the resource provider of a theme variant. Returns whether it was present.
key
fn key(self: &Self) -> Option<ThemeVariant>
The key that is used in the theme dictionaries of the containing resource dictionary.
set_key
fn set_key(self: &Self, value: Option<ThemeVariant>)
add
fn add(self: &Self, key: impl Into<ResourceKey>, value: ResourceValue)
Adds a resource. Panics if the key is already present.
add_value
fn add_value<T: PartialEq + 'static>(self: &Self, key: impl Into<ResourceKey>, value: T)
Adds a resource value. Panics if the key is already present.
add_deferred_fn
fn add_deferred_fn(self: &Self, key: impl Into<ResourceKey>, factory: impl Fn(Option<&Rc<dyn IServiceProvider>>) -> Option<BoxedValue> + 'static)
Adds a resource that is created by factory the first time it is
requested.
add_deferred
fn add_deferred(self: &Self, key: impl Into<ResourceKey>, deferred_content: Rc<dyn IDeferredContent>)
Adds a resource that is built from deferred_content the first time
it is requested.
add_not_shared_deferred
fn add_not_shared_deferred(self: &Self, key: impl Into<ResourceKey>, deferred_content: Rc<dyn IDeferredContent>)
Adds a resource that is built from deferred_content every time it is
requested.
set_items
fn set_items(self: &Self, values: impl IntoIterator<Item = (ResourceKey, ResourceValue)>)
Adds or replaces multiple resources, raising a single notification.
clear
fn clear(self: &Self)
Removes all resources of the dictionary itself.
contains_key
fn contains_key(self: &Self, key: &ResourceKey) -> bool
Whether the dictionary itself contains the key.
remove
fn remove(self: &Self, key: &ResourceKey) -> bool
Removes a resource. Returns whether it was present.
try_get_value
fn try_get_value(self: &Self, key: &ResourceKey) -> Option<ResourceValue>
Gets a resource of the dictionary itself, building it if it is deferred.
ensure_capacity
fn ensure_capacity(self: &Self, capacity: usize)
Ensures that the dictionary can hold up to capacity resources
without further expansion of its backing storage.
contains_deferred_key
fn contains_deferred_key(self: &Self, key: &ResourceKey) -> bool
Whether the key is present and its resource has not been built yet.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeResourceProviderImplExtFerroObjectImplExtClassDefaultsBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>ReceiverAnyErasedDestructorIntoEitherDerefUpcast<T>Upcast<ResourceDictionary>StaticTypeObjectTypeSubclassable<T>DefaultConstructibleFerroObjectImplResourceProviderImpl
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.