diff options
author | Minijackson <minijackson@riseup.net> | 2020-01-12 13:30:44 +0100 |
---|---|---|
committer | Minijackson <minijackson@riseup.net> | 2020-01-12 13:30:44 +0100 |
commit | 9fb109c5cd72348fb6e0cde151a54866cbcf14bf (patch) | |
tree | 71ec9e2d0f06b46494ca7fc72912e7164b022557 | |
parent | 5d6f163000bf34d12ec9587b2d8572319d27607d (diff) | |
download | poseidoc-9fb109c5cd72348fb6e0cde151a54866cbcf14bf.tar.gz poseidoc-9fb109c5cd72348fb6e0cde151a54866cbcf14bf.zip |
Make most public types non exhaustive
-rw-r--r-- | src/types.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/types.rs b/src/types.rs index d192ab5..1cd1b57 100644 --- a/src/types.rs +++ b/src/types.rs | |||
@@ -1,16 +1,21 @@ | |||
1 | use serde_derive::{Serialize, Deserialize}; | 1 | use serde_derive::{Deserialize, Serialize}; |
2 | use thiserror::Error; | 2 | use thiserror::Error; |
3 | 3 | ||
4 | use std::collections::BTreeMap; | 4 | use std::collections::BTreeMap; |
5 | use std::str::FromStr; | 5 | use std::str::FromStr; |
6 | 6 | ||
7 | // TODO: maybe not public attributes after all, we want to be able to add attributes in the future. | ||
8 | // Maybe use the builder pattern? | ||
9 | |||
7 | #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] | 10 | #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] |
11 | #[non_exhaustive] | ||
8 | pub struct Poseidoc { | 12 | pub struct Poseidoc { |
9 | pub config: toml::Value, | 13 | pub config: toml::Value, |
10 | pub entities: BTreeMap<String, Entity>, | 14 | pub entities: BTreeMap<String, Entity>, |
11 | } | 15 | } |
12 | 16 | ||
13 | #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] | 17 | #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] |
18 | #[non_exhaustive] | ||
14 | pub struct Entity { | 19 | pub struct Entity { |
15 | pub name: String, | 20 | pub name: String, |
16 | //location: SourceLocation | 21 | //location: SourceLocation |
@@ -27,6 +32,7 @@ pub type Children = BTreeMap<ChildrenKind, BTreeMap<EntityId, Entity>>; | |||
27 | 32 | ||
28 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] | 33 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] |
29 | #[serde(try_from = "&str", into = "&'static str")] | 34 | #[serde(try_from = "&str", into = "&'static str")] |
35 | #[non_exhaustive] | ||
30 | pub enum Language { | 36 | pub enum Language { |
31 | Clang, | 37 | Clang, |
32 | } | 38 | } |
@@ -67,12 +73,14 @@ impl From<Language> for &'static str { | |||
67 | #[error("invalid language")] | 73 | #[error("invalid language")] |
68 | pub struct LanguageParseError(()); | 74 | pub struct LanguageParseError(()); |
69 | 75 | ||
76 | // TODO: maybe provide methods instead of struct with public member for NewTypes | ||
77 | |||
70 | #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] | 78 | #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] |
71 | #[serde(transparent)] | 79 | #[serde(transparent)] |
72 | pub struct EntityKind(pub String); | 80 | pub struct EntityKind(pub String); |
73 | 81 | ||
74 | // Plural version of EntityKind | ||
75 | 82 | ||
83 | /// Plural version of EntityKind | ||
76 | #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] | 84 | #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] |
77 | #[serde(transparent)] | 85 | #[serde(transparent)] |
78 | pub struct ChildrenKind(pub String); | 86 | pub struct ChildrenKind(pub String); |