1use crate::CamelCaseString;
2use codama_errors::CodamaResult;
3use std::fmt::Debug;
4
5pub trait NodeTrait:
6 HasKind + Debug + PartialEq + Clone + serde::Serialize + for<'de> serde::Deserialize<'de>
7{
8 const KIND: &'static str;
9
10 fn to_json(&self) -> CodamaResult<String> {
11 serde_json::to_string(&self).map_err(Into::into)
12 }
13
14 fn to_json_pretty(&self) -> CodamaResult<String> {
15 serde_json::to_string_pretty(&self).map_err(Into::into)
16 }
17
18 fn from_json(json: &str) -> CodamaResult<Self> {
19 serde_json::from_str(json).map_err(Into::into)
20 }
21}
22
23pub trait NodeUnionTrait:
24 HasKind + Debug + PartialEq + Clone + serde::Serialize + for<'de> serde::Deserialize<'de>
25{
26}
27
28pub trait HasKind {
29 fn kind(&self) -> &'static str;
30}
31
32pub trait HasName {
33 fn name(&self) -> &CamelCaseString;
34}