1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
//! Provides generic datatypes used across multiple Tinychain sub-crates. //! //! This library is a part of Tinychain: [http://github.com/haydnv/tinychain](http://github.com/haydnv/tinychain) use std::fmt; pub mod id; pub mod map; pub mod time; pub mod tuple; pub use id::*; pub use map::*; pub use time::*; pub use tuple::*; /// A generic class trait pub trait Class: fmt::Display + Sized { /// The [`Instance`] type of this class. type Instance; } /// A generic native (i.e. implemented in Rust) class trait pub trait NativeClass: Class { /// Given a fully qualified path, return this class, or a subclass. /// /// Example: /// ```no_run /// assert_eq!( /// Number::from_path("/state/scalar/value/number/int/32"), /// NumberType::Int(IntType::I32)); /// ``` fn from_path(path: &[PathSegment]) -> Option<Self>; /// Returns the fully-qualified path of this class. fn path(&self) -> TCPathBuf; } /// A generic instance trait pub trait Instance: Send + Sync { /// The [`Class`] type of this instance type Class: Class; /// Returns the [`Class]` of this instance. fn class(&self) -> Self::Class; }