# PageType

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

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

```rust
struct PageType
```

The type of a page a `Frame` navigates to (WinUI's `SourcePageType`): the
identity of a class deriving from [`FramePage`](/docs/0.5.0/api/ferroui-controls/struct-framepage/) and how the frame creates a page of it.

Made with `PageType::of`, which names the page class statically: the compiler checks that
the class is a page with a default constructor, and the constructor is reached through the
class, not through its `TypeInfo`, so an application links the constructors of the pages it
navigates to and no others. A page class that has no default constructor and whose pages a page
factory of the frame creates (`Frame::register_page_factory`) is named with
`PageType::for_factory`.

```ignore
frame.navigate(PageType::of::<SettingsPage>(), None)?;
```

Two page types are equal when they name the same class, whichever way they were made; the hash
follows. The conversion from a `&'static TypeInfo` (`From`, for the run-time XAML loader, the
designer and the tools) creates a page by reflection, through the default constructor of the
`TypeInfo` (`TypeInfo::default_constructor`): the one it carries with the tables of types
(the `ferroui-base` feature `type-tables`), or the one registered for the class with
`TypeInfo::register_constructor` (as compiled markup does for `{x:Type local:Page}`). Without
either the navigation fails with `NavigationError::MissingConstructor`, whose message names
`PageType::of` and the tables. The conversion stays in 0.5 for compatibility and is removed
with the other deprecated forms (#625).

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

## Members

- [`of`](#function-of)
- [`for_factory`](#function-for_factory)
- [`from_type_info`](#function-from_type_info)
- [`identity`](#function-identity)
- [`name`](#function-name)
- [`is`](#function-is)
- [`is_assignable_from`](#function-is_assignable_from)
- [`create`](#function-create)

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

### of

```rust
const fn of<T: ObjectType + DefaultConstructible + Upcast<FramePage>>() -> Self
```

The page type of the page class `T`: a class deriving from `FramePage` that declares a
default constructor (`new` of `ferro_class_info!`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/page_type.rs#L55)

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

### for_factory

```rust
const fn for_factory<T: ObjectType + Upcast<FramePage>>() -> Self
```

The page type of the page class `T` without a constructor: the pages of `T` are created
by the page factory a frame registers for it (`Frame::register_page_factory`), and a
navigation of a frame that has none fails with `NavigationError::MissingConstructor`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/page_type.rs#L62)

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

### from_type_info

```rust
const fn from_type_info(type_: &'static TypeInfo) -> Self
```

The page type of the runtime type `type_`. A page of it is created through the default
constructor of its `TypeInfo`, which builds without the type tables do not keep unless
code that names the class registers it (`TypeInfo::register_constructor`); a type that is
not a page fails when the frame navigates to it (`NavigationError::NotAPage`).

> **Deprecated since 0.5.0.** use `PageType::of::<T>()`, which reaches the constructor of the page statically

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/page_type.rs#L81)

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

### identity

```rust
fn identity(self: &Self) -> Option<&'static TypeIdentity>
```

The identity of the class (`TypeIdentity`); `None` for a runtime type that is not a class
(the conversion from a `&'static TypeInfo` of a static type).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/page_type.rs#L88)

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

### name

```rust
fn name(self: &Self) -> &'static str
```

The name of the class, without namespace.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/page_type.rs#L96)

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

### is

```rust
fn is<T: ObjectType>(self: &Self) -> bool
```

Whether this is the page type of the class `T`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/page_type.rs#L105)

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

### is_assignable_from

```rust
fn is_assignable_from(self: &Self, object_type: &'static TypeInfo) -> bool
```

Whether `object_type`, the runtime type of an object, is this class or derives from it.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/page_type.rs#L110)

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

### create

```rust
fn create(self: &Self) -> Result<Ref<FramePage>, NavigationError>
```

Creates a page of the type with its default constructor. A page type of
`PageType::of` always creates one, one of `PageType::for_factory` never does
(`NavigationError::MissingConstructor`); one converted from a runtime type fails with
`NavigationError::NotAPage` for a type that is not a page and with
`NavigationError::MissingConstructor` for a type without a default constructor.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/page_type.rs#L144)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- `ToString`
- [`ResourceKeyObject`](/docs/0.5.0/api/ferroui-base/controls/trait-resourcekeyobject/)
- [`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`
- [`ValueTypeRegistration`](/docs/0.5.0/api/ferroui-base/data/core/trait-valuetyperegistration/)
- `Clone`
- `Copy`
- `From<&'static TypeInfo>`
- `PartialEq`
- `Eq`
- `Hash`
- `Debug`
- `Display`

## Availability

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