scsys_core/traits/appellation.rs
1/*
2 Appellation: appellation <module>
3 Contrib: FL03 <jo3mccain@icloud.com>
4*/
5use crate::id::Identifier;
6use crate::traits::Classifier;
7
8/// An appellation is considered to be a name or title that is used to identify an object.
9/// For our purposes, an `Appellation` is a type that is used to identify an object in a computational space.
10/// The appellation outlines a notation that combines an idenfifier, classifier, and name into a single unique
11/// identifier for an object.
12pub trait Appellation {
13 type Class: Classifier;
14 type Id: Identifier;
15
16 fn class(&self) -> &Self::Class;
17
18 fn id(&self) -> &Self::Id;
19
20 fn name(&self) -> &str;
21}
22
23/*
24 ************* Implementations *************
25*/
26impl<Cls, Id, T> Appellation for (Cls, Id, T)
27where
28 Cls: Classifier,
29 Id: Identifier,
30 T: AsRef<str>,
31{
32 type Class = Cls;
33 type Id = Id;
34
35 fn class(&self) -> &Cls {
36 &self.0
37 }
38
39 fn id(&self) -> &Id {
40 &self.1
41 }
42
43 fn name(&self) -> &str {
44 self.2.as_ref()
45 }
46}