summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMinijackson <minijackson@riseup.net>2020-01-12 13:30:44 +0100
committerMinijackson <minijackson@riseup.net>2020-01-12 13:30:44 +0100
commit9fb109c5cd72348fb6e0cde151a54866cbcf14bf (patch)
tree71ec9e2d0f06b46494ca7fc72912e7164b022557
parent5d6f163000bf34d12ec9587b2d8572319d27607d (diff)
downloadposeidoc-9fb109c5cd72348fb6e0cde151a54866cbcf14bf.tar.gz
poseidoc-9fb109c5cd72348fb6e0cde151a54866cbcf14bf.zip
Make most public types non exhaustive
-rw-r--r--src/types.rs12
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 @@
1use serde_derive::{Serialize, Deserialize}; 1use serde_derive::{Deserialize, Serialize};
2use thiserror::Error; 2use thiserror::Error;
3 3
4use std::collections::BTreeMap; 4use std::collections::BTreeMap;
5use std::str::FromStr; 5use 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]
8pub struct Poseidoc { 12pub 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]
14pub struct Entity { 19pub 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]
30pub enum Language { 36pub 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")]
68pub struct LanguageParseError(()); 74pub 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)]
72pub struct EntityKind(pub String); 80pub 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)]
78pub struct ChildrenKind(pub String); 86pub struct ChildrenKind(pub String);