From 58c8f8d356f5921bbce3edd316f182e85230c06f Mon Sep 17 00:00:00 2001 From: "Philip (a-0)" <@ph:a-0.me> Date: Wed, 12 Jul 2023 00:21:51 +0200 Subject: [PATCH] Added several new types --- src/v1/schemas/extended_event_list.rs | 2 +- src/v1/schemas/extended_galaxy.rs | 14 ++++ src/v1/schemas/extended_galaxy_cluster.rs | 11 ++++ src/v1/schemas/extended_object.rs | 11 ++++ src/v1/schemas/extended_tag.rs | 11 ++++ src/v1/schemas/galaxy.rs | 11 ++++ src/v1/schemas/galaxy_cluster.rs | 14 ++++ src/v1/schemas/galaxy_cluster_authors.rs | 18 +++++ src/v1/schemas/galaxy_cluster_description.rs | 43 ++++++++++++ src/v1/schemas/galaxy_cluster_id.rs | 58 ++++++++++++++++ src/v1/schemas/galaxy_cluster_no_id.rs | 11 ++++ .../schemas/galaxy_cluster_relation_list.rs | 25 +++++++ src/v1/schemas/galaxy_cluster_source.rs | 49 ++++++++++++++ src/v1/schemas/galaxy_cluster_type.rs | 49 ++++++++++++++ src/v1/schemas/galaxy_cluster_value.rs | 43 ++++++++++++ src/v1/schemas/galaxy_cluster_version.rs | 49 ++++++++++++++ src/v1/schemas/galaxy_description.rs | 43 ++++++++++++ src/v1/schemas/galaxy_element.rs | 16 +++++ src/v1/schemas/galaxy_element_id.rs | 58 ++++++++++++++++ src/v1/schemas/galaxy_element_key.rs | 49 ++++++++++++++ src/v1/schemas/galaxy_element_list.rs | 25 +++++++ src/v1/schemas/galaxy_element_value.rs | 43 ++++++++++++ src/v1/schemas/galaxy_id.rs | 58 ++++++++++++++++ src/v1/schemas/galaxy_misp_format.rs | 11 ++++ src/v1/schemas/galaxy_name.rs | 49 ++++++++++++++ src/v1/schemas/galaxy_namespace.rs | 49 ++++++++++++++ src/v1/schemas/galaxy_type.rs | 49 ++++++++++++++ src/v1/schemas/galaxy_value_search_filter.rs | 18 +++++ src/v1/schemas/galaxy_version.rs | 49 ++++++++++++++ src/v1/schemas/hide_tag_flag.rs | 13 ++++ src/v1/schemas/import_galaxy_cluster_item.rs | 14 ++++ src/v1/schemas/mod.rs | 42 ++++++++++++ src/v1/schemas/object_rest_search_filter.rs | 12 ++++ src/v1/schemas/object_rest_search_list.rs | 25 +++++++ src/v1/schemas/object_template_id.rs | 52 +++++++++++++++ src/v1/schemas/sighting.rs | 11 ++++ src/v1/schemas/sighting_id.rs | 58 ++++++++++++++++ src/v1/schemas/tag.rs | 16 +++++ src/v1/schemas/tag_collection_id.rs | 58 ++++++++++++++++ src/v1/schemas/tag_colour.rs | 49 ++++++++++++++ src/v1/schemas/tag_id.rs | 58 ++++++++++++++++ src/v1/schemas/tag_list.rs | 25 +++++++ src/v1/schemas/tag_name.rs | 49 ++++++++++++++ src/v1/schemas/tag_no_id.rs | 13 ++++ src/v1/schemas/tag_numerical_value.rs | 66 +++++++++++++++++++ 45 files changed, 1496 insertions(+), 1 deletion(-) create mode 100644 src/v1/schemas/extended_galaxy.rs create mode 100644 src/v1/schemas/extended_galaxy_cluster.rs create mode 100644 src/v1/schemas/extended_object.rs create mode 100644 src/v1/schemas/extended_tag.rs create mode 100644 src/v1/schemas/galaxy.rs create mode 100644 src/v1/schemas/galaxy_cluster.rs create mode 100644 src/v1/schemas/galaxy_cluster_authors.rs create mode 100644 src/v1/schemas/galaxy_cluster_description.rs create mode 100644 src/v1/schemas/galaxy_cluster_id.rs create mode 100644 src/v1/schemas/galaxy_cluster_no_id.rs create mode 100644 src/v1/schemas/galaxy_cluster_relation_list.rs create mode 100644 src/v1/schemas/galaxy_cluster_source.rs create mode 100644 src/v1/schemas/galaxy_cluster_type.rs create mode 100644 src/v1/schemas/galaxy_cluster_value.rs create mode 100644 src/v1/schemas/galaxy_cluster_version.rs create mode 100644 src/v1/schemas/galaxy_description.rs create mode 100644 src/v1/schemas/galaxy_element.rs create mode 100644 src/v1/schemas/galaxy_element_id.rs create mode 100644 src/v1/schemas/galaxy_element_key.rs create mode 100644 src/v1/schemas/galaxy_element_list.rs create mode 100644 src/v1/schemas/galaxy_element_value.rs create mode 100644 src/v1/schemas/galaxy_id.rs create mode 100644 src/v1/schemas/galaxy_misp_format.rs create mode 100644 src/v1/schemas/galaxy_name.rs create mode 100644 src/v1/schemas/galaxy_namespace.rs create mode 100644 src/v1/schemas/galaxy_type.rs create mode 100644 src/v1/schemas/galaxy_value_search_filter.rs create mode 100644 src/v1/schemas/galaxy_version.rs create mode 100644 src/v1/schemas/hide_tag_flag.rs create mode 100644 src/v1/schemas/import_galaxy_cluster_item.rs create mode 100644 src/v1/schemas/object_rest_search_filter.rs create mode 100644 src/v1/schemas/object_rest_search_list.rs create mode 100644 src/v1/schemas/object_template_id.rs create mode 100644 src/v1/schemas/sighting.rs create mode 100644 src/v1/schemas/sighting_id.rs create mode 100644 src/v1/schemas/tag.rs create mode 100644 src/v1/schemas/tag_collection_id.rs create mode 100644 src/v1/schemas/tag_colour.rs create mode 100644 src/v1/schemas/tag_id.rs create mode 100644 src/v1/schemas/tag_list.rs create mode 100644 src/v1/schemas/tag_name.rs create mode 100644 src/v1/schemas/tag_no_id.rs create mode 100644 src/v1/schemas/tag_numerical_value.rs diff --git a/src/v1/schemas/extended_event_list.rs b/src/v1/schemas/extended_event_list.rs index 4cc9ef2..8a2546e 100644 --- a/src/v1/schemas/extended_event_list.rs +++ b/src/v1/schemas/extended_event_list.rs @@ -1,4 +1,4 @@ -use super::{ExtendedEvent}; +use super::ExtendedEvent; default_derive!{ pub struct ExtendedEventList { diff --git a/src/v1/schemas/extended_galaxy.rs b/src/v1/schemas/extended_galaxy.rs new file mode 100644 index 0000000..ae9c3f8 --- /dev/null +++ b/src/v1/schemas/extended_galaxy.rs @@ -0,0 +1,14 @@ +use super::{Galaxy, GalaxyCluster}; + + +default_derive!{ + pub struct ExtendedGalaxy { + galaxy: Galaxy, + galaxy_cluster: GalaxyCluster, + } +} + +#[test] +fn valid1() { + todo!() +} \ No newline at end of file diff --git a/src/v1/schemas/extended_galaxy_cluster.rs b/src/v1/schemas/extended_galaxy_cluster.rs new file mode 100644 index 0000000..329e736 --- /dev/null +++ b/src/v1/schemas/extended_galaxy_cluster.rs @@ -0,0 +1,11 @@ + +default_derive!{ + pub struct ExtendedGalaxyCluster { + //TODO + } +} + +#[test] +fn valid1() { + todo!() +} \ No newline at end of file diff --git a/src/v1/schemas/extended_object.rs b/src/v1/schemas/extended_object.rs new file mode 100644 index 0000000..50d7487 --- /dev/null +++ b/src/v1/schemas/extended_object.rs @@ -0,0 +1,11 @@ + +default_derive!{ + pub struct ExtendedObject { + //TODO + } +} + +#[test] +fn valid1() { + todo!() +} \ No newline at end of file diff --git a/src/v1/schemas/extended_tag.rs b/src/v1/schemas/extended_tag.rs new file mode 100644 index 0000000..e0c9caf --- /dev/null +++ b/src/v1/schemas/extended_tag.rs @@ -0,0 +1,11 @@ + +default_derive!{ + pub struct ExtendedTag { + //TODO + } +} + +#[test] +fn valid1() { + todo!() +} \ No newline at end of file diff --git a/src/v1/schemas/galaxy.rs b/src/v1/schemas/galaxy.rs new file mode 100644 index 0000000..b7641e9 --- /dev/null +++ b/src/v1/schemas/galaxy.rs @@ -0,0 +1,11 @@ + +default_derive!{ + pub struct Galaxy { + //TODO + } +} + +#[test] +fn valid1() { + todo!() +} \ No newline at end of file diff --git a/src/v1/schemas/galaxy_cluster.rs b/src/v1/schemas/galaxy_cluster.rs new file mode 100644 index 0000000..7649c1a --- /dev/null +++ b/src/v1/schemas/galaxy_cluster.rs @@ -0,0 +1,14 @@ +use super::{GalaxyClusterId, GalaxyClusterWithoutId}; + + +default_derive!{ + pub struct GalaxyCluster { + id: GalaxyClusterId, + attrs: GalaxyClusterWithoutId, + } +} + +#[test] +fn valid1() { + todo!() +} \ No newline at end of file diff --git a/src/v1/schemas/galaxy_cluster_authors.rs b/src/v1/schemas/galaxy_cluster_authors.rs new file mode 100644 index 0000000..c2d754f --- /dev/null +++ b/src/v1/schemas/galaxy_cluster_authors.rs @@ -0,0 +1,18 @@ + +default_derive!{ + pub struct GalaxyClusterAuthors { + authors: String + } +} + +impl From<&str> for GalaxyClusterAuthors { + fn from(value: &str) -> Self { + GalaxyClusterAuthors { authors: value.to_string() } + } +} + +impl Into for GalaxyClusterAuthors { + fn into(self) -> String { + self.authors + } +} diff --git a/src/v1/schemas/galaxy_cluster_description.rs b/src/v1/schemas/galaxy_cluster_description.rs new file mode 100644 index 0000000..2aab9ce --- /dev/null +++ b/src/v1/schemas/galaxy_cluster_description.rs @@ -0,0 +1,43 @@ + +default_derive!{ + pub struct GalaxyClusterDescription { + name: String + } +} + +impl TryFrom<&str> for GalaxyClusterDescription { + type Error = &'static str; + + fn try_from(value: &str) -> Result { + if value.len() > 0 && value.len() <= 65535 { + Ok(GalaxyClusterDescription { name: value.to_string() }) + } + else { + Err("Failed to parse GalaxyClusterDescription") + } + } +} + +impl Into for GalaxyClusterDescription { + fn into(self) -> String { + self.name + } +} + +#[test] +fn oversized() { + let id: Result = format!("{:>65536}", "Test").as_str().try_into(); + assert!(id.is_err()) +} + +#[test] +fn valid1() { + let id: Result = "".try_into(); + assert_eq!(id, Ok(GalaxyClusterDescription { name: "".to_string() })) +} + +#[test] +fn valid2() { + let id: Result = "some super long description".try_into(); + assert_eq!(id, Ok(GalaxyClusterDescription { name: "some super long description".to_string() })) +} \ No newline at end of file diff --git a/src/v1/schemas/galaxy_cluster_id.rs b/src/v1/schemas/galaxy_cluster_id.rs new file mode 100644 index 0000000..2114c7e --- /dev/null +++ b/src/v1/schemas/galaxy_cluster_id.rs @@ -0,0 +1,58 @@ +use regex_macro::regex; + + +default_derive!{ + pub struct GalaxyClusterId { + id: String + } +} + +impl TryFrom<&str> for GalaxyClusterId { + type Error = &'static str; + + fn try_from(value: &str) -> Result { + let re = regex!("^[[:digit:]]+$"); + if value.len() <= 10 && re.is_match(value) { + Ok(GalaxyClusterId { id: value.to_string() }) + } + else { + Err("Failed to parse GalaxyClusterId") + } + } +} + +impl Into for GalaxyClusterId { + fn into(self) -> String { + self.id + } +} + +#[test] +fn empty() { + let id: Result = "".try_into(); + assert!(id.is_err()) +} + +#[test] +fn oversized() { + let id: Result = "12345678910".try_into(); + assert!(id.is_err()) +} + +#[test] +fn forbidden_char() { + let id: Result = "1954a".try_into(); + assert!(id.is_err()) +} + +#[test] +fn valid1() { + let id: Result = "12345".try_into(); + assert_eq!(id, Ok(GalaxyClusterId { id: "12345".to_string() })) +} + +#[test] +fn valid2() { + let id: Result = "0123456789".try_into(); + assert_eq!(id, Ok(GalaxyClusterId { id: "0123456789".to_string() })) +} \ No newline at end of file diff --git a/src/v1/schemas/galaxy_cluster_no_id.rs b/src/v1/schemas/galaxy_cluster_no_id.rs new file mode 100644 index 0000000..adb0d9a --- /dev/null +++ b/src/v1/schemas/galaxy_cluster_no_id.rs @@ -0,0 +1,11 @@ + +default_derive!{ + pub struct GalaxyClusterWithoutId { + //TODO + } +} + +#[test] +fn valid1() { + todo!() +} \ No newline at end of file diff --git a/src/v1/schemas/galaxy_cluster_relation_list.rs b/src/v1/schemas/galaxy_cluster_relation_list.rs new file mode 100644 index 0000000..ce58130 --- /dev/null +++ b/src/v1/schemas/galaxy_cluster_relation_list.rs @@ -0,0 +1,25 @@ +use super::GalaxyElement; + + +default_derive!{ + pub struct GalaxyClusterRelationList { + elements: Vec + } +} + +impl From> for GalaxyClusterRelationList { + fn from(value: Vec) -> Self { + GalaxyClusterRelationList { elements: value } + } +} + +impl Into> for GalaxyClusterRelationList { + fn into(self) -> Vec { + self.elements + } +} + +#[test] +fn valid1() { + todo!() +} \ No newline at end of file diff --git a/src/v1/schemas/galaxy_cluster_source.rs b/src/v1/schemas/galaxy_cluster_source.rs new file mode 100644 index 0000000..b5e8dba --- /dev/null +++ b/src/v1/schemas/galaxy_cluster_source.rs @@ -0,0 +1,49 @@ + +default_derive!{ + pub struct GalaxyClusterSource { + name: String + } +} + +impl TryFrom<&str> for GalaxyClusterSource { + type Error = &'static str; + + fn try_from(value: &str) -> Result { + if value.len() > 0 && value.len() <= 255 { + Ok(GalaxyClusterSource { name: value.to_string() }) + } + else { + Err("Failed to parse GalaxyClusterSource") + } + } +} + +impl Into for GalaxyClusterSource { + fn into(self) -> String { + self.name + } +} + +#[test] +fn empty() { + let id: Result = "".try_into(); + assert!(id.is_err()) +} + +#[test] +fn oversized() { + let id: Result = format!("{:>256}", "Test").as_str().try_into(); + assert!(id.is_err()) +} + +#[test] +fn valid1() { + let id: Result = "version".try_into(); + assert_eq!(id, Ok(GalaxyClusterSource { name: "version".to_string() })) +} + +#[test] +fn valid2() { + let id: Result = "1234".try_into(); + assert_eq!(id, Ok(GalaxyClusterSource { name: "1234".to_string() })) +} \ No newline at end of file diff --git a/src/v1/schemas/galaxy_cluster_type.rs b/src/v1/schemas/galaxy_cluster_type.rs new file mode 100644 index 0000000..040170a --- /dev/null +++ b/src/v1/schemas/galaxy_cluster_type.rs @@ -0,0 +1,49 @@ + +default_derive!{ + pub struct GalaxyClusterType { + name: String + } +} + +impl TryFrom<&str> for GalaxyClusterType { + type Error = &'static str; + + fn try_from(value: &str) -> Result { + if value.len() > 0 && value.len() <= 255 { + Ok(GalaxyClusterType { name: value.to_string() }) + } + else { + Err("Failed to parse GalaxyClusterType") + } + } +} + +impl Into for GalaxyClusterType { + fn into(self) -> String { + self.name + } +} + +#[test] +fn empty() { + let id: Result = "".try_into(); + assert!(id.is_err()) +} + +#[test] +fn oversized() { + let id: Result = format!("{:>256}", "Test").as_str().try_into(); + assert!(id.is_err()) +} + +#[test] +fn valid1() { + let id: Result = "clustertype".try_into(); + assert_eq!(id, Ok(GalaxyClusterType { name: "clustertype".to_string() })) +} + +#[test] +fn valid2() { + let id: Result = "1234".try_into(); + assert_eq!(id, Ok(GalaxyClusterType { name: "1234".to_string() })) +} \ No newline at end of file diff --git a/src/v1/schemas/galaxy_cluster_value.rs b/src/v1/schemas/galaxy_cluster_value.rs new file mode 100644 index 0000000..937c691 --- /dev/null +++ b/src/v1/schemas/galaxy_cluster_value.rs @@ -0,0 +1,43 @@ + +default_derive!{ + pub struct GalaxyClusterValue { + name: String + } +} + +impl TryFrom<&str> for GalaxyClusterValue { + type Error = &'static str; + + fn try_from(value: &str) -> Result { + if value.len() > 0 && value.len() <= 65535 { + Ok(GalaxyClusterValue { name: value.to_string() }) + } + else { + Err("Failed to parse GalaxyClusterValue") + } + } +} + +impl Into for GalaxyClusterValue { + fn into(self) -> String { + self.name + } +} + +#[test] +fn oversized() { + let id: Result = format!("{:>65536}", "Test").as_str().try_into(); + assert!(id.is_err()) +} + +#[test] +fn valid1() { + let id: Result = "".try_into(); + assert_eq!(id, Ok(GalaxyClusterValue { name: "".to_string() })) +} + +#[test] +fn valid2() { + let id: Result = "some super long value".try_into(); + assert_eq!(id, Ok(GalaxyClusterValue { name: "some super long value".to_string() })) +} \ No newline at end of file diff --git a/src/v1/schemas/galaxy_cluster_version.rs b/src/v1/schemas/galaxy_cluster_version.rs new file mode 100644 index 0000000..d86b440 --- /dev/null +++ b/src/v1/schemas/galaxy_cluster_version.rs @@ -0,0 +1,49 @@ + +default_derive!{ + pub struct GalaxyClusterVersion { + name: String + } +} + +impl TryFrom<&str> for GalaxyClusterVersion { + type Error = &'static str; + + fn try_from(value: &str) -> Result { + if value.len() > 0 && value.len() <= 255 { + Ok(GalaxyClusterVersion { name: value.to_string() }) + } + else { + Err("Failed to parse GalaxyClusterVersion") + } + } +} + +impl Into for GalaxyClusterVersion { + fn into(self) -> String { + self.name + } +} + +#[test] +fn empty() { + let id: Result = "".try_into(); + assert!(id.is_err()) +} + +#[test] +fn oversized() { + let id: Result = format!("{:>256}", "Test").as_str().try_into(); + assert!(id.is_err()) +} + +#[test] +fn valid1() { + let id: Result = "version".try_into(); + assert_eq!(id, Ok(GalaxyClusterVersion { name: "version".to_string() })) +} + +#[test] +fn valid2() { + let id: Result = "1234".try_into(); + assert_eq!(id, Ok(GalaxyClusterVersion { name: "1234".to_string() })) +} \ No newline at end of file diff --git a/src/v1/schemas/galaxy_description.rs b/src/v1/schemas/galaxy_description.rs new file mode 100644 index 0000000..ed64fcf --- /dev/null +++ b/src/v1/schemas/galaxy_description.rs @@ -0,0 +1,43 @@ + +default_derive!{ + pub struct GalaxyDescription { + name: String + } +} + +impl TryFrom<&str> for GalaxyDescription { + type Error = &'static str; + + fn try_from(value: &str) -> Result { + if value.len() > 0 && value.len() <= 65535 { + Ok(GalaxyDescription { name: value.to_string() }) + } + else { + Err("Failed to parse GalaxyDescription") + } + } +} + +impl Into for GalaxyDescription { + fn into(self) -> String { + self.name + } +} + +#[test] +fn oversized() { + let id: Result = format!("{:>65536}", "Test").as_str().try_into(); + assert!(id.is_err()) +} + +#[test] +fn valid1() { + let id: Result = "".try_into(); + assert_eq!(id, Ok(GalaxyDescription { name: "".to_string() })) +} + +#[test] +fn valid2() { + let id: Result = "some super long description".try_into(); + assert_eq!(id, Ok(GalaxyDescription { name: "some super long description".to_string() })) +} \ No newline at end of file diff --git a/src/v1/schemas/galaxy_element.rs b/src/v1/schemas/galaxy_element.rs new file mode 100644 index 0000000..fb9cb53 --- /dev/null +++ b/src/v1/schemas/galaxy_element.rs @@ -0,0 +1,16 @@ +use super::{GalaxyElementId, GalaxyClusterId, GalaxyElementKey, GalaxyElementValue}; + + +default_derive!{ + pub struct GalaxyElement { + id: GalaxyElementId, + galaxy_cluster_id: GalaxyClusterId, + key: GalaxyElementKey, + value: GalaxyElementValue + } +} + +#[test] +fn valid1() { + todo!(); +} \ No newline at end of file diff --git a/src/v1/schemas/galaxy_element_id.rs b/src/v1/schemas/galaxy_element_id.rs new file mode 100644 index 0000000..d754707 --- /dev/null +++ b/src/v1/schemas/galaxy_element_id.rs @@ -0,0 +1,58 @@ +use regex_macro::regex; + + +default_derive!{ + pub struct GalaxyElementId { + id: String + } +} + +impl TryFrom<&str> for GalaxyElementId { + type Error = &'static str; + + fn try_from(value: &str) -> Result { + let re = regex!("^[[:digit:]]+$"); + if value.len() <= 10 && re.is_match(value) { + Ok(GalaxyElementId { id: value.to_string() }) + } + else { + Err("Failed to parse GalaxyElementId") + } + } +} + +impl Into for GalaxyElementId { + fn into(self) -> String { + self.id + } +} + +#[test] +fn empty() { + let id: Result = "".try_into(); + assert!(id.is_err()) +} + +#[test] +fn oversized() { + let id: Result = "12345678910".try_into(); + assert!(id.is_err()) +} + +#[test] +fn forbidden_char() { + let id: Result = "1954a".try_into(); + assert!(id.is_err()) +} + +#[test] +fn valid1() { + let id: Result = "12345".try_into(); + assert_eq!(id, Ok(GalaxyElementId { id: "12345".to_string() })) +} + +#[test] +fn valid2() { + let id: Result = "0123456789".try_into(); + assert_eq!(id, Ok(GalaxyElementId { id: "0123456789".to_string() })) +} \ No newline at end of file diff --git a/src/v1/schemas/galaxy_element_key.rs b/src/v1/schemas/galaxy_element_key.rs new file mode 100644 index 0000000..775e9b7 --- /dev/null +++ b/src/v1/schemas/galaxy_element_key.rs @@ -0,0 +1,49 @@ + +default_derive!{ + pub struct GalaxyElementKey { + name: String + } +} + +impl TryFrom<&str> for GalaxyElementKey { + type Error = &'static str; + + fn try_from(value: &str) -> Result { + if value.len() > 0 && value.len() <= 255 { + Ok(GalaxyElementKey { name: value.to_string() }) + } + else { + Err("Failed to parse GalaxyElementKey") + } + } +} + +impl Into for GalaxyElementKey { + fn into(self) -> String { + self.name + } +} + +#[test] +fn empty() { + let id: Result = "".try_into(); + assert!(id.is_err()) +} + +#[test] +fn oversized() { + let id: Result = format!("{:>256}", "Test").as_str().try_into(); + assert!(id.is_err()) +} + +#[test] +fn valid1() { + let id: Result = "key".try_into(); + assert_eq!(id, Ok(GalaxyElementKey { name: "key".to_string() })) +} + +#[test] +fn valid2() { + let id: Result = "best-key:ever&0123456789".try_into(); + assert_eq!(id, Ok(GalaxyElementKey { name: "best-key:ever&0123456789".to_string() })) +} \ No newline at end of file diff --git a/src/v1/schemas/galaxy_element_list.rs b/src/v1/schemas/galaxy_element_list.rs new file mode 100644 index 0000000..496b292 --- /dev/null +++ b/src/v1/schemas/galaxy_element_list.rs @@ -0,0 +1,25 @@ +use super::GalaxyElement; + + +default_derive!{ + pub struct GalaxyElementList { + elements: Vec + } +} + +impl From> for GalaxyElementList { + fn from(value: Vec) -> Self { + GalaxyElementList { elements: value } + } +} + +impl Into> for GalaxyElementList { + fn into(self) -> Vec { + self.elements + } +} + +#[test] +fn valid1() { + todo!() +} \ No newline at end of file diff --git a/src/v1/schemas/galaxy_element_value.rs b/src/v1/schemas/galaxy_element_value.rs new file mode 100644 index 0000000..25bf26d --- /dev/null +++ b/src/v1/schemas/galaxy_element_value.rs @@ -0,0 +1,43 @@ + +default_derive!{ + pub struct GalaxyElementValue { + name: String + } +} + +impl TryFrom<&str> for GalaxyElementValue { + type Error = &'static str; + + fn try_from(value: &str) -> Result { + if value.len() > 0 && value.len() <= 65535 { + Ok(GalaxyElementValue { name: value.to_string() }) + } + else { + Err("Failed to parse GalaxyElementValue") + } + } +} + +impl Into for GalaxyElementValue { + fn into(self) -> String { + self.name + } +} + +#[test] +fn oversized() { + let id: Result = format!("{:>65536}", "Test").as_str().try_into(); + assert!(id.is_err()) +} + +#[test] +fn valid1() { + let id: Result = "".try_into(); + assert_eq!(id, Ok(GalaxyElementValue { name: "".to_string() })) +} + +#[test] +fn valid2() { + let id: Result = "some super long value".try_into(); + assert_eq!(id, Ok(GalaxyElementValue { name: "some super long value".to_string() })) +} \ No newline at end of file diff --git a/src/v1/schemas/galaxy_id.rs b/src/v1/schemas/galaxy_id.rs new file mode 100644 index 0000000..409f40f --- /dev/null +++ b/src/v1/schemas/galaxy_id.rs @@ -0,0 +1,58 @@ +use regex_macro::regex; + + +default_derive!{ + pub struct GalaxyId { + id: String + } +} + +impl TryFrom<&str> for GalaxyId { + type Error = &'static str; + + fn try_from(value: &str) -> Result { + let re = regex!("^[[:digit:]]+$"); + if value.len() <= 10 && re.is_match(value) { + Ok(GalaxyId { id: value.to_string() }) + } + else { + Err("Failed to parse GalaxyId") + } + } +} + +impl Into for GalaxyId { + fn into(self) -> String { + self.id + } +} + +#[test] +fn empty() { + let id: Result = "".try_into(); + assert!(id.is_err()) +} + +#[test] +fn oversized() { + let id: Result = "12345678910".try_into(); + assert!(id.is_err()) +} + +#[test] +fn forbidden_char() { + let id: Result = "1954a".try_into(); + assert!(id.is_err()) +} + +#[test] +fn valid1() { + let id: Result = "12345".try_into(); + assert_eq!(id, Ok(GalaxyId { id: "12345".to_string() })) +} + +#[test] +fn valid2() { + let id: Result = "0123456789".try_into(); + assert_eq!(id, Ok(GalaxyId { id: "0123456789".to_string() })) +} \ No newline at end of file diff --git a/src/v1/schemas/galaxy_misp_format.rs b/src/v1/schemas/galaxy_misp_format.rs new file mode 100644 index 0000000..81a34eb --- /dev/null +++ b/src/v1/schemas/galaxy_misp_format.rs @@ -0,0 +1,11 @@ + +default_derive!{ + pub struct GalaxyMispFormat { + //TODO + } +} + +#[test] +fn valid1() { + todo!() +} \ No newline at end of file diff --git a/src/v1/schemas/galaxy_name.rs b/src/v1/schemas/galaxy_name.rs new file mode 100644 index 0000000..b361cef --- /dev/null +++ b/src/v1/schemas/galaxy_name.rs @@ -0,0 +1,49 @@ + +default_derive!{ + pub struct GalaxyName { + name: String + } +} + +impl TryFrom<&str> for GalaxyName { + type Error = &'static str; + + fn try_from(value: &str) -> Result { + if value.len() > 0 && value.len() <= 255 { + Ok(GalaxyName { name: value.to_string() }) + } + else { + Err("Failed to parse GalaxyName") + } + } +} + +impl Into for GalaxyName { + fn into(self) -> String { + self.name + } +} + +#[test] +fn empty() { + let id: Result = "".try_into(); + assert!(id.is_err()) +} + +#[test] +fn oversized() { + let id: Result = format!("{:>256}", "Test").as_str().try_into(); + assert!(id.is_err()) +} + +#[test] +fn valid1() { + let id: Result = "name".try_into(); + assert_eq!(id, Ok(GalaxyName { name: "name".to_string() })) +} + +#[test] +fn valid2() { + let id: Result = "best-name:ever&0123456789".try_into(); + assert_eq!(id, Ok(GalaxyName { name: "best-name:ever&0123456789".to_string() })) +} \ No newline at end of file diff --git a/src/v1/schemas/galaxy_namespace.rs b/src/v1/schemas/galaxy_namespace.rs new file mode 100644 index 0000000..ffb21af --- /dev/null +++ b/src/v1/schemas/galaxy_namespace.rs @@ -0,0 +1,49 @@ + +default_derive!{ + pub struct GalaxyNamespace { + name: String + } +} + +impl TryFrom<&str> for GalaxyNamespace { + type Error = &'static str; + + fn try_from(value: &str) -> Result { + if value.len() > 0 && value.len() <= 255 { + Ok(GalaxyNamespace { name: value.to_string() }) + } + else { + Err("Failed to parse GalaxyNamespace") + } + } +} + +impl Into for GalaxyNamespace { + fn into(self) -> String { + self.name + } +} + +#[test] +fn empty() { + let id: Result = "".try_into(); + assert!(id.is_err()) +} + +#[test] +fn oversized() { + let id: Result = format!("{:>256}", "Test").as_str().try_into(); + assert!(id.is_err()) +} + +#[test] +fn valid1() { + let id: Result = "namespace".try_into(); + assert_eq!(id, Ok(GalaxyNamespace { name: "namespace".to_string() })) +} + +#[test] +fn valid2() { + let id: Result = "best-namespace:ever&0123456789".try_into(); + assert_eq!(id, Ok(GalaxyNamespace { name: "best-namespace:ever&0123456789".to_string() })) +} \ No newline at end of file diff --git a/src/v1/schemas/galaxy_type.rs b/src/v1/schemas/galaxy_type.rs new file mode 100644 index 0000000..21b85fb --- /dev/null +++ b/src/v1/schemas/galaxy_type.rs @@ -0,0 +1,49 @@ + +default_derive!{ + pub struct GalaxyType { + name: String + } +} + +impl TryFrom<&str> for GalaxyType { + type Error = &'static str; + + fn try_from(value: &str) -> Result { + if value.len() > 0 && value.len() <= 255 { + Ok(GalaxyType { name: value.to_string() }) + } + else { + Err("Failed to parse GalaxyType") + } + } +} + +impl Into for GalaxyType { + fn into(self) -> String { + self.name + } +} + +#[test] +fn empty() { + let id: Result = "".try_into(); + assert!(id.is_err()) +} + +#[test] +fn oversized() { + let id: Result = format!("{:>256}", "Test").as_str().try_into(); + assert!(id.is_err()) +} + +#[test] +fn valid1() { + let id: Result = "type".try_into(); + assert_eq!(id, Ok(GalaxyType { name: "type".to_string() })) +} + +#[test] +fn valid2() { + let id: Result = "best-type:ever&0123456789".try_into(); + assert_eq!(id, Ok(GalaxyType { name: "best-type:ever&0123456789".to_string() })) +} \ No newline at end of file diff --git a/src/v1/schemas/galaxy_value_search_filter.rs b/src/v1/schemas/galaxy_value_search_filter.rs new file mode 100644 index 0000000..873b47f --- /dev/null +++ b/src/v1/schemas/galaxy_value_search_filter.rs @@ -0,0 +1,18 @@ + +default_derive!{ + pub struct GalaxyValueSearchFilter { + authors: String + } +} + +impl From<&str> for GalaxyValueSearchFilter { + fn from(value: &str) -> Self { + GalaxyValueSearchFilter { authors: value.to_string() } + } +} + +impl Into for GalaxyValueSearchFilter { + fn into(self) -> String { + self.authors + } +} diff --git a/src/v1/schemas/galaxy_version.rs b/src/v1/schemas/galaxy_version.rs new file mode 100644 index 0000000..05bb7f0 --- /dev/null +++ b/src/v1/schemas/galaxy_version.rs @@ -0,0 +1,49 @@ + +default_derive!{ + pub struct GalaxyVersion { + name: String + } +} + +impl TryFrom<&str> for GalaxyVersion { + type Error = &'static str; + + fn try_from(value: &str) -> Result { + if value.len() > 0 && value.len() <= 255 { + Ok(GalaxyVersion { name: value.to_string() }) + } + else { + Err("Failed to parse GalaxyVersion") + } + } +} + +impl Into for GalaxyVersion { + fn into(self) -> String { + self.name + } +} + +#[test] +fn empty() { + let id: Result = "".try_into(); + assert!(id.is_err()) +} + +#[test] +fn oversized() { + let id: Result = format!("{:>256}", "Test").as_str().try_into(); + assert!(id.is_err()) +} + +#[test] +fn valid1() { + let id: Result = "version".try_into(); + assert_eq!(id, Ok(GalaxyVersion { name: "version".to_string() })) +} + +#[test] +fn valid2() { + let id: Result = "1234".try_into(); + assert_eq!(id, Ok(GalaxyVersion { name: "1234".to_string() })) +} \ No newline at end of file diff --git a/src/v1/schemas/hide_tag_flag.rs b/src/v1/schemas/hide_tag_flag.rs new file mode 100644 index 0000000..1dc272b --- /dev/null +++ b/src/v1/schemas/hide_tag_flag.rs @@ -0,0 +1,13 @@ + +default_derive!{ + pub struct HideTagFlag { + flag: bool + } +} + + + +#[test] +fn valid1() { + todo!(); +} \ No newline at end of file diff --git a/src/v1/schemas/import_galaxy_cluster_item.rs b/src/v1/schemas/import_galaxy_cluster_item.rs new file mode 100644 index 0000000..7aeb187 --- /dev/null +++ b/src/v1/schemas/import_galaxy_cluster_item.rs @@ -0,0 +1,14 @@ +use super::{GalaxyCluster, Galaxy}; + + +default_derive!{ + pub struct ImportGalaxyClusterItem { + galaxy_cluster: GalaxyCluster, + galaxy: Galaxy + } +} + +#[test] +fn valid1() { + todo!() +} \ No newline at end of file diff --git a/src/v1/schemas/mod.rs b/src/v1/schemas/mod.rs index 70062cf..b451ef2 100644 --- a/src/v1/schemas/mod.rs +++ b/src/v1/schemas/mod.rs @@ -36,17 +36,59 @@ expose_submodules!( extended_attribute, extended_event_list, extended_event, + extended_galaxy_cluster, + extended_galaxy, + extended_object, + extended_tag, full_decaying_model, + galaxy_cluster_authors, + galaxy_cluster_description, + galaxy_cluster_id, + galaxy_cluster_no_id, + galaxy_cluster_relation_list, + galaxy_cluster_source, + galaxy_cluster_value, + galaxy_cluster_version, + galaxy_cluster, + galaxy_description, + galaxy_element_id, + galaxy_element_key, + galaxy_element_list, + galaxy_element_value, + galaxy_element, + galaxy_id, + galaxy_misp_format, + galaxy_name, + galaxy_namespace, + galaxy_type, + galaxy_value_search_filter, + galaxy_version, + galaxy, + hide_tag_flag, + import_galaxy_cluster_item, nullable_object_relation, object_description, object_id, object_meta_category, object_name, object_relation, + object_rest_search_filter, + object_rest_search_list, + object_template_id, object_template_version, object, + sighting_id, + sighting, slim_event_list, slim_event, + tag_collection_id, + tag_colour, + tag_id, + tag_list, + tag_name, + tag_no_id, + tag_numerical_value, + tag, updated_event, uuid ); \ No newline at end of file diff --git a/src/v1/schemas/object_rest_search_filter.rs b/src/v1/schemas/object_rest_search_filter.rs new file mode 100644 index 0000000..ab7ed5d --- /dev/null +++ b/src/v1/schemas/object_rest_search_filter.rs @@ -0,0 +1,12 @@ + +default_derive!{ + pub struct ObjectRestSearchFilter { + //TODO + } +} + + +#[test] +fn valid1() { + todo!() +} \ No newline at end of file diff --git a/src/v1/schemas/object_rest_search_list.rs b/src/v1/schemas/object_rest_search_list.rs new file mode 100644 index 0000000..cd7f408 --- /dev/null +++ b/src/v1/schemas/object_rest_search_list.rs @@ -0,0 +1,25 @@ +use super::Object; + + +default_derive!{ + pub struct ObjectRestSearchList { + objects: Vec + } +} + +impl From> for ObjectRestSearchList { + fn from(value: Vec) -> Self { + ObjectRestSearchList { objects: value } + } +} + +impl Into> for ObjectRestSearchList { + fn into(self) -> Vec { + self.objects + } +} + +#[test] +fn valid1() { + todo!() +} \ No newline at end of file diff --git a/src/v1/schemas/object_template_id.rs b/src/v1/schemas/object_template_id.rs new file mode 100644 index 0000000..be1e8a8 --- /dev/null +++ b/src/v1/schemas/object_template_id.rs @@ -0,0 +1,52 @@ +use regex_macro::regex; + + +default_derive!{ + pub struct ObjectTemplateId { + id: String + } +} + +impl TryFrom<&str> for ObjectTemplateId { + type Error = &'static str; + + fn try_from(value: &str) -> Result { + let re = regex!("^[[:digit:]]+$"); + if value.len() <= 10 && re.is_match(value) { + Ok(ObjectTemplateId { id: value.to_string() }) + } + else { + Err("Failed to parse ObjectTemplateId") + } + } +} + +#[test] +fn empty() { + let id: Result = "".try_into(); + assert!(id.is_err()) +} + +#[test] +fn oversized() { + let id: Result = "12345678910".try_into(); + assert!(id.is_err()) +} + +#[test] +fn forbidden_char() { + let id: Result = "1954a".try_into(); + assert!(id.is_err()) +} + +#[test] +fn valid1() { + let id: Result = "12345".try_into(); + assert_eq!(id, Ok(ObjectTemplateId { id: "12345".to_string() })) +} + +#[test] +fn valid2() { + let id: Result = "0123456789".try_into(); + assert_eq!(id, Ok(ObjectTemplateId { id: "0123456789".to_string() })) +} \ No newline at end of file diff --git a/src/v1/schemas/sighting.rs b/src/v1/schemas/sighting.rs new file mode 100644 index 0000000..50d7487 --- /dev/null +++ b/src/v1/schemas/sighting.rs @@ -0,0 +1,11 @@ + +default_derive!{ + pub struct ExtendedObject { + //TODO + } +} + +#[test] +fn valid1() { + todo!() +} \ No newline at end of file diff --git a/src/v1/schemas/sighting_id.rs b/src/v1/schemas/sighting_id.rs new file mode 100644 index 0000000..efc6f2a --- /dev/null +++ b/src/v1/schemas/sighting_id.rs @@ -0,0 +1,58 @@ +use regex_macro::regex; + + +default_derive!{ + pub struct SightingId { + id: String + } +} + +impl TryFrom<&str> for SightingId { + type Error = &'static str; + + fn try_from(value: &str) -> Result { + let re = regex!("^[[:digit:]]+$"); + if value.len() <= 10 && re.is_match(value) { + Ok(SightingId { id: value.to_string() }) + } + else { + Err("Failed to parse SightingId") + } + } +} + +impl Into for SightingId { + fn into(self) -> String { + self.id + } +} + +#[test] +fn empty() { + let id: Result = "".try_into(); + assert!(id.is_err()) +} + +#[test] +fn oversized() { + let id: Result = "12345678910".try_into(); + assert!(id.is_err()) +} + +#[test] +fn forbidden_char() { + let id: Result = "1954a".try_into(); + assert!(id.is_err()) +} + +#[test] +fn valid1() { + let id: Result = "12345".try_into(); + assert_eq!(id, Ok(SightingId { id: "12345".to_string() })) +} + +#[test] +fn valid2() { + let id: Result = "0123456789".try_into(); + assert_eq!(id, Ok(SightingId { id: "0123456789".to_string() })) +} \ No newline at end of file diff --git a/src/v1/schemas/tag.rs b/src/v1/schemas/tag.rs new file mode 100644 index 0000000..a3ded45 --- /dev/null +++ b/src/v1/schemas/tag.rs @@ -0,0 +1,16 @@ +use super::{TagWithoutId, TagId}; + + +default_derive!{ + pub struct Tag { + id: TagId, + tag: TagWithoutId + } +} + + + +#[test] +fn valid1() { + todo!(); +} \ No newline at end of file diff --git a/src/v1/schemas/tag_collection_id.rs b/src/v1/schemas/tag_collection_id.rs new file mode 100644 index 0000000..04c86e1 --- /dev/null +++ b/src/v1/schemas/tag_collection_id.rs @@ -0,0 +1,58 @@ +use regex_macro::regex; + + +default_derive!{ + pub struct TagCollectionId { + id: String + } +} + +impl TryFrom<&str> for TagCollectionId { + type Error = &'static str; + + fn try_from(value: &str) -> Result { + let re = regex!("^[[:digit:]]+$"); + if value.len() <= 10 && re.is_match(value) { + Ok(TagCollectionId { id: value.to_string() }) + } + else { + Err("Failed to parse TagCollectionId") + } + } +} + +impl Into for TagCollectionId { + fn into(self) -> String { + self.id + } +} + +#[test] +fn empty() { + let id: Result = "".try_into(); + assert!(id.is_err()) +} + +#[test] +fn oversized() { + let id: Result = "12345678910".try_into(); + assert!(id.is_err()) +} + +#[test] +fn forbidden_char() { + let id: Result = "1954a".try_into(); + assert!(id.is_err()) +} + +#[test] +fn valid1() { + let id: Result = "12345".try_into(); + assert_eq!(id, Ok(TagCollectionId { id: "12345".to_string() })) +} + +#[test] +fn valid2() { + let id: Result = "0123456789".try_into(); + assert_eq!(id, Ok(TagCollectionId { id: "0123456789".to_string() })) +} \ No newline at end of file diff --git a/src/v1/schemas/tag_colour.rs b/src/v1/schemas/tag_colour.rs new file mode 100644 index 0000000..0fa927b --- /dev/null +++ b/src/v1/schemas/tag_colour.rs @@ -0,0 +1,49 @@ + +default_derive!{ + pub struct TagColour { + name: String + } +} + +impl TryFrom<&str> for TagColour { + type Error = &'static str; + + fn try_from(value: &str) -> Result { + if value.len() > 0 && value.len() <= 7 { + Ok(TagColour { name: value.to_string() }) + } + else { + Err("Failed to parse TagColour") + } + } +} + +impl Into for TagColour { + fn into(self) -> String { + self.name + } +} + +#[test] +fn empty() { + let id: Result = "".try_into(); + assert!(id.is_err()) +} + +#[test] +fn oversized() { + let id: Result = format!("{:>8}", "Test").as_str().try_into(); + assert!(id.is_err()) +} + +#[test] +fn valid1() { + let id: Result = "#ffffff".try_into(); + assert_eq!(id, Ok(TagColour { name: "name".to_string() })) +} + +#[test] +fn valid2() { + let id: Result = "colour".try_into(); // colour is not specced with any regex, only string length + assert_eq!(id, Ok(TagColour { name: "best-name:ever&0123456789".to_string() })) +} \ No newline at end of file diff --git a/src/v1/schemas/tag_id.rs b/src/v1/schemas/tag_id.rs new file mode 100644 index 0000000..70ab5d5 --- /dev/null +++ b/src/v1/schemas/tag_id.rs @@ -0,0 +1,58 @@ +use regex_macro::regex; + + +default_derive!{ + pub struct TagId { + id: String, + } +} + +impl TryFrom<&str> for TagId { + type Error = &'static str; + + fn try_from(value: &str) -> Result { + let re = regex!("^[[:digit:]]+$"); + if value.len() <= 10 && re.is_match(value) { + Ok(TagId { id: value.to_string() }) + } + else { + Err("Failed to parse TagId") + } + } +} + +impl Into for TagId { + fn into(self) -> String { + self.id + } +} + +#[test] +fn empty() { + let id: Result = "".try_into(); + assert!(id.is_err()) +} + +#[test] +fn oversized() { + let id: Result = "12345678910".try_into(); + assert!(id.is_err()) +} + +#[test] +fn forbidden_char() { + let id: Result = "1954a".try_into(); + assert!(id.is_err()) +} + +#[test] +fn valid1() { + let id: Result = "12345".try_into(); + assert_eq!(id, Ok(TagId { id: "12345".to_string() })) +} + +#[test] +fn valid2() { + let id: Result = "0123456789".try_into(); + assert_eq!(id, Ok(TagId { id: "0123456789".to_string() })) +} \ No newline at end of file diff --git a/src/v1/schemas/tag_list.rs b/src/v1/schemas/tag_list.rs new file mode 100644 index 0000000..316a043 --- /dev/null +++ b/src/v1/schemas/tag_list.rs @@ -0,0 +1,25 @@ +use super::Tag; + + +default_derive!{ + pub struct TagList { + elements: Vec + } +} + +impl From> for TagList { + fn from(value: Vec) -> Self { + TagList { elements: value } + } +} + +impl Into> for TagList { + fn into(self) -> Vec { + self.elements + } +} + +#[test] +fn valid1() { + todo!() +} \ No newline at end of file diff --git a/src/v1/schemas/tag_name.rs b/src/v1/schemas/tag_name.rs new file mode 100644 index 0000000..12c8006 --- /dev/null +++ b/src/v1/schemas/tag_name.rs @@ -0,0 +1,49 @@ + +default_derive!{ + pub struct TagName { + name: String + } +} + +impl TryFrom<&str> for TagName { + type Error = &'static str; + + fn try_from(value: &str) -> Result { + if value.len() > 0 && value.len() <= 255 { + Ok(TagName { name: value.to_string() }) + } + else { + Err("Failed to parse TagName") + } + } +} + +impl Into for TagName { + fn into(self) -> String { + self.name + } +} + +#[test] +fn empty() { + let id: Result = "".try_into(); + assert!(id.is_err()) +} + +#[test] +fn oversized() { + let id: Result = format!("{:>256}", "Test").as_str().try_into(); + assert!(id.is_err()) +} + +#[test] +fn valid1() { + let id: Result = "name".try_into(); + assert_eq!(id, Ok(TagName { name: "name".to_string() })) +} + +#[test] +fn valid2() { + let id: Result = "best-name:ever&0123456789".try_into(); + assert_eq!(id, Ok(TagName { name: "best-name:ever&0123456789".to_string() })) +} \ No newline at end of file diff --git a/src/v1/schemas/tag_no_id.rs b/src/v1/schemas/tag_no_id.rs new file mode 100644 index 0000000..e7f3894 --- /dev/null +++ b/src/v1/schemas/tag_no_id.rs @@ -0,0 +1,13 @@ + +default_derive!{ + pub struct TagWithoutId { + //TODO + } +} + + + +#[test] +fn valid1() { + todo!(); +} \ No newline at end of file diff --git a/src/v1/schemas/tag_numerical_value.rs b/src/v1/schemas/tag_numerical_value.rs new file mode 100644 index 0000000..46850a5 --- /dev/null +++ b/src/v1/schemas/tag_numerical_value.rs @@ -0,0 +1,66 @@ +use regex_macro::regex; + + +default_derive!{ + pub struct TagNumericalValue { + val: Option + } +} + +impl TryFrom<&str> for TagNumericalValue { + type Error = &'static str; + + fn try_from(value: &str) -> Result { + if value.len() == 0 || value == "null" { + return Ok(TagNumericalValue{ val: None }); + } + else { + let re = regex!("^[[:digit:]]+$"); + if re.is_match(value) { + Ok(TagNumericalValue { val: Some(value.to_string()) }) + } + else { + Err("Failed to parse TagNumericalValue") + } + } + } +} + + +impl TryInto for TagNumericalValue { + type Error = &'static str; + + fn try_into(self) -> Result { + if let Some(s) = self.val { + Ok(s) + } + else { + Err("Cannot cast TagNumericalValue into string, val is None") + } + } + +} + +#[test] +fn valid1() { + let val: Result = "12345".try_into(); + assert_eq!(val, Ok(TagNumericalValue { val: Some("12345".to_string()) })) +} + +#[test] +fn valid2() { + let val: Result = "0123456789".try_into(); + assert_eq!(val, Ok(TagNumericalValue { val: Some("0123456789".to_string()) })) +} + +#[test] +fn valid3() { + let val: Result = "".try_into(); + assert_eq!(val, Ok(TagNumericalValue { val: None })) +} + +#[test] +fn valid4() { + let val: Result = "null".try_into(); + assert_eq!(val, Ok(TagNumericalValue { val: None })) +} \ No newline at end of file