# TemplatePartAttribute

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-controls/metadata/struct-templatepartattribute/

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

```rust
struct TemplatePartAttribute
```

Declares that a templated control expects a named part of a given type
in its control template.

Classes expose their parts through a `template_parts()` function.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/metadata/template_part_attribute.rs#L8)

## Members

- [`name`](#struct_field-name)
- [`type_`](#struct_field-type_)
- [`is_required`](#struct_field-is_required)
- [`new`](#function-new)
- [`required`](#function-required)

<a id="struct_field-name"></a>

### name

```rust
name: &'static str
```

The pre-defined name of the part.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/metadata/template_part_attribute.rs#L10)

<a id="struct_field-type_"></a>

### type_

```rust
type_: &'static ferroui_base::TypeInfo
```

The type of the named part: the part is of this class or a class
derived from it.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/metadata/template_part_attribute.rs#L13)

<a id="struct_field-is_required"></a>

### is_required

```rust
is_required: bool
```

Whether the part is required to be present in the template. A
required part not found in the template is an error.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/metadata/template_part_attribute.rs#L16)

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

### new

```rust
const fn new(name: &'static str, type_: &'static TypeInfo) -> Self
```

Declares an optional part.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/metadata/template_part_attribute.rs#L21)

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

### required

```rust
const fn required(name: &'static str, type_: &'static TypeInfo) -> Self
```

Declares a required part.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/metadata/template_part_attribute.rs#L26)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- [`PropertyValue`](/docs/0.5.0/api/ferroui-base/trait-propertyvalue/)
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`
- `Clone`
- `Copy`
- `Debug`
- `StructuralPartialEq`
- `PartialEq`
- `Eq`

## Availability

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