From 9fb109c5cd72348fb6e0cde151a54866cbcf14bf Mon Sep 17 00:00:00 2001 From: Minijackson Date: Sun, 12 Jan 2020 13:30:44 +0100 Subject: Make most public types non exhaustive --- src/types.rs | 12 ++++++++++-- 1 file 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 @@ -use serde_derive::{Serialize, Deserialize}; +use serde_derive::{Deserialize, Serialize}; use thiserror::Error; use std::collections::BTreeMap; use std::str::FromStr; +// TODO: maybe not public attributes after all, we want to be able to add attributes in the future. +// Maybe use the builder pattern? + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[non_exhaustive] pub struct Poseidoc { pub config: toml::Value, pub entities: BTreeMap, } #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[non_exhaustive] pub struct Entity { pub name: String, //location: SourceLocation @@ -27,6 +32,7 @@ pub type Children = BTreeMap>; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] #[serde(try_from = "&str", into = "&'static str")] +#[non_exhaustive] pub enum Language { Clang, } @@ -67,12 +73,14 @@ impl From for &'static str { #[error("invalid language")] pub struct LanguageParseError(()); +// TODO: maybe provide methods instead of struct with public member for NewTypes + #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] #[serde(transparent)] pub struct EntityKind(pub String); -// Plural version of EntityKind +/// Plural version of EntityKind #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] #[serde(transparent)] pub struct ChildrenKind(pub String); -- cgit v1.2.3