pub unsafe trait IsClassFor: Sized + 'static {
type Instance: ObjectType;
// Provided methods
fn get_type(&self) -> Type { ... }
fn upcast_ref<U: IsClassFor>(&self) -> &U
where Self::Instance: IsA<U::Instance>,
U::Instance: ObjectType { ... }
fn upcast_ref_mut<U: IsClassFor>(&mut self) -> &mut U
where Self::Instance: IsA<U::Instance>,
U::Instance: ObjectType { ... }
fn downcast_ref<U: IsClassFor>(&self) -> Option<&U>
where U::Instance: IsA<Self::Instance>,
Self::Instance: ObjectType { ... }
fn downcast_ref_mut<U: IsClassFor>(&mut self) -> Option<&mut U>
where U::Instance: IsA<Self::Instance>,
Self::Instance: ObjectType { ... }
fn from_type(type_: Type) -> Option<ClassRef<Self>> { ... }
}
Expand description
Trait for mapping a class struct type to its corresponding instance type.
Required Associated Types§
Sourcetype Instance: ObjectType
type Instance: ObjectType
Corresponding Rust instance type for this class.
Provided Methods§
Sourcefn upcast_ref<U: IsClassFor>(&self) -> &U
fn upcast_ref<U: IsClassFor>(&self) -> &U
Casts this class to a reference to a parent type’s class.
Sourcefn upcast_ref_mut<U: IsClassFor>(&mut self) -> &mut U
fn upcast_ref_mut<U: IsClassFor>(&mut self) -> &mut U
Casts this class to a mutable reference to a parent type’s class.
Sourcefn downcast_ref<U: IsClassFor>(&self) -> Option<&U>
fn downcast_ref<U: IsClassFor>(&self) -> Option<&U>
Casts this class to a reference to a child type’s class or fails if this class is not implementing the child class.
Sourcefn downcast_ref_mut<U: IsClassFor>(&mut self) -> Option<&mut U>
fn downcast_ref_mut<U: IsClassFor>(&mut self) -> Option<&mut U>
Casts this class to a mutable reference to a child type’s class or fails if this class is not implementing the child class.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.