use std::collections::HashMap;
#[derive(Debug, PartialEq, Eq, Hash)]
pub enum BuiltInType {
Binary, Bits, Boolean, Decimal64, Empty, Enumeration, IdentityRef, InstanceIdentifier, Int8, Int16, Int32, Int64, LeafRef, String, UInt8, UInt16, UInt32, UInt64, Union }
#[derive(Debug, PartialEq, Eq, Hash)]
pub enum NodeType
{
LeafNode,
LeafListNode,
ContainerNode,
ListNode,
ModuleNode
}
pub fn built_in_type_mapping<'a>() -> HashMap<BuiltInType, &'a str>
{
HashMap::from([
(BuiltInType::Binary, "binary"),
(BuiltInType::Bits, "bits"),
(BuiltInType::Boolean, "boolean"),
(BuiltInType::Decimal64, "decimal64"),
(BuiltInType::Empty, "empty"),
(BuiltInType::Enumeration, "enumeration"),
(BuiltInType::IdentityRef, "identityref"),
(BuiltInType::InstanceIdentifier, "instance-identifier"),
(BuiltInType::Int8, "int8"),
(BuiltInType::Int16, "int16"),
(BuiltInType::Int32, "int32"),
(BuiltInType::Int64, "int64"),
(BuiltInType::LeafRef, "leafref"),
(BuiltInType::String, "string"),
(BuiltInType::UInt8, "uint8"),
(BuiltInType::UInt16, "uint16"),
(BuiltInType::UInt32, "uint32"),
(BuiltInType::UInt64, "uint64"),
(BuiltInType::Union, "union")
])
}
pub fn node_type_mapping<'a>() -> HashMap<NodeType, &'a str>
{
HashMap::from([
(NodeType::LeafNode, "leaf"),
(NodeType::LeafListNode, "leaf-list"),
(NodeType::ContainerNode, "container"),
(NodeType::ModuleNode, "module"),
(NodeType::ListNode, "list")
])
}
pub fn node_serde_mapping<'a>() -> HashMap<NodeType, &'a str>
{
HashMap::from([
(NodeType::LeafNode, "leaf--"),
(NodeType::LeafListNode, "leaf-list--"),
(NodeType::ContainerNode, "container--"),
(NodeType::ModuleNode, "module--"),
(NodeType::ListNode, "list--")
])
}
pub fn get_built_in_type_str<'a>(built_in: BuiltInType) -> &'a str{
built_in_type_mapping()[&built_in]
}