type_registry/logical/
type_info.rs

1use std::any::Any;
2
3/// Information that describes a type registered in a [registry](crate::logical::Registry).
4pub trait TypeInfo: Any + Sync {
5    fn as_any(&self) -> &(dyn Any + Sync);
6}
7
8// Blanket implementation for all Sized TypeInfo types to convert to a &(dyn Any + Sync). This 
9// leaves the possibility of other implementations for other types T: TypeInfo + ?Sized, but as the
10// Registry trait requires Self::TypeInfo: TypeInfo + Sized, these other implementations cannot
11// be used with this crate. The notable exception being dyn TypeInfo, but its implementation is
12// deferring to this one as required.
13
14impl<T: Any + Sync> TypeInfo for T {
15    fn as_any(&self) -> &(dyn Any + Sync) {
16        self
17    }
18}