monstermaker_core/lib.rs
1#![deny(missing_docs)]
2
3//! Core traits for the Monster Maker ecosystem.
4//!
5//! This crate provides shared traits for types in the Monster Maker
6//! ecosystem. Composition of these traits allows for custom types that
7//! can be used across other crates in the Monster Maker ecosystem
8//! (both official and third-party).
9
10/// A named type.
11///
12/// A type can implement this trait to provide a name, possibly defined
13/// internally in the type. For example:
14///
15/// ```
16/// use monstermaker_core::Name;
17///
18/// struct Foo {
19/// name: &'static str,
20/// }
21///
22/// impl Name for Foo {
23/// fn name(&self) -> &str {
24/// self.name
25/// }
26/// }
27/// ```
28pub trait Name {
29 /// Returns the object's name.
30 fn name(&self) -> &str;
31}
32
33/// An identified type.
34///
35/// A type can implement this trait to provide an id, possibly defined
36/// interally in the type. For example:
37///
38/// ```
39/// use monstermaker_core::Id;
40///
41/// struct Foo {
42/// id: u16,
43/// }
44///
45/// impl Id for Foo {
46/// fn id(&self) -> u16 {
47/// self.id
48/// }
49/// }
50/// ```
51pub trait Id {
52 /// Returns the object's id.
53 fn id(&self) -> u16;
54}