# ResourceProvider

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/controls/struct-resourceprovider/

**struct** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
struct ResourceProvider
```

Base implementation for resource providers.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_provider.rs#L14)

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`has_resources`](#function-has_resources)
- [`try_get_resource`](#function-try_get_resource)
- [`on_add_owner`](#function-on_add_owner)
- [`on_remove_owner`](#function-on_remove_owner)
- [`construct`](#function-construct)
- [`construct_with_owner`](#function-construct_with_owner)
- [`owner`](#function-owner)
- [`owner_changed`](#function-owner_changed)
- [`raise_resources_changed`](#function-raise_resources_changed)
- [`add_owner`](#function-add_owner)
- [`remove_owner`](#function-remove_owner)

<a id="assoc_const-type"></a>

### TYPE

```rust
const TYPE: &'static $crate::TypeInfo
```

The runtime type of this class.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_provider.rs#L20)

<a id="function-to_ref"></a>

### to_ref

```rust
fn to_ref(self: &Self) -> $crate::Ref<ResourceProvider>
```

Returns a strong reference to this object.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_provider.rs#L20)

<a id="function-has_resources"></a>

### has_resources

```rust
fn has_resources(self: &Self) -> bool
```

Whether the provider has resources.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_provider.rs#L20)

<a id="function-try_get_resource"></a>

### try_get_resource

```rust
fn try_get_resource(self: &Self, key: &ResourceKey, theme: Option<&ThemeVariant>) -> Option<ResourceValue>
```

Tries to find a resource within the provider.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_provider.rs#L20)

<a id="function-on_add_owner"></a>

### on_add_owner

```rust
fn on_add_owner(self: &Self, owner: &ResourceHostRef)
```

Handles when the owner is added. The base method notifies the
owner about its resources changing, if the provider has any.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_provider.rs#L20)

<a id="function-on_remove_owner"></a>

### on_remove_owner

```rust
fn on_remove_owner(self: &Self, owner: &ResourceHostRef)
```

Handles when the owner is removed. The base method notifies the
owner about its resources changing, if the provider has any.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_provider.rs#L20)

<a id="function-construct"></a>

### construct

```rust
fn construct() -> Self
```

Creates the class data of a provider without an owner.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_provider.rs#L63)

<a id="function-construct_with_owner"></a>

### construct_with_owner

```rust
fn construct_with_owner(owner: &ResourceHostRef) -> Self
```

Creates the class data of a provider that belongs to `owner`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_provider.rs#L68)

<a id="function-owner"></a>

### owner

```rust
fn owner(self: &Self) -> Option<ResourceHostRef>
```

The owner of the resource provider.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_provider.rs#L77)

<a id="function-owner_changed"></a>

### owner_changed

```rust
fn owner_changed(self: &Self, handler: impl Fn() -> () + 'static) -> Rc<dyn IDisposable>
```

Raised when the owner of the resource provider changes.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_provider.rs#L95)

<a id="function-raise_resources_changed"></a>

### raise_resources_changed

```rust
fn raise_resources_changed(self: &Self)
```

Notifies the owner, if any, that the resources of the provider have
changed.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_provider.rs#L111)

<a id="function-add_owner"></a>

### add_owner

```rust
fn add_owner(self: &Self, owner: &ResourceHostRef)
```

Adds an owner to the resource provider.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_provider.rs#L118)

<a id="function-remove_owner"></a>

### remove_owner

```rust
fn remove_owner(self: &Self, owner: &ResourceHostRef)
```

Removes a resource provider owner.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_provider.rs#L127)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ResourceProviderImplExt`](/docs/0.5.0/api/ferroui-base/controls/trait-resourceproviderimplext/)
- [`FerroObjectImplExt`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimplext/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- [`Receiver`](/docs/0.5.0/api/ferroui-system/task/oneshot/struct-receiver/)
- `Any`
- `ErasedDestructor`
- `IntoEither`
- `Deref`
- [`Upcast<T>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`Upcast<ResourceProvider>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`StaticType`](/docs/0.5.0/api/ferroui-base/trait-statictype/)
- [`ObjectType`](/docs/0.5.0/api/ferroui-base/trait-objecttype/)
- [`Subclassable<T>`](/docs/0.5.0/api/ferroui-base/trait-subclassable/)
- [`FerroObjectImpl`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimpl/)
- [`ResourceProviderImpl`](/docs/0.5.0/api/ferroui-base/controls/trait-resourceproviderimpl/)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
