//! Key types and functions for creating actions, components, packages, and themes. use crate::util::TypeInfo; use std::any::Any; // Common definitions for core types. pub trait AnyBase: Any { fn type_name(&self) -> &'static str; fn short_name(&self) -> &'static str; fn as_any_ref(&self) -> &dyn Any; fn as_any_mut(&mut self) -> &mut dyn Any; } impl AnyBase for T { #[inline(always)] fn type_name(&self) -> &'static str { TypeInfo::FullName.of::() } #[inline(always)] fn short_name(&self) -> &'static str { TypeInfo::ShortName.of::() } #[inline(always)] fn as_any_ref(&self) -> &dyn Any { self } #[inline(always)] fn as_any_mut(&mut self) -> &mut dyn Any { self } } pub trait AnyTo: AnyBase { #[inline] fn is(&self) -> bool where T: AnyBase, { self.as_any_ref().is::() } #[inline] fn downcast_ref(&self) -> Option<&T> where T: AnyBase, { self.as_any_ref().downcast_ref() } #[inline] fn downcast_mut(&mut self) -> Option<&mut T> where T: AnyBase, { self.as_any_mut().downcast_mut() } } impl AnyTo for T {} // API to define functions that alter the behavior of PageTop core. pub mod action; // API to build new components. pub mod component; // API to add new features with packages. pub mod package; // API to add new layouts with themes. pub mod theme;