PageType
struct · ferroui-controls · v0.5.0
struct PageType
The type of a page a Frame navigates to (WinUI's SourcePageType): the
identity of a class deriving from 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.
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).
Members
of
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!).
for_factory
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.
from_type_info
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
identity
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).
name
fn name(self: &Self) -> &'static str
The name of the class, without namespace.
is
fn is<T: ObjectType>(self: &Self) -> bool
Whether this is the page type of the class T.
is_assignable_from
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.
create
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.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedToStringResourceKeyObjectPropertyValueAnyValueClassDefaultsErasedDestructorIntoEitherValueTypeRegistrationCloneCopyFrom<&'static TypeInfo>PartialEqEqHashDebugDisplay
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.