arcanite-addml: init
This commit is contained in:
parent
56ed664204
commit
d2c41c87cc
.gitignoreCargo.lockCargo.toml
arcanite-addml
Cargo.lockCargo.tomlREADME.md
src
lib.rsraw_types.rstypes.rs
types
additional_element.rsadditional_elements.rsaddml_document.rschar_definition.rscode.rscontent.rscontext.rsdata_object.rsdata_objects.rsdataset.rsdelim_file_format.rsfield_definition.rsfield_parts.rsfield_processes.rsfield_type.rsfixed_file_format.rsflat_file.rsflat_file_definition.rsflat_file_definition_reference.rsflat_file_process.rsflat_file_type.rsflat_files.rsheader_level.rskey.rsparameter.rsprocess.rsproperty.rsquery.rsrecord_definition.rsrecord_definition_reference.rsrecord_processes.rsrecord_type.rsreference.rsrepeating_group.rsrepeating_group_occurrence_field.rsstructure_types.rs
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
target
|
154
Cargo.lock
generated
Normal file
154
Cargo.lock
generated
Normal file
@ -0,0 +1,154 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "arcanite-addml"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"quick-xml",
|
||||
"serde",
|
||||
"serde-xml-rs",
|
||||
"serde_path_to_error",
|
||||
"vec1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.82"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quick-xml"
|
||||
version = "0.31.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.36"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.201"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde-xml-rs"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb3aa78ecda1ebc9ec9847d5d3aba7d618823446a049ba2491940506da6e2782"
|
||||
dependencies = [
|
||||
"log",
|
||||
"serde",
|
||||
"thiserror",
|
||||
"xml-rs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.201"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_path_to_error"
|
||||
version = "0.1.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af99884400da37c88f5e9146b7f1fd0fbcae8f6eec4e9da38b67d05486f814a6"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.63"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf5be731623ca1a1fb7d8be6f261a3be6d3e2337b8a1f97be944d020c8fcb704"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.60"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.60"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||
|
||||
[[package]]
|
||||
name = "vec1"
|
||||
version = "1.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ffb60dcfffc189bfd4e2a81333c268619fee9db53da71bce2bcbd8e129c56936"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "xml-rs"
|
||||
version = "0.8.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "791978798f0597cfc70478424c2b4fdc2b7a8024aaff78497ef00f24ef674193"
|
5
Cargo.toml
Normal file
5
Cargo.toml
Normal file
@ -0,0 +1,5 @@
|
||||
[workspace]
|
||||
|
||||
members = [
|
||||
"arcanite-addml",
|
||||
]
|
154
arcanite-addml/Cargo.lock
generated
Normal file
154
arcanite-addml/Cargo.lock
generated
Normal file
@ -0,0 +1,154 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "arcanite-addml"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"quick-xml",
|
||||
"serde",
|
||||
"serde-xml-rs",
|
||||
"serde_path_to_error",
|
||||
"vec1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.82"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quick-xml"
|
||||
version = "0.31.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.36"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.201"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde-xml-rs"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb3aa78ecda1ebc9ec9847d5d3aba7d618823446a049ba2491940506da6e2782"
|
||||
dependencies = [
|
||||
"log",
|
||||
"serde",
|
||||
"thiserror",
|
||||
"xml-rs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.201"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_path_to_error"
|
||||
version = "0.1.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af99884400da37c88f5e9146b7f1fd0fbcae8f6eec4e9da38b67d05486f814a6"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.63"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf5be731623ca1a1fb7d8be6f261a3be6d3e2337b8a1f97be944d020c8fcb704"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.60"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.60"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||
|
||||
[[package]]
|
||||
name = "vec1"
|
||||
version = "1.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ffb60dcfffc189bfd4e2a81333c268619fee9db53da71bce2bcbd8e129c56936"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "xml-rs"
|
||||
version = "0.8.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "791978798f0597cfc70478424c2b4fdc2b7a8024aaff78497ef00f24ef674193"
|
12
arcanite-addml/Cargo.toml
Normal file
12
arcanite-addml/Cargo.toml
Normal file
@ -0,0 +1,12 @@
|
||||
[package]
|
||||
name = "arcanite-addml"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
# TODO: Choose between quick-xml and serde-xml-rs
|
||||
quick-xml = { version = "0.31.0", features = ["serde", "serialize"] }
|
||||
serde = { version = "1.0.201", features = ["derive"] }
|
||||
serde-xml-rs = "0.6.0"
|
||||
serde_path_to_error = "0.1.16"
|
||||
vec1 = { version = "1.12.0", features = ["serde"] }
|
7
arcanite-addml/README.md
Normal file
7
arcanite-addml/README.md
Normal file
@ -0,0 +1,7 @@
|
||||
# arcanite-addml
|
||||
|
||||
## Links
|
||||
|
||||
- https://www.arkivverket.no/forvaltning-og-utvikling/regelverk-og-standarder/andre-arkivstandarder/addml-archival-data-description-markup-language
|
||||
- https://www.arkivverket.no/forvaltning-og-utvikling/regelverk-og-standarder/andre-arkivstandarder/addml-archival-data-description-markup-language/_/attachment/download/e3e195d0-aa21-4df3-99a8-31096f3e4525:c0a09d695060c1cae7e5b820feb3bca97c50d049/ADDML%208-3%20Generelt.pdf
|
||||
- https://www.arkivverket.no/forvaltning-og-utvikling/regelverk-og-standarder/andre-arkivstandarder/addml-archival-data-description-markup-language/_/attachment/download/94c6a79e-d1af-40ae-b1ef-3e754f762d95:f0fadebbc99ef785cca2c674726846f2c5603ae5/ADDML%208-3%20Profil%20Arkivverket.pdf
|
4
arcanite-addml/src/lib.rs
Normal file
4
arcanite-addml/src/lib.rs
Normal file
@ -0,0 +1,4 @@
|
||||
mod raw_types;
|
||||
pub mod types;
|
||||
|
||||
pub use raw_types::RawAddmlDocument;
|
557
arcanite-addml/src/raw_types.rs
Normal file
557
arcanite-addml/src/raw_types.rs
Normal file
@ -0,0 +1,557 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use vec1::Vec1;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawAdditionalElement {
|
||||
pub name: String,
|
||||
pub data_type: Option<String>,
|
||||
pub format: Option<String>,
|
||||
pub value: Option<RawValue>,
|
||||
pub properties: Option<RawProperties>,
|
||||
pub additional_elements: Option<RawAdditionalElements>,
|
||||
pub processes: Option<RawProcesses>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawAdditionalElements {
|
||||
pub description: Option<RawDescription>,
|
||||
pub additional_element: Option<Vec<RawAdditionalElement>>,
|
||||
pub processes: Option<RawProcesses>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawAddmlDocument {
|
||||
pub dataset: Vec1<RawDataset>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawAlignment(pub String);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawAlternateKey;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawCharDefinition {
|
||||
pub from_char: String,
|
||||
pub to_char: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawCharDefinitions {
|
||||
pub char_definition: Vec1<RawCharDefinition>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawCharset(pub String);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawCode {
|
||||
pub code_value: String,
|
||||
pub explan: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawCodes {
|
||||
pub code: Vec1<RawCode>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawContent {
|
||||
pub content: String,
|
||||
pub description: Option<RawDescription>,
|
||||
pub additional_elements: Option<RawAdditionalElements>,
|
||||
pub processes: Option<RawProcesses>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawContext {
|
||||
pub description: Option<RawDescription>,
|
||||
pub additional_elements: Option<RawAdditionalElements>,
|
||||
pub processes: Option<RawProcesses>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawDataObject {
|
||||
pub name: String,
|
||||
pub description: Option<RawDescription>,
|
||||
pub properties: Option<RawProperties>,
|
||||
pub data_objects: Option<RawDataObjects>,
|
||||
pub processes: Option<RawProcesses>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawDataObjects {
|
||||
pub description: Option<RawDescription>,
|
||||
pub data_object: Vec1<RawDataObject>,
|
||||
pub processes: Option<RawProcesses>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawDataset {
|
||||
pub name: String,
|
||||
pub description: Option<RawDescription>,
|
||||
pub reference: Option<RawReference>,
|
||||
pub flat_files: Option<RawFlatFiles>,
|
||||
pub data_objects: Option<RawDataObjects>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawDataType(pub String);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawDelimFileFormat {
|
||||
pub record_separator: RawRecordSeparator,
|
||||
pub field_separating_char: RawFieldSeparatingChar,
|
||||
pub quoting_char: Option<RawQuotingChar>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawDescription(pub String);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawEndPos(pub usize);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawExternal;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawFieldDefinition {
|
||||
pub name: String,
|
||||
pub type_reference: String,
|
||||
pub description: Option<RawDescription>,
|
||||
pub properties: Option<RawProperties>,
|
||||
pub start_pos: Option<RawStartPos>,
|
||||
pub end_pos: Option<RawEndPos>,
|
||||
pub fixed_length: Option<RawFixedLength>,
|
||||
pub min_length: Option<RawMinLength>,
|
||||
pub max_length: Option<RawMaxLength>,
|
||||
pub unique: Option<RawUnique>,
|
||||
pub not_null: Option<RawNotNull>,
|
||||
pub field_parts: Option<RawFieldParts>,
|
||||
pub codes: Option<RawCodes>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawFieldDefinitionReference {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawFieldDefinitionReferences {
|
||||
pub field_definition_reference: Vec1<RawFieldDefinitionReference>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawFieldDefinitions {
|
||||
pub field_definition: Vec1<RawFieldDefinition>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawFieldFormat(pub String);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawFieldParts {
|
||||
pub name: String,
|
||||
pub field_definition: Vec1<RawFieldDefinition>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawFieldProcesses {
|
||||
pub definition_reference: String,
|
||||
pub processes: RawProcesses,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawFieldSeparatingChar(pub String);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawFieldType {
|
||||
pub name: String,
|
||||
pub description: Option<RawDescription>,
|
||||
pub data_type: RawDataType,
|
||||
pub field_format: Option<RawFieldFormat>,
|
||||
pub alignment: Option<RawAlignment>,
|
||||
pub pad_char: Option<RawPadChar>,
|
||||
pub pack_type: Option<RawPackType>,
|
||||
pub null_values: Option<RawNullValues>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawFieldTypes {
|
||||
pub field_type: Vec1<RawFieldType>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawFixedFileFormat {
|
||||
pub record_separator: Option<RawRecordSeparator>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawFixedLength(pub usize);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawFixedOccurrences(pub usize);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawFlatFile {
|
||||
pub name: String,
|
||||
pub definition_reference: String,
|
||||
pub properties: Option<RawProperties>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawFlatFileDefinition {
|
||||
pub name: String,
|
||||
pub type_reference: Option<String>,
|
||||
pub description: Option<RawDescription>,
|
||||
pub properties: Option<Vec<RawProperties>>,
|
||||
pub external: Option<RawExternal>,
|
||||
pub record_definition_field_identifier: Option<RawRecordDefinitionFieldIdentifier>,
|
||||
pub record_definitions: RawRecordDefinitions,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawFlatFileDefinitionReference {
|
||||
pub name: String,
|
||||
pub record_definition_references: Option<RawRecordDefinitionReferences>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawFlatFileDefinitions {
|
||||
pub flat_file_definition: Vec1<RawFlatFileDefinition>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawFlatFileProcess {
|
||||
pub flat_file_reference: String,
|
||||
pub processes: Option<RawProcesses>,
|
||||
pub record_processes: Vec<RawRecordProcesses>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawFlatFiles {
|
||||
pub flat_file: Vec<RawFlatFile>,
|
||||
pub flat_file_definitions: RawFlatFileDefinitions,
|
||||
pub structure_types: RawStructureTypes,
|
||||
pub queries: Option<RawQueries>,
|
||||
pub processes: Option<RawProcesses>,
|
||||
pub flat_file_processes: Vec<RawFlatFileProcess>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawFlatFileType {
|
||||
pub name: String,
|
||||
pub description: Option<RawDescription>,
|
||||
pub charset: RawCharset,
|
||||
pub char_definitions: Option<RawCharDefinitions>,
|
||||
// TODO: ensure at least one of the following is present
|
||||
pub fixed_file_format: Option<RawFixedFileFormat>,
|
||||
pub delim_file_format: Option<RawDelimFileFormat>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawFlatFileTypes {
|
||||
pub flat_file_type: Vec1<RawFlatFileType>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawForeignKey {
|
||||
pub flat_file_definition_reference: RawFlatFileDefinitionReference,
|
||||
pub relation_type: RawRelationType,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawHeaderLevel {
|
||||
// TODO: there seems to be a format for this, but it's left unspecified?
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawIncomplete;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawKey {
|
||||
pub name: String,
|
||||
pub primary_key: Option<RawPrimaryKey>,
|
||||
pub alternate_key: Option<RawAlternateKey>,
|
||||
pub foreign_key: Option<RawForeignKey>,
|
||||
|
||||
pub field_definition_references: RawFieldDefinitionReferences,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawKeys {
|
||||
pub key: Vec1<RawKey>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawMaxLength(pub usize);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawMinLength(pub usize);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawNotNull;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawNullValue(pub String);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawNullValues {
|
||||
pub null_value: Vec1<RawNullValue>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawPackType(pub Option<String>);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawPadChar(pub String);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawParameter {
|
||||
pub name: String,
|
||||
pub value: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawParameters {
|
||||
pub parameter: Vec1<RawParameter>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawPrimaryKey;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawProcess {
|
||||
pub name: String,
|
||||
pub parameters: Option<RawParameters>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawProcesses {
|
||||
pub process: Vec1<RawProcess>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawProperties {
|
||||
pub property: Vec1<RawProperty>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawProperty {
|
||||
pub name: String,
|
||||
pub data_type: Option<String>,
|
||||
pub format: Option<String>,
|
||||
pub value: Option<RawValue>,
|
||||
pub properties: Option<RawProperties>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawQueries {
|
||||
pub query: Vec1<RawQuery>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawQuery {
|
||||
pub name: String,
|
||||
pub description: Option<RawDescription>,
|
||||
pub statement: RawStatement,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawQuotingChar(pub String);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawRecordDefinition {
|
||||
pub name: String,
|
||||
pub type_reference: Option<String>,
|
||||
pub description: Option<RawDescription>,
|
||||
pub properties: Option<RawProperties>,
|
||||
pub record_definition_field_value: Option<RawRecordDefinitionFieldValue>,
|
||||
pub incomplete: Option<RawIncomplete>,
|
||||
pub fixed_length: Option<RawFixedLength>,
|
||||
pub repeating_groups: Option<RawRepeatingGroups>,
|
||||
pub keys: Option<RawKeys>,
|
||||
pub field_definitions: RawFieldDefinitions,
|
||||
pub header_level: Option<RawHeaderLevel>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawRecordDefinitionFieldIdentifier(pub String);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawRecordDefinitionFieldValue(pub String);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawRecordDefinitionReference {
|
||||
pub name: String,
|
||||
pub field_definition_references: Option<RawFieldDefinitionReferences>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawRecordDefinitionReferences {
|
||||
pub record_definition_reference: Vec1<RawRecordDefinitionReference>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawRecordDefinitions {
|
||||
pub record_definition: Vec1<RawRecordDefinition>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawRecordProcesses {
|
||||
// TODO: report this as a bug in the spec
|
||||
// pub name: String,
|
||||
pub definition_reference: String,
|
||||
pub processes: Option<RawProcesses>,
|
||||
pub field_processes: Option<Vec<RawFieldProcesses>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawRecordSeparator(pub String);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawRecordType {
|
||||
pub name: String,
|
||||
pub description: Option<RawDescription>,
|
||||
pub trimmed: Option<RawTrimmed>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawRecordTypes {
|
||||
pub record_type: Vec1<RawRecordType>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawReference {
|
||||
pub name: Option<String>,
|
||||
pub context: Option<RawContext>,
|
||||
pub content: Option<RawContent>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawRelationType(pub String);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawRepeatingGroup {
|
||||
pub name: String,
|
||||
// TODO: one of repeating_group_occurrence_field or fixed_occurrences must be present, maybe create enum?
|
||||
pub repeating_group_occurrence_field: Option<RawRepeatingGroupOccurrenceField>,
|
||||
pub fixed_occurrences: Option<RawFixedOccurrences>,
|
||||
pub field_definition_references: RawFieldDefinitionReferences,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawRepeatingGroupOccurrenceField {
|
||||
pub definition_reference: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawRepeatingGroups {
|
||||
pub repeating_group: Vec1<RawRepeatingGroup>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawStartPos(pub usize);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawStatement(pub String);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawStructureTypes {
|
||||
pub flat_file_types: RawFlatFileTypes,
|
||||
pub record_types: Option<RawRecordTypes>,
|
||||
pub field_types: RawFieldTypes,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawTrimmed;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawUnique;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RawValue(pub String);
|
77
arcanite-addml/src/types.rs
Normal file
77
arcanite-addml/src/types.rs
Normal file
@ -0,0 +1,77 @@
|
||||
use vec1::Vec1;
|
||||
|
||||
use crate::raw_types::*;
|
||||
|
||||
mod additional_element;
|
||||
mod additional_elements;
|
||||
mod addml_document;
|
||||
mod char_definition;
|
||||
mod code;
|
||||
mod content;
|
||||
mod context;
|
||||
mod data_object;
|
||||
mod data_objects;
|
||||
mod dataset;
|
||||
mod delim_file_format;
|
||||
mod field_definition;
|
||||
mod field_parts;
|
||||
mod field_processes;
|
||||
mod field_type;
|
||||
mod fixed_file_format;
|
||||
mod flat_file;
|
||||
mod flat_file_definition;
|
||||
mod flat_file_definition_reference;
|
||||
mod flat_file_process;
|
||||
mod flat_file_type;
|
||||
mod flat_files;
|
||||
mod header_level;
|
||||
mod key;
|
||||
mod parameter;
|
||||
mod process;
|
||||
mod property;
|
||||
mod query;
|
||||
mod record_definition;
|
||||
mod record_definition_reference;
|
||||
mod record_processes;
|
||||
mod record_type;
|
||||
mod reference;
|
||||
mod repeating_group;
|
||||
mod repeating_group_occurrence_field;
|
||||
mod structure_types;
|
||||
|
||||
pub use additional_element::*;
|
||||
pub use additional_elements::*;
|
||||
pub use addml_document::*;
|
||||
pub use char_definition::*;
|
||||
pub use code::*;
|
||||
pub use content::*;
|
||||
pub use context::*;
|
||||
pub use data_object::*;
|
||||
pub use data_objects::*;
|
||||
pub use dataset::*;
|
||||
pub use delim_file_format::*;
|
||||
pub use field_definition::*;
|
||||
pub use field_parts::*;
|
||||
pub use field_processes::*;
|
||||
pub use field_type::*;
|
||||
pub use fixed_file_format::*;
|
||||
pub use flat_file::*;
|
||||
pub use flat_file_definition::*;
|
||||
pub use flat_file_definition_reference::*;
|
||||
pub use flat_file_process::*;
|
||||
pub use flat_file_type::*;
|
||||
pub use flat_files::*;
|
||||
pub use header_level::*;
|
||||
pub use key::*;
|
||||
pub use parameter::*;
|
||||
pub use process::*;
|
||||
pub use property::*;
|
||||
pub use query::*;
|
||||
pub use record_definition::*;
|
||||
pub use record_definition_reference::*;
|
||||
pub use record_processes::*;
|
||||
pub use record_type::*;
|
||||
pub use reference::*;
|
||||
pub use repeating_group::*;
|
||||
pub use repeating_group_occurrence_field::*;
|
||||
pub use structure_types::*;
|
56
arcanite-addml/src/types/additional_element.rs
Normal file
56
arcanite-addml/src/types/additional_element.rs
Normal file
@ -0,0 +1,56 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct AdditionalElement {
|
||||
pub name: String,
|
||||
pub data_type: Option<String>,
|
||||
pub format: Option<String>,
|
||||
pub value: Option<String>,
|
||||
pub properties: Vec<Property>,
|
||||
pub additional_elements: Option<AdditionalElements>,
|
||||
pub processes: Vec<Process>,
|
||||
}
|
||||
|
||||
impl From<RawAdditionalElement> for AdditionalElement {
|
||||
fn from(raw: RawAdditionalElement) -> Self {
|
||||
AdditionalElement {
|
||||
name: raw.name,
|
||||
data_type: raw.data_type,
|
||||
format: raw.format,
|
||||
value: raw.value.map(|RawValue(v)| v),
|
||||
properties: raw
|
||||
.properties
|
||||
.map(|RawProperties { property: p }| p.mapped(|p| p.into()).into())
|
||||
.unwrap_or_default(),
|
||||
additional_elements: raw.additional_elements.map(|ae| ae.into()),
|
||||
processes: raw
|
||||
.processes
|
||||
.map(|RawProcesses { process: p }| p.mapped(|p| p.into()).into())
|
||||
.unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<AdditionalElement> for RawAdditionalElement {
|
||||
fn from(val: AdditionalElement) -> Self {
|
||||
RawAdditionalElement {
|
||||
name: val.name,
|
||||
data_type: val.data_type,
|
||||
format: val.format,
|
||||
value: val.value.map(RawValue),
|
||||
properties: match Vec1::try_from_vec(val.properties) {
|
||||
Ok(properties) => Some(RawProperties {
|
||||
property: properties.mapped(|p| p.into()),
|
||||
}),
|
||||
Err(_) => None,
|
||||
},
|
||||
additional_elements: val.additional_elements.map(|ae| ae.into()),
|
||||
processes: match Vec1::try_from_vec(val.processes) {
|
||||
Ok(processes) => Some(RawProcesses {
|
||||
process: processes.mapped(|p| p.into()),
|
||||
}),
|
||||
Err(_) => None,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
40
arcanite-addml/src/types/additional_elements.rs
Normal file
40
arcanite-addml/src/types/additional_elements.rs
Normal file
@ -0,0 +1,40 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct AdditionalElements {
|
||||
pub description: Option<String>,
|
||||
pub additional_element: Option<Vec<AdditionalElement>>,
|
||||
pub processes: Vec<Process>,
|
||||
}
|
||||
|
||||
impl From<RawAdditionalElements> for AdditionalElements {
|
||||
fn from(raw: RawAdditionalElements) -> Self {
|
||||
AdditionalElements {
|
||||
description: raw.description.map(|RawDescription(d)| d),
|
||||
additional_element: raw
|
||||
.additional_element
|
||||
.map(|ae| ae.into_iter().map(|ae| ae.into()).collect()),
|
||||
processes: raw
|
||||
.processes
|
||||
.map(|RawProcesses { process: p }| p.mapped(|p| p.into()).into())
|
||||
.unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<AdditionalElements> for RawAdditionalElements {
|
||||
fn from(val: AdditionalElements) -> Self {
|
||||
RawAdditionalElements {
|
||||
description: val.description.map(RawDescription),
|
||||
additional_element: val
|
||||
.additional_element
|
||||
.map(|ae| ae.into_iter().map(|ae| ae.into()).collect()),
|
||||
processes: match Vec1::try_from_vec(val.processes) {
|
||||
Ok(processes) => Some(RawProcesses {
|
||||
process: processes.mapped(|p| p.into()),
|
||||
}),
|
||||
Err(_) => None,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
22
arcanite-addml/src/types/addml_document.rs
Normal file
22
arcanite-addml/src/types/addml_document.rs
Normal file
@ -0,0 +1,22 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct AddmlDocument {
|
||||
dataset: Vec1<Dataset>,
|
||||
}
|
||||
|
||||
impl From<RawAddmlDocument> for AddmlDocument {
|
||||
fn from(raw: RawAddmlDocument) -> Self {
|
||||
AddmlDocument {
|
||||
dataset: raw.dataset.mapped(|ds| ds.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<AddmlDocument> for RawAddmlDocument {
|
||||
fn from(val: AddmlDocument) -> Self {
|
||||
RawAddmlDocument {
|
||||
dataset: val.dataset.mapped(|ds| ds.into()),
|
||||
}
|
||||
}
|
||||
}
|
25
arcanite-addml/src/types/char_definition.rs
Normal file
25
arcanite-addml/src/types/char_definition.rs
Normal file
@ -0,0 +1,25 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct CharDefinition {
|
||||
pub from_char: String,
|
||||
pub to_char: String,
|
||||
}
|
||||
|
||||
impl From<RawCharDefinition> for CharDefinition {
|
||||
fn from(raw: RawCharDefinition) -> Self {
|
||||
CharDefinition {
|
||||
from_char: raw.from_char,
|
||||
to_char: raw.to_char,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<CharDefinition> for RawCharDefinition {
|
||||
fn from(val: CharDefinition) -> Self {
|
||||
RawCharDefinition {
|
||||
from_char: val.from_char,
|
||||
to_char: val.to_char,
|
||||
}
|
||||
}
|
||||
}
|
25
arcanite-addml/src/types/code.rs
Normal file
25
arcanite-addml/src/types/code.rs
Normal file
@ -0,0 +1,25 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct Code {
|
||||
code_value: String,
|
||||
explan: Option<String>,
|
||||
}
|
||||
|
||||
impl From<RawCode> for Code {
|
||||
fn from(raw: RawCode) -> Self {
|
||||
Code {
|
||||
code_value: raw.code_value,
|
||||
explan: raw.explan,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Code> for RawCode {
|
||||
fn from(val: Code) -> Self {
|
||||
RawCode {
|
||||
code_value: val.code_value,
|
||||
explan: val.explan,
|
||||
}
|
||||
}
|
||||
}
|
39
arcanite-addml/src/types/content.rs
Normal file
39
arcanite-addml/src/types/content.rs
Normal file
@ -0,0 +1,39 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct Content {
|
||||
pub content: String,
|
||||
pub description: Option<String>,
|
||||
pub additional_elements: Option<AdditionalElements>,
|
||||
pub processes: Vec<Process>,
|
||||
}
|
||||
|
||||
impl From<RawContent> for Content {
|
||||
fn from(raw: RawContent) -> Self {
|
||||
Content {
|
||||
content: raw.content,
|
||||
description: raw.description.map(|RawDescription(d)| d),
|
||||
additional_elements: raw.additional_elements.map(|ae| ae.into()),
|
||||
processes: raw
|
||||
.processes
|
||||
.map(|RawProcesses { process: p }| p.mapped(|p| p.into()).into())
|
||||
.unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Content> for RawContent {
|
||||
fn from(val: Content) -> Self {
|
||||
RawContent {
|
||||
content: val.content,
|
||||
description: val.description.map(RawDescription),
|
||||
additional_elements: val.additional_elements.map(|ae| ae.into()),
|
||||
processes: match Vec1::try_from_vec(val.processes) {
|
||||
Ok(processes) => Some(RawProcesses {
|
||||
process: processes.mapped(|p| p.into()),
|
||||
}),
|
||||
Err(_) => None,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
36
arcanite-addml/src/types/context.rs
Normal file
36
arcanite-addml/src/types/context.rs
Normal file
@ -0,0 +1,36 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct Context {
|
||||
pub description: Option<String>,
|
||||
pub additional_elements: Option<AdditionalElements>,
|
||||
pub processes: Vec<Process>,
|
||||
}
|
||||
|
||||
impl From<RawContext> for Context {
|
||||
fn from(raw: RawContext) -> Self {
|
||||
Context {
|
||||
description: raw.description.map(|RawDescription(d)| d),
|
||||
additional_elements: raw.additional_elements.map(|ae| ae.into()),
|
||||
processes: raw
|
||||
.processes
|
||||
.map(|RawProcesses { process: p }| p.mapped(|p| p.into()).into())
|
||||
.unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Context> for RawContext {
|
||||
fn from(val: Context) -> Self {
|
||||
RawContext {
|
||||
description: val.description.map(RawDescription),
|
||||
additional_elements: val.additional_elements.map(|ae| ae.into()),
|
||||
processes: match Vec1::try_from_vec(val.processes) {
|
||||
Ok(processes) => Some(RawProcesses {
|
||||
process: processes.mapped(|p| p.into()),
|
||||
}),
|
||||
Err(_) => None,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
50
arcanite-addml/src/types/data_object.rs
Normal file
50
arcanite-addml/src/types/data_object.rs
Normal file
@ -0,0 +1,50 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct DataObject {
|
||||
pub name: String,
|
||||
pub description: Option<String>,
|
||||
pub properties: Vec<Property>,
|
||||
pub data_objects: Option<DataObjects>,
|
||||
pub processes: Vec<Process>,
|
||||
}
|
||||
|
||||
impl From<RawDataObject> for DataObject {
|
||||
fn from(raw: RawDataObject) -> Self {
|
||||
DataObject {
|
||||
name: raw.name,
|
||||
description: raw.description.map(|RawDescription(d)| d),
|
||||
properties: raw
|
||||
.properties
|
||||
.map(|RawProperties { property: p }| p.mapped(|p| p.into()).into())
|
||||
.unwrap_or_default(),
|
||||
data_objects: raw.data_objects.map(|do_| do_.into()),
|
||||
processes: raw
|
||||
.processes
|
||||
.map(|RawProcesses { process: p }| p.mapped(|p| p.into()).into())
|
||||
.unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DataObject> for RawDataObject {
|
||||
fn from(val: DataObject) -> Self {
|
||||
RawDataObject {
|
||||
name: val.name,
|
||||
description: val.description.map(RawDescription),
|
||||
properties: match Vec1::try_from_vec(val.properties) {
|
||||
Ok(properties) => Some(RawProperties {
|
||||
property: properties.mapped(|p| p.into()),
|
||||
}),
|
||||
Err(_) => None,
|
||||
},
|
||||
data_objects: val.data_objects.map(|do_| do_.into()),
|
||||
processes: match Vec1::try_from_vec(val.processes) {
|
||||
Ok(processes) => Some(RawProcesses {
|
||||
process: processes.mapped(|p| p.into()),
|
||||
}),
|
||||
Err(_) => None,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
36
arcanite-addml/src/types/data_objects.rs
Normal file
36
arcanite-addml/src/types/data_objects.rs
Normal file
@ -0,0 +1,36 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct DataObjects {
|
||||
pub description: Option<String>,
|
||||
pub data_object: Vec1<DataObject>,
|
||||
pub processes: Vec<Process>,
|
||||
}
|
||||
|
||||
impl From<RawDataObjects> for DataObjects {
|
||||
fn from(raw: RawDataObjects) -> Self {
|
||||
DataObjects {
|
||||
description: raw.description.map(|RawDescription(d)| d),
|
||||
data_object: raw.data_object.mapped(|do_| do_.into()),
|
||||
processes: raw
|
||||
.processes
|
||||
.map(|RawProcesses { process: p }| p.mapped(|p| p.into()).into())
|
||||
.unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DataObjects> for RawDataObjects {
|
||||
fn from(val: DataObjects) -> Self {
|
||||
RawDataObjects {
|
||||
description: val.description.map(RawDescription),
|
||||
data_object: val.data_object.mapped(|do_| do_.into()),
|
||||
processes: match Vec1::try_from_vec(val.processes) {
|
||||
Ok(processes) => Some(RawProcesses {
|
||||
process: processes.mapped(|p| p.into()),
|
||||
}),
|
||||
Err(_) => None,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
34
arcanite-addml/src/types/dataset.rs
Normal file
34
arcanite-addml/src/types/dataset.rs
Normal file
@ -0,0 +1,34 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct Dataset {
|
||||
pub name: String,
|
||||
pub description: Option<String>,
|
||||
pub reference: Option<Reference>,
|
||||
pub flat_files: Option<FlatFiles>,
|
||||
pub data_objects: Option<DataObjects>,
|
||||
}
|
||||
|
||||
impl From<RawDataset> for Dataset {
|
||||
fn from(raw: RawDataset) -> Self {
|
||||
Dataset {
|
||||
name: raw.name,
|
||||
description: raw.description.map(|RawDescription(d)| d),
|
||||
reference: raw.reference.map(|r| r.into()),
|
||||
flat_files: raw.flat_files.map(|ff| ff.into()),
|
||||
data_objects: raw.data_objects.map(|do_| do_.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Dataset> for RawDataset {
|
||||
fn from(val: Dataset) -> Self {
|
||||
RawDataset {
|
||||
name: val.name,
|
||||
description: val.description.map(RawDescription),
|
||||
reference: val.reference.map(|r| r.into()),
|
||||
flat_files: val.flat_files.map(|ff| ff.into()),
|
||||
data_objects: val.data_objects.map(|do_| do_.into()),
|
||||
}
|
||||
}
|
||||
}
|
28
arcanite-addml/src/types/delim_file_format.rs
Normal file
28
arcanite-addml/src/types/delim_file_format.rs
Normal file
@ -0,0 +1,28 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct DelimFileFormat {
|
||||
pub record_separator: String,
|
||||
pub field_separating_char: String,
|
||||
pub quoting_char: Option<String>,
|
||||
}
|
||||
|
||||
impl From<RawDelimFileFormat> for DelimFileFormat {
|
||||
fn from(raw: RawDelimFileFormat) -> Self {
|
||||
DelimFileFormat {
|
||||
record_separator: raw.record_separator.0,
|
||||
field_separating_char: raw.field_separating_char.0,
|
||||
quoting_char: raw.quoting_char.map(|RawQuotingChar(qc)| qc),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DelimFileFormat> for RawDelimFileFormat {
|
||||
fn from(val: DelimFileFormat) -> Self {
|
||||
RawDelimFileFormat {
|
||||
record_separator: RawRecordSeparator(val.record_separator),
|
||||
field_separating_char: RawFieldSeparatingChar(val.field_separating_char),
|
||||
quoting_char: val.quoting_char.map(RawQuotingChar),
|
||||
}
|
||||
}
|
||||
}
|
74
arcanite-addml/src/types/field_definition.rs
Normal file
74
arcanite-addml/src/types/field_definition.rs
Normal file
@ -0,0 +1,74 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct FieldDefinition {
|
||||
pub name: String,
|
||||
pub type_reference: String,
|
||||
pub description: Option<String>,
|
||||
pub properties: Vec<Property>,
|
||||
pub start_pos: Option<usize>,
|
||||
pub end_pos: Option<usize>,
|
||||
pub fixed_length: Option<usize>,
|
||||
pub min_length: Option<usize>,
|
||||
pub max_length: Option<usize>,
|
||||
pub unique: bool,
|
||||
pub not_null: bool,
|
||||
pub field_parts: Option<FieldParts>,
|
||||
pub codes: Vec<Code>,
|
||||
}
|
||||
|
||||
impl From<RawFieldDefinition> for FieldDefinition {
|
||||
fn from(raw: RawFieldDefinition) -> Self {
|
||||
FieldDefinition {
|
||||
name: raw.name,
|
||||
type_reference: raw.type_reference,
|
||||
description: raw.description.map(|RawDescription(d)| d),
|
||||
properties: raw
|
||||
.properties
|
||||
.map(|RawProperties { property: p }| p.mapped(|p| p.into()).into())
|
||||
.unwrap_or_default(),
|
||||
start_pos: raw.start_pos.map(|RawStartPos(sp)| sp),
|
||||
end_pos: raw.end_pos.map(|RawEndPos(ep)| ep),
|
||||
fixed_length: raw.fixed_length.map(|RawFixedLength(fl)| fl),
|
||||
min_length: raw.min_length.map(|RawMinLength(ml)| ml),
|
||||
max_length: raw.max_length.map(|RawMaxLength(ml)| ml),
|
||||
unique: raw.unique.is_some(),
|
||||
not_null: raw.not_null.is_some(),
|
||||
field_parts: raw.field_parts.map(|fp| fp.into()),
|
||||
codes: raw
|
||||
.codes
|
||||
.map(|RawCodes { code: c }| c.mapped(|c| c.into()).into())
|
||||
.unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<FieldDefinition> for RawFieldDefinition {
|
||||
fn from(val: FieldDefinition) -> Self {
|
||||
RawFieldDefinition {
|
||||
name: val.name,
|
||||
type_reference: val.type_reference,
|
||||
description: val.description.map(RawDescription),
|
||||
properties: match Vec1::try_from_vec(val.properties) {
|
||||
Ok(properties) => Some(RawProperties {
|
||||
property: properties.mapped(|p| p.into()),
|
||||
}),
|
||||
Err(_) => None,
|
||||
},
|
||||
start_pos: val.start_pos.map(RawStartPos),
|
||||
end_pos: val.end_pos.map(RawEndPos),
|
||||
fixed_length: val.fixed_length.map(RawFixedLength),
|
||||
min_length: val.min_length.map(RawMinLength),
|
||||
max_length: val.max_length.map(RawMaxLength),
|
||||
unique: if val.unique { Some(RawUnique) } else { None },
|
||||
not_null: if val.not_null { Some(RawNotNull) } else { None },
|
||||
field_parts: val.field_parts.map(|fp| fp.into()),
|
||||
codes: match Vec1::try_from_vec(val.codes) {
|
||||
Ok(codes) => Some(RawCodes {
|
||||
code: codes.mapped(|c| c.into()),
|
||||
}),
|
||||
Err(_) => None,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
25
arcanite-addml/src/types/field_parts.rs
Normal file
25
arcanite-addml/src/types/field_parts.rs
Normal file
@ -0,0 +1,25 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct FieldParts {
|
||||
pub name: String,
|
||||
pub field_definition: Vec1<FieldDefinition>,
|
||||
}
|
||||
|
||||
impl From<RawFieldParts> for FieldParts {
|
||||
fn from(raw: RawFieldParts) -> Self {
|
||||
FieldParts {
|
||||
name: raw.name,
|
||||
field_definition: raw.field_definition.mapped(|fd| fd.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<FieldParts> for RawFieldParts {
|
||||
fn from(val: FieldParts) -> Self {
|
||||
RawFieldParts {
|
||||
name: val.name,
|
||||
field_definition: val.field_definition.mapped(|fd| fd.into()),
|
||||
}
|
||||
}
|
||||
}
|
27
arcanite-addml/src/types/field_processes.rs
Normal file
27
arcanite-addml/src/types/field_processes.rs
Normal file
@ -0,0 +1,27 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct FieldProcesses {
|
||||
pub definition_reference: String,
|
||||
pub processes: Vec1<Process>,
|
||||
}
|
||||
|
||||
impl From<RawFieldProcesses> for FieldProcesses {
|
||||
fn from(raw: RawFieldProcesses) -> Self {
|
||||
FieldProcesses {
|
||||
definition_reference: raw.definition_reference,
|
||||
processes: raw.processes.process.mapped(|p| p.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<FieldProcesses> for RawFieldProcesses {
|
||||
fn from(val: FieldProcesses) -> Self {
|
||||
RawFieldProcesses {
|
||||
definition_reference: val.definition_reference,
|
||||
processes: RawProcesses {
|
||||
process: val.processes.mapped(|p| p.into()),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
55
arcanite-addml/src/types/field_type.rs
Normal file
55
arcanite-addml/src/types/field_type.rs
Normal file
@ -0,0 +1,55 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct FieldType {
|
||||
pub name: String,
|
||||
pub description: Option<String>,
|
||||
pub data_type: String,
|
||||
pub field_format: Option<String>,
|
||||
pub alignment: Option<String>,
|
||||
pub pad_char: Option<String>,
|
||||
// TODO: Make a more explanatory type for this
|
||||
// If the outer Option is Some, the field is packed,
|
||||
// but the algorithm is not specified. The inner value
|
||||
// can also be "packed", which would be the same as Some(None).
|
||||
pub pack_type: Option<Option<String>>,
|
||||
pub null_values: Vec<String>,
|
||||
}
|
||||
|
||||
impl From<RawFieldType> for FieldType {
|
||||
fn from(raw: RawFieldType) -> Self {
|
||||
FieldType {
|
||||
name: raw.name,
|
||||
description: raw.description.map(|RawDescription(d)| d),
|
||||
data_type: raw.data_type.0,
|
||||
field_format: raw.field_format.map(|RawFieldFormat(ff)| ff),
|
||||
alignment: raw.alignment.map(|RawAlignment(a)| a),
|
||||
pad_char: raw.pad_char.map(|RawPadChar(pc)| pc),
|
||||
pack_type: raw.pack_type.map(|RawPackType(pt)| pt),
|
||||
null_values: raw
|
||||
.null_values
|
||||
.map(|RawNullValues { null_value: nv }| nv.mapped(|RawNullValue(nv)| nv).into())
|
||||
.unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<FieldType> for RawFieldType {
|
||||
fn from(val: FieldType) -> Self {
|
||||
RawFieldType {
|
||||
name: val.name,
|
||||
description: val.description.map(RawDescription),
|
||||
data_type: RawDataType(val.data_type),
|
||||
field_format: val.field_format.map(RawFieldFormat),
|
||||
alignment: val.alignment.map(RawAlignment),
|
||||
pad_char: val.pad_char.map(RawPadChar),
|
||||
pack_type: val.pack_type.map(|pt| RawPackType(pt)),
|
||||
null_values: match Vec1::try_from_vec(val.null_values) {
|
||||
Ok(null_values) => Some(RawNullValues {
|
||||
null_value: null_values.mapped(|nv| RawNullValue(nv)),
|
||||
}),
|
||||
Err(_) => None,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
22
arcanite-addml/src/types/fixed_file_format.rs
Normal file
22
arcanite-addml/src/types/fixed_file_format.rs
Normal file
@ -0,0 +1,22 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct FixedFileFormat {
|
||||
pub record_separator: Option<String>,
|
||||
}
|
||||
|
||||
impl From<RawFixedFileFormat> for FixedFileFormat {
|
||||
fn from(raw: RawFixedFileFormat) -> Self {
|
||||
FixedFileFormat {
|
||||
record_separator: raw.record_separator.map(|RawRecordSeparator(rs)| rs),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<FixedFileFormat> for RawFixedFileFormat {
|
||||
fn from(val: FixedFileFormat) -> Self {
|
||||
RawFixedFileFormat {
|
||||
record_separator: val.record_separator.map(RawRecordSeparator),
|
||||
}
|
||||
}
|
||||
}
|
36
arcanite-addml/src/types/flat_file.rs
Normal file
36
arcanite-addml/src/types/flat_file.rs
Normal file
@ -0,0 +1,36 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct FlatFile {
|
||||
pub name: String,
|
||||
pub definition_reference: String,
|
||||
pub properties: Vec<Property>,
|
||||
}
|
||||
|
||||
impl From<RawFlatFile> for FlatFile {
|
||||
fn from(raw: RawFlatFile) -> Self {
|
||||
FlatFile {
|
||||
name: raw.name,
|
||||
definition_reference: raw.definition_reference,
|
||||
properties: raw
|
||||
.properties
|
||||
.map(|RawProperties { property: p }| p.mapped(|p| p.into()).into())
|
||||
.unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<FlatFile> for RawFlatFile {
|
||||
fn from(val: FlatFile) -> Self {
|
||||
RawFlatFile {
|
||||
name: val.name,
|
||||
definition_reference: val.definition_reference,
|
||||
properties: match Vec1::try_from_vec(val.properties) {
|
||||
Ok(properties) => Some(RawProperties {
|
||||
property: properties.mapped(|p| p.into()),
|
||||
}),
|
||||
Err(_) => None,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
70
arcanite-addml/src/types/flat_file_definition.rs
Normal file
70
arcanite-addml/src/types/flat_file_definition.rs
Normal file
@ -0,0 +1,70 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct FlatFileDefinition {
|
||||
pub name: String,
|
||||
pub type_reference: Option<String>,
|
||||
pub description: Option<String>,
|
||||
pub properties: Vec<Vec<Property>>,
|
||||
pub external: bool,
|
||||
pub record_definition_field_identifier: Option<String>,
|
||||
pub record_definitions: Vec1<RecordDefinition>,
|
||||
}
|
||||
|
||||
impl From<RawFlatFileDefinition> for FlatFileDefinition {
|
||||
fn from(raw: RawFlatFileDefinition) -> Self {
|
||||
FlatFileDefinition {
|
||||
name: raw.name,
|
||||
type_reference: raw.type_reference,
|
||||
description: raw.description.map(|RawDescription(d)| d),
|
||||
properties: match raw.properties {
|
||||
Some(raw_properties) => raw_properties
|
||||
.into_iter()
|
||||
.map(|RawProperties { property: p }| p.mapped(|p| p.into()).into())
|
||||
.collect(),
|
||||
None => vec![],
|
||||
},
|
||||
external: match raw.external {
|
||||
Some(RawExternal) => true,
|
||||
None => false,
|
||||
},
|
||||
record_definition_field_identifier: raw
|
||||
.record_definition_field_identifier
|
||||
.map(|RawRecordDefinitionFieldIdentifier(rdfi)| rdfi),
|
||||
record_definitions: raw
|
||||
.record_definitions
|
||||
.record_definition
|
||||
.mapped(|rd| rd.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<FlatFileDefinition> for RawFlatFileDefinition {
|
||||
fn from(val: FlatFileDefinition) -> Self {
|
||||
RawFlatFileDefinition {
|
||||
name: val.name,
|
||||
type_reference: val.type_reference,
|
||||
description: val.description.map(RawDescription),
|
||||
properties: Vec1::try_from_vec(val.properties)
|
||||
.map(|properties| {
|
||||
properties
|
||||
.mapped(|p| RawProperties {
|
||||
property: Vec1::try_from_vec(p).unwrap().mapped(|p| p.into()),
|
||||
})
|
||||
.into()
|
||||
})
|
||||
.ok(),
|
||||
external: if val.external {
|
||||
Some(RawExternal)
|
||||
} else {
|
||||
None
|
||||
},
|
||||
record_definition_field_identifier: val
|
||||
.record_definition_field_identifier
|
||||
.map(RawRecordDefinitionFieldIdentifier),
|
||||
record_definitions: RawRecordDefinitions {
|
||||
record_definition: val.record_definitions.mapped(|rd| rd.into()),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
41
arcanite-addml/src/types/flat_file_definition_reference.rs
Normal file
41
arcanite-addml/src/types/flat_file_definition_reference.rs
Normal file
@ -0,0 +1,41 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct FlatFileDefinitionReference {
|
||||
pub name: String,
|
||||
pub record_definition_references: Vec<RecordDefinitionReference>,
|
||||
}
|
||||
|
||||
impl From<RawFlatFileDefinitionReference> for FlatFileDefinitionReference {
|
||||
fn from(raw: RawFlatFileDefinitionReference) -> Self {
|
||||
FlatFileDefinitionReference {
|
||||
name: raw.name,
|
||||
record_definition_references: raw
|
||||
.record_definition_references
|
||||
.map(
|
||||
|RawRecordDefinitionReferences {
|
||||
record_definition_reference,
|
||||
}| {
|
||||
record_definition_reference.mapped(|rdr| rdr.into()).into()
|
||||
},
|
||||
)
|
||||
.unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<FlatFileDefinitionReference> for RawFlatFileDefinitionReference {
|
||||
fn from(val: FlatFileDefinitionReference) -> Self {
|
||||
RawFlatFileDefinitionReference {
|
||||
name: val.name,
|
||||
record_definition_references: match Vec1::try_from_vec(val.record_definition_references)
|
||||
{
|
||||
Ok(record_definition_references) => Some(RawRecordDefinitionReferences {
|
||||
record_definition_reference: record_definition_references
|
||||
.mapped(|rdr| rdr.into()),
|
||||
}),
|
||||
Err(_) => None,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
43
arcanite-addml/src/types/flat_file_process.rs
Normal file
43
arcanite-addml/src/types/flat_file_process.rs
Normal file
@ -0,0 +1,43 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct FlatFileProcess {
|
||||
pub flat_file_reference: String,
|
||||
pub processes: Vec<Process>,
|
||||
pub record_processes: Vec<RecordProcesses>,
|
||||
}
|
||||
|
||||
impl From<RawFlatFileProcess> for FlatFileProcess {
|
||||
fn from(raw: RawFlatFileProcess) -> Self {
|
||||
FlatFileProcess {
|
||||
flat_file_reference: raw.flat_file_reference,
|
||||
processes: raw
|
||||
.processes
|
||||
.map(|RawProcesses { process }| process.mapped(|p| p.into()).into())
|
||||
.unwrap_or_default(),
|
||||
record_processes: raw
|
||||
.record_processes
|
||||
.into_iter()
|
||||
.map(|rrp| rrp.into())
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<FlatFileProcess> for RawFlatFileProcess {
|
||||
fn from(val: FlatFileProcess) -> Self {
|
||||
RawFlatFileProcess {
|
||||
flat_file_reference: val.flat_file_reference,
|
||||
processes: Vec1::try_from_vec(val.processes)
|
||||
.map(|processes| RawProcesses {
|
||||
process: processes.mapped(|p| p.into()),
|
||||
})
|
||||
.ok(),
|
||||
record_processes: val
|
||||
.record_processes
|
||||
.into_iter()
|
||||
.map(|rp| rp.into())
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
}
|
48
arcanite-addml/src/types/flat_file_type.rs
Normal file
48
arcanite-addml/src/types/flat_file_type.rs
Normal file
@ -0,0 +1,48 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct FlatFileType {
|
||||
pub name: String,
|
||||
pub description: Option<String>,
|
||||
pub charset: String,
|
||||
pub char_definitions: Vec<CharDefinition>,
|
||||
// TODO: ensure at least one of the following is present
|
||||
pub fixed_file_format: Option<FixedFileFormat>,
|
||||
pub delim_file_format: Option<DelimFileFormat>,
|
||||
}
|
||||
|
||||
impl From<RawFlatFileType> for FlatFileType {
|
||||
fn from(raw: RawFlatFileType) -> Self {
|
||||
FlatFileType {
|
||||
name: raw.name,
|
||||
description: raw.description.map(|RawDescription(d)| d),
|
||||
charset: raw.charset.0,
|
||||
char_definitions: raw
|
||||
.char_definitions
|
||||
.map(|RawCharDefinitions { char_definition }| {
|
||||
char_definition.mapped(|cd| cd.into()).into()
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
fixed_file_format: raw.fixed_file_format.map(|fff| fff.into()),
|
||||
delim_file_format: raw.delim_file_format.map(|dff| dff.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<FlatFileType> for RawFlatFileType {
|
||||
fn from(val: FlatFileType) -> Self {
|
||||
RawFlatFileType {
|
||||
name: val.name,
|
||||
description: val.description.map(|d| RawDescription(d)),
|
||||
charset: RawCharset(val.charset),
|
||||
char_definitions: match Vec1::try_from_vec(val.char_definitions) {
|
||||
Ok(char_definitions) => Some(RawCharDefinitions {
|
||||
char_definition: char_definitions.mapped(|cd| cd.into()),
|
||||
}),
|
||||
Err(_) => None,
|
||||
},
|
||||
fixed_file_format: val.fixed_file_format.map(|fff| fff.into()),
|
||||
delim_file_format: val.delim_file_format.map(|dff| dff.into()),
|
||||
}
|
||||
}
|
||||
}
|
64
arcanite-addml/src/types/flat_files.rs
Normal file
64
arcanite-addml/src/types/flat_files.rs
Normal file
@ -0,0 +1,64 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct FlatFiles {
|
||||
pub flat_file: Vec<FlatFile>,
|
||||
pub flat_file_definitions: Vec1<FlatFileDefinition>,
|
||||
pub structure_types: StructureTypes,
|
||||
pub queries: Vec<Query>,
|
||||
pub processes: Vec<Process>,
|
||||
pub flat_file_processes: Vec<FlatFileProcess>,
|
||||
}
|
||||
|
||||
impl From<RawFlatFiles> for FlatFiles {
|
||||
fn from(raw: RawFlatFiles) -> Self {
|
||||
FlatFiles {
|
||||
flat_file: raw.flat_file.into_iter().map(|ff| ff.into()).collect(),
|
||||
flat_file_definitions: raw
|
||||
.flat_file_definitions
|
||||
.flat_file_definition
|
||||
.mapped(|ffd| ffd.into()),
|
||||
structure_types: raw.structure_types.into(),
|
||||
queries: raw
|
||||
.queries
|
||||
.map(|RawQueries { query }| query.mapped(|q| q.into()).into())
|
||||
.unwrap_or_default(),
|
||||
processes: raw
|
||||
.processes
|
||||
.map(|RawProcesses { process }| process.mapped(|p| p.into()).into())
|
||||
.unwrap_or_default(),
|
||||
flat_file_processes: raw
|
||||
.flat_file_processes
|
||||
.into_iter()
|
||||
.map(|rffp| rffp.into())
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<FlatFiles> for RawFlatFiles {
|
||||
fn from(val: FlatFiles) -> Self {
|
||||
RawFlatFiles {
|
||||
flat_file: val.flat_file.into_iter().map(|ff| ff.into()).collect(),
|
||||
flat_file_definitions: RawFlatFileDefinitions {
|
||||
flat_file_definition: val.flat_file_definitions.mapped(|ffd| ffd.into()),
|
||||
},
|
||||
structure_types: val.structure_types.into(),
|
||||
queries: Vec1::try_from_vec(val.queries)
|
||||
.map(|queries| RawQueries {
|
||||
query: queries.mapped(|q| q.into()),
|
||||
})
|
||||
.ok(),
|
||||
processes: Vec1::try_from_vec(val.processes)
|
||||
.map(|processes| RawProcesses {
|
||||
process: processes.mapped(|p| p.into()),
|
||||
})
|
||||
.ok(),
|
||||
flat_file_processes: val
|
||||
.flat_file_processes
|
||||
.into_iter()
|
||||
.map(|rffp| rffp.into())
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
}
|
18
arcanite-addml/src/types/header_level.rs
Normal file
18
arcanite-addml/src/types/header_level.rs
Normal file
@ -0,0 +1,18 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct HeaderLevel {
|
||||
// TODO: there seems to be a format for this, but it's left unspecified?
|
||||
}
|
||||
|
||||
impl From<RawHeaderLevel> for HeaderLevel {
|
||||
fn from(_: RawHeaderLevel) -> Self {
|
||||
HeaderLevel {}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<HeaderLevel> for RawHeaderLevel {
|
||||
fn from(_: HeaderLevel) -> Self {
|
||||
RawHeaderLevel {}
|
||||
}
|
||||
}
|
78
arcanite-addml/src/types/key.rs
Normal file
78
arcanite-addml/src/types/key.rs
Normal file
@ -0,0 +1,78 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum KeyType {
|
||||
PrimaryKey,
|
||||
AlternateKey,
|
||||
ForeignKey {
|
||||
flat_file_definition_reference: FlatFileDefinitionReference,
|
||||
relation_type: String,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct Key {
|
||||
pub name: String,
|
||||
pub key_type: KeyType,
|
||||
|
||||
pub field_definition_references: Vec1<String>,
|
||||
}
|
||||
|
||||
impl From<RawKey> for Key {
|
||||
fn from(raw: RawKey) -> Self {
|
||||
Key {
|
||||
name: raw.name,
|
||||
// TODO: this state should be validated properly.
|
||||
// Falling back to PrimaryKey is a bad idea.
|
||||
key_type: if raw.primary_key.is_some() {
|
||||
KeyType::PrimaryKey
|
||||
} else if raw.alternate_key.is_some() {
|
||||
KeyType::AlternateKey
|
||||
} else if raw.foreign_key.is_some() {
|
||||
let fk = raw.foreign_key.unwrap();
|
||||
KeyType::ForeignKey {
|
||||
flat_file_definition_reference: fk.flat_file_definition_reference.into(),
|
||||
relation_type: fk.relation_type.0,
|
||||
}
|
||||
} else {
|
||||
KeyType::PrimaryKey
|
||||
},
|
||||
field_definition_references: raw
|
||||
.field_definition_references
|
||||
.field_definition_reference
|
||||
.mapped(|fdr| fdr.name),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Key> for RawKey {
|
||||
fn from(val: Key) -> Self {
|
||||
let (primary_key, alternate_key, foreign_key) = match val.key_type {
|
||||
KeyType::PrimaryKey => (Some(RawPrimaryKey), None, None),
|
||||
KeyType::AlternateKey => (None, Some(RawAlternateKey), None),
|
||||
KeyType::ForeignKey {
|
||||
flat_file_definition_reference,
|
||||
relation_type,
|
||||
} => (
|
||||
None,
|
||||
None,
|
||||
Some(RawForeignKey {
|
||||
flat_file_definition_reference: flat_file_definition_reference.into(),
|
||||
relation_type: RawRelationType(relation_type),
|
||||
}),
|
||||
),
|
||||
};
|
||||
|
||||
RawKey {
|
||||
name: val.name,
|
||||
primary_key,
|
||||
alternate_key,
|
||||
foreign_key,
|
||||
field_definition_references: RawFieldDefinitionReferences {
|
||||
field_definition_reference: val
|
||||
.field_definition_references
|
||||
.mapped(|name| RawFieldDefinitionReference { name }),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
25
arcanite-addml/src/types/parameter.rs
Normal file
25
arcanite-addml/src/types/parameter.rs
Normal file
@ -0,0 +1,25 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct Parameter {
|
||||
pub name: String,
|
||||
pub value: String,
|
||||
}
|
||||
|
||||
impl From<RawParameter> for Parameter {
|
||||
fn from(raw: RawParameter) -> Self {
|
||||
Parameter {
|
||||
name: raw.name,
|
||||
value: raw.value,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Parameter> for RawParameter {
|
||||
fn from(val: Parameter) -> Self {
|
||||
RawParameter {
|
||||
name: val.name,
|
||||
value: val.value,
|
||||
}
|
||||
}
|
||||
}
|
33
arcanite-addml/src/types/process.rs
Normal file
33
arcanite-addml/src/types/process.rs
Normal file
@ -0,0 +1,33 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct Process {
|
||||
pub name: String,
|
||||
pub parameters: Vec<Parameter>,
|
||||
}
|
||||
|
||||
impl From<RawProcess> for Process {
|
||||
fn from(raw: RawProcess) -> Self {
|
||||
Process {
|
||||
name: raw.name,
|
||||
parameters: raw
|
||||
.parameters
|
||||
.map(|RawParameters { parameter: p }| p.mapped(|p| p.into()).into())
|
||||
.unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Process> for RawProcess {
|
||||
fn from(val: Process) -> Self {
|
||||
RawProcess {
|
||||
name: val.name,
|
||||
parameters: match Vec1::try_from_vec(val.parameters) {
|
||||
Ok(parameters) => Some(RawParameters {
|
||||
parameter: parameters.mapped(|p| p.into()),
|
||||
}),
|
||||
Err(_) => None,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
42
arcanite-addml/src/types/property.rs
Normal file
42
arcanite-addml/src/types/property.rs
Normal file
@ -0,0 +1,42 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct Property {
|
||||
pub name: String,
|
||||
pub data_type: Option<String>,
|
||||
pub format: Option<String>,
|
||||
pub value: Option<String>,
|
||||
pub properties: Vec<Property>,
|
||||
}
|
||||
|
||||
impl From<RawProperty> for Property {
|
||||
fn from(raw: RawProperty) -> Self {
|
||||
Property {
|
||||
name: raw.name,
|
||||
data_type: raw.data_type,
|
||||
format: raw.format,
|
||||
value: raw.value.map(|RawValue(v)| v),
|
||||
properties: raw
|
||||
.properties
|
||||
.map(|RawProperties { property: p }| p.mapped(|p| p.into()).into())
|
||||
.unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Property> for RawProperty {
|
||||
fn from(val: Property) -> Self {
|
||||
RawProperty {
|
||||
name: val.name,
|
||||
data_type: val.data_type,
|
||||
format: val.format,
|
||||
value: val.value.map(RawValue),
|
||||
properties: match Vec1::try_from_vec(val.properties) {
|
||||
Ok(properties) => Some(RawProperties {
|
||||
property: properties.mapped(|p| p.into()),
|
||||
}),
|
||||
Err(_) => None,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
28
arcanite-addml/src/types/query.rs
Normal file
28
arcanite-addml/src/types/query.rs
Normal file
@ -0,0 +1,28 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct Query {
|
||||
pub name: String,
|
||||
pub description: Option<String>,
|
||||
pub statement: String,
|
||||
}
|
||||
|
||||
impl From<RawQuery> for Query {
|
||||
fn from(raw: RawQuery) -> Self {
|
||||
Query {
|
||||
name: raw.name,
|
||||
description: raw.description.map(|RawDescription(d)| d),
|
||||
statement: raw.statement.0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Query> for RawQuery {
|
||||
fn from(val: Query) -> Self {
|
||||
RawQuery {
|
||||
name: val.name,
|
||||
description: val.description.map(RawDescription),
|
||||
statement: RawStatement(val.statement),
|
||||
}
|
||||
}
|
||||
}
|
94
arcanite-addml/src/types/record_definition.rs
Normal file
94
arcanite-addml/src/types/record_definition.rs
Normal file
@ -0,0 +1,94 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct RecordDefinition {
|
||||
pub name: String,
|
||||
pub type_reference: Option<String>,
|
||||
pub description: Option<String>,
|
||||
pub properties: Vec<Property>,
|
||||
pub record_definition_field_value: Option<String>,
|
||||
pub incomplete: bool,
|
||||
pub fixed_length: Option<usize>,
|
||||
pub repeating_groups: Vec<RepeatingGroup>,
|
||||
pub keys: Vec<Key>,
|
||||
pub field_definitions: Vec1<FieldDefinition>,
|
||||
pub header_level: Option<HeaderLevel>,
|
||||
}
|
||||
|
||||
impl From<RawRecordDefinition> for RecordDefinition {
|
||||
fn from(raw: RawRecordDefinition) -> Self {
|
||||
RecordDefinition {
|
||||
name: raw.name,
|
||||
type_reference: raw.type_reference,
|
||||
description: raw.description.map(|RawDescription(d)| d),
|
||||
properties: raw
|
||||
.properties
|
||||
.map(|RawProperties { property: p }| p.mapped(|p| p.into()).into())
|
||||
.unwrap_or_default(),
|
||||
record_definition_field_value: raw
|
||||
.record_definition_field_value
|
||||
.map(|RawRecordDefinitionFieldValue(rdfv)| rdfv),
|
||||
incomplete: match raw.incomplete {
|
||||
Some(RawIncomplete) => true,
|
||||
None => false,
|
||||
},
|
||||
fixed_length: raw.fixed_length.map(|RawFixedLength(l)| l),
|
||||
repeating_groups: raw
|
||||
.repeating_groups
|
||||
.map(|RawRepeatingGroups { repeating_group }| {
|
||||
repeating_group.mapped(|rg| rg.into()).into()
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
keys: raw
|
||||
.keys
|
||||
.map(|RawKeys { key }| key.mapped(|k| k.into()).into())
|
||||
.unwrap_or_default(),
|
||||
field_definitions: raw
|
||||
.field_definitions
|
||||
.field_definition
|
||||
.mapped(|fd| fd.into()),
|
||||
header_level: raw.header_level.map(|hl| hl.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RecordDefinition> for RawRecordDefinition {
|
||||
fn from(val: RecordDefinition) -> Self {
|
||||
RawRecordDefinition {
|
||||
name: val.name,
|
||||
type_reference: val.type_reference,
|
||||
description: val.description.map(RawDescription),
|
||||
properties: match Vec1::try_from_vec(val.properties) {
|
||||
Ok(properties) => Some(RawProperties {
|
||||
property: properties.mapped(|p| p.into()),
|
||||
}),
|
||||
Err(_) => None,
|
||||
},
|
||||
record_definition_field_value: val
|
||||
.record_definition_field_value
|
||||
.map(RawRecordDefinitionFieldValue),
|
||||
incomplete: if val.incomplete {
|
||||
Some(RawIncomplete)
|
||||
} else {
|
||||
None
|
||||
},
|
||||
fixed_length: val.fixed_length.map(RawFixedLength),
|
||||
repeating_groups: match Vec1::try_from_vec(val.repeating_groups) {
|
||||
Ok(repeating_groups) => Some(RawRepeatingGroups {
|
||||
repeating_group: repeating_groups.mapped(|rg| rg.into()),
|
||||
}),
|
||||
Err(_) => None,
|
||||
},
|
||||
keys: match Vec1::try_from_vec(val.keys) {
|
||||
Ok(keys) => Some(RawKeys {
|
||||
key: keys.mapped(|k| k.into()),
|
||||
}),
|
||||
Err(_) => None,
|
||||
},
|
||||
field_definitions: RawFieldDefinitions {
|
||||
field_definition: val.field_definitions.mapped(|fd| fd.into()),
|
||||
},
|
||||
header_level: val.header_level.map(|hl| hl.into()),
|
||||
}
|
||||
}
|
||||
}
|
40
arcanite-addml/src/types/record_definition_reference.rs
Normal file
40
arcanite-addml/src/types/record_definition_reference.rs
Normal file
@ -0,0 +1,40 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct RecordDefinitionReference {
|
||||
pub name: String,
|
||||
pub field_definition_references: Vec<String>,
|
||||
}
|
||||
|
||||
impl From<RawRecordDefinitionReference> for RecordDefinitionReference {
|
||||
fn from(raw: RawRecordDefinitionReference) -> Self {
|
||||
RecordDefinitionReference {
|
||||
name: raw.name,
|
||||
field_definition_references: raw
|
||||
.field_definition_references
|
||||
.map(
|
||||
|RawFieldDefinitionReferences {
|
||||
field_definition_reference,
|
||||
}| {
|
||||
field_definition_reference.mapped(|fdr| fdr.name).into()
|
||||
},
|
||||
)
|
||||
.unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RecordDefinitionReference> for RawRecordDefinitionReference {
|
||||
fn from(val: RecordDefinitionReference) -> Self {
|
||||
RawRecordDefinitionReference {
|
||||
name: val.name,
|
||||
field_definition_references: match Vec1::try_from_vec(val.field_definition_references) {
|
||||
Ok(field_definition_references) => Some(RawFieldDefinitionReferences {
|
||||
field_definition_reference: field_definition_references
|
||||
.mapped(|name| RawFieldDefinitionReference { name }),
|
||||
}),
|
||||
Err(_) => None,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
42
arcanite-addml/src/types/record_processes.rs
Normal file
42
arcanite-addml/src/types/record_processes.rs
Normal file
@ -0,0 +1,42 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct RecordProcesses {
|
||||
// TODO: report this as a bug in the spec
|
||||
// pub name: String,
|
||||
pub definition_reference: String,
|
||||
pub processes: Vec<Process>,
|
||||
pub field_processes: Option<Vec<FieldProcesses>>,
|
||||
}
|
||||
|
||||
impl From<RawRecordProcesses> for RecordProcesses {
|
||||
fn from(raw: RawRecordProcesses) -> Self {
|
||||
RecordProcesses {
|
||||
definition_reference: raw.definition_reference,
|
||||
processes: raw
|
||||
.processes
|
||||
.map(|RawProcesses { process }| process.mapped(|p| p.into()).into())
|
||||
.unwrap_or_default(),
|
||||
field_processes: raw
|
||||
.field_processes
|
||||
.map(|rfps| rfps.into_iter().map(|rfp| rfp.into()).collect()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RecordProcesses> for RawRecordProcesses {
|
||||
fn from(val: RecordProcesses) -> Self {
|
||||
RawRecordProcesses {
|
||||
// name: val.name,
|
||||
definition_reference: val.definition_reference,
|
||||
processes: Vec1::try_from_vec(val.processes)
|
||||
.map(|processes| RawProcesses {
|
||||
process: processes.mapped(|p| p.into()),
|
||||
})
|
||||
.ok(),
|
||||
field_processes: val
|
||||
.field_processes
|
||||
.map(|rfps| rfps.into_iter().map(|rfp| rfp.into()).collect()),
|
||||
}
|
||||
}
|
||||
}
|
31
arcanite-addml/src/types/record_type.rs
Normal file
31
arcanite-addml/src/types/record_type.rs
Normal file
@ -0,0 +1,31 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct RecordType {
|
||||
pub name: String,
|
||||
pub description: Option<String>,
|
||||
pub trimmed: bool,
|
||||
}
|
||||
|
||||
impl From<RawRecordType> for RecordType {
|
||||
fn from(raw: RawRecordType) -> Self {
|
||||
RecordType {
|
||||
name: raw.name,
|
||||
description: raw.description.map(|RawDescription(d)| d),
|
||||
trimmed: match raw.trimmed {
|
||||
Some(RawTrimmed) => true,
|
||||
None => false,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RecordType> for RawRecordType {
|
||||
fn from(val: RecordType) -> Self {
|
||||
RawRecordType {
|
||||
name: val.name,
|
||||
description: val.description.map(RawDescription),
|
||||
trimmed: if val.trimmed { Some(RawTrimmed) } else { None },
|
||||
}
|
||||
}
|
||||
}
|
28
arcanite-addml/src/types/reference.rs
Normal file
28
arcanite-addml/src/types/reference.rs
Normal file
@ -0,0 +1,28 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct Reference {
|
||||
pub name: Option<String>,
|
||||
pub context: Option<Context>,
|
||||
pub content: Option<Content>,
|
||||
}
|
||||
|
||||
impl From<RawReference> for Reference {
|
||||
fn from(raw: RawReference) -> Self {
|
||||
Reference {
|
||||
name: raw.name,
|
||||
context: raw.context.map(|c| c.into()),
|
||||
content: raw.content.map(|c| c.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Reference> for RawReference {
|
||||
fn from(val: Reference) -> Self {
|
||||
RawReference {
|
||||
name: val.name,
|
||||
context: val.context.map(|c| c.into()),
|
||||
content: val.content.map(|c| c.into()),
|
||||
}
|
||||
}
|
||||
}
|
43
arcanite-addml/src/types/repeating_group.rs
Normal file
43
arcanite-addml/src/types/repeating_group.rs
Normal file
@ -0,0 +1,43 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct RepeatingGroup {
|
||||
pub name: String,
|
||||
// TODO: one of repeating_group_occurrence_field or fixed_occurrences must be present, maybe create enum?
|
||||
pub repeating_group_occurrence_field: Option<RepeatingGroupOccurrenceField>,
|
||||
pub fixed_occurrences: Option<usize>,
|
||||
pub field_definition_references: Vec1<String>,
|
||||
}
|
||||
|
||||
impl From<RawRepeatingGroup> for RepeatingGroup {
|
||||
fn from(raw: RawRepeatingGroup) -> Self {
|
||||
RepeatingGroup {
|
||||
name: raw.name,
|
||||
repeating_group_occurrence_field: raw
|
||||
.repeating_group_occurrence_field
|
||||
.map(|rgof| rgof.into()),
|
||||
fixed_occurrences: raw.fixed_occurrences.map(|RawFixedOccurrences(u)| u),
|
||||
field_definition_references: raw
|
||||
.field_definition_references
|
||||
.field_definition_reference
|
||||
.mapped(|fdr| fdr.name),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RepeatingGroup> for RawRepeatingGroup {
|
||||
fn from(val: RepeatingGroup) -> Self {
|
||||
RawRepeatingGroup {
|
||||
name: val.name,
|
||||
repeating_group_occurrence_field: val
|
||||
.repeating_group_occurrence_field
|
||||
.map(|rgof| rgof.into()),
|
||||
fixed_occurrences: val.fixed_occurrences.map(RawFixedOccurrences),
|
||||
field_definition_references: RawFieldDefinitionReferences {
|
||||
field_definition_reference: val
|
||||
.field_definition_references
|
||||
.mapped(|name| RawFieldDefinitionReference { name }),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
22
arcanite-addml/src/types/repeating_group_occurrence_field.rs
Normal file
22
arcanite-addml/src/types/repeating_group_occurrence_field.rs
Normal file
@ -0,0 +1,22 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct RepeatingGroupOccurrenceField {
|
||||
definition_reference: String,
|
||||
}
|
||||
|
||||
impl From<RawRepeatingGroupOccurrenceField> for RepeatingGroupOccurrenceField {
|
||||
fn from(raw: RawRepeatingGroupOccurrenceField) -> Self {
|
||||
RepeatingGroupOccurrenceField {
|
||||
definition_reference: raw.definition_reference,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RepeatingGroupOccurrenceField> for RawRepeatingGroupOccurrenceField {
|
||||
fn from(val: RepeatingGroupOccurrenceField) -> Self {
|
||||
RawRepeatingGroupOccurrenceField {
|
||||
definition_reference: val.definition_reference,
|
||||
}
|
||||
}
|
||||
}
|
39
arcanite-addml/src/types/structure_types.rs
Normal file
39
arcanite-addml/src/types/structure_types.rs
Normal file
@ -0,0 +1,39 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct StructureTypes {
|
||||
pub flat_file_types: Vec1<FlatFileType>,
|
||||
pub record_types: Vec<RecordType>,
|
||||
pub field_types: Vec1<FieldType>,
|
||||
}
|
||||
|
||||
impl From<RawStructureTypes> for StructureTypes {
|
||||
fn from(raw: RawStructureTypes) -> Self {
|
||||
StructureTypes {
|
||||
flat_file_types: raw.flat_file_types.flat_file_type.mapped(|fft| fft.into()),
|
||||
record_types: raw
|
||||
.record_types
|
||||
.map(|RawRecordTypes { record_type }| record_type.mapped(|rt| rt.into()).into())
|
||||
.unwrap_or_default(),
|
||||
field_types: raw.field_types.field_type.mapped(|ft| ft.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StructureTypes> for RawStructureTypes {
|
||||
fn from(val: StructureTypes) -> Self {
|
||||
RawStructureTypes {
|
||||
flat_file_types: RawFlatFileTypes {
|
||||
flat_file_type: val.flat_file_types.mapped(|fft| fft.into()),
|
||||
},
|
||||
record_types: Vec1::try_from_vec(val.record_types)
|
||||
.map(|record_types| RawRecordTypes {
|
||||
record_type: record_types.mapped(|rt| rt.into()),
|
||||
})
|
||||
.ok(),
|
||||
field_types: RawFieldTypes {
|
||||
field_type: val.field_types.mapped(|ft| ft.into()),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user