aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/src
diff options
context:
space:
mode:
Diffstat (limited to 'mingling_core/src')
-rw-r--r--mingling_core/src/lib.rs3
-rw-r--r--mingling_core/src/metadata.rs2
-rw-r--r--mingling_core/src/metadata/description.rs57
3 files changed, 62 insertions, 0 deletions
diff --git a/mingling_core/src/lib.rs b/mingling_core/src/lib.rs
index 3a5acf4..3db3d31 100644
--- a/mingling_core/src/lib.rs
+++ b/mingling_core/src/lib.rs
@@ -103,3 +103,6 @@ mod private;
pub mod __private {
pub use crate::private::*;
}
+
+/// Mingling's convention metadatas, which can be bound to types using `#[metadata]`, to provide identification for types
+pub mod metadata;
diff --git a/mingling_core/src/metadata.rs b/mingling_core/src/metadata.rs
new file mode 100644
index 0000000..329576c
--- /dev/null
+++ b/mingling_core/src/metadata.rs
@@ -0,0 +1,2 @@
+mod description;
+pub use description::*;
diff --git a/mingling_core/src/metadata/description.rs b/mingling_core/src/metadata/description.rs
new file mode 100644
index 0000000..48bf095
--- /dev/null
+++ b/mingling_core/src/metadata/description.rs
@@ -0,0 +1,57 @@
+/// Provides a description for any Grouped type.
+pub struct Description {
+ desc: String,
+}
+
+impl Description {
+ /// Creates a new `Description` instance.
+ pub fn new<S: Into<String>>(desc: S) -> Self {
+ Self { desc: desc.into() }
+ }
+}
+
+impl From<String> for Description {
+ fn from(desc: String) -> Self {
+ Self { desc }
+ }
+}
+
+impl From<&str> for Description {
+ fn from(desc: &str) -> Self {
+ Self {
+ desc: desc.to_string(),
+ }
+ }
+}
+
+impl From<Description> for String {
+ fn from(desc: Description) -> Self {
+ desc.desc
+ }
+}
+
+impl From<&Description> for String {
+ fn from(desc: &Description) -> Self {
+ desc.desc.clone()
+ }
+}
+
+impl std::ops::Deref for Description {
+ type Target = str;
+
+ fn deref(&self) -> &Self::Target {
+ &self.desc
+ }
+}
+
+impl std::ops::DerefMut for Description {
+ fn deref_mut(&mut self) -> &mut Self::Target {
+ &mut self.desc
+ }
+}
+
+impl std::fmt::Display for Description {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(f, "{}", self.desc)
+ }
+}