pub struct DecisionImporter;Expand description
Decision importer for parsing MADR-compliant YAML files
Implementations§
Source§impl DecisionImporter
impl DecisionImporter
Sourcepub fn import(&self, yaml_content: &str) -> Result<Decision, ImportError>
pub fn import(&self, yaml_content: &str) -> Result<Decision, ImportError>
Import a decision from YAML content
Optionally validates against the JSON schema if the schema-validation feature is enabled.
§Arguments
yaml_content- Decision YAML content as a string
§Returns
A Decision parsed from the YAML content
§Example
use data_modelling_core::import::decision::DecisionImporter;
let importer = DecisionImporter::new();
let yaml = r#"
id: 550e8400-e29b-41d4-a716-446655440000
number: 1
title: "Use ODCS Format for Data Contracts"
status: accepted
category: datadesign
date: "2024-01-15T10:00:00Z"
context: "We need a standard format for data contracts."
decision: "Use ODCS v3.1.0 format."
createdAt: "2024-01-15T10:00:00Z"
updatedAt: "2024-01-15T10:00:00Z"
"#;
let decision = importer.import(yaml).unwrap();
assert_eq!(decision.title, "Use ODCS Format for Data Contracts");Sourcepub fn import_without_validation(
&self,
yaml_content: &str,
) -> Result<Decision, ImportError>
pub fn import_without_validation( &self, yaml_content: &str, ) -> Result<Decision, ImportError>
Sourcepub fn import_index(
&self,
yaml_content: &str,
) -> Result<DecisionIndex, ImportError>
pub fn import_index( &self, yaml_content: &str, ) -> Result<DecisionIndex, ImportError>
Import a decisions index from YAML content
§Arguments
yaml_content- Decisions index YAML content (decisions.yaml)
§Returns
A DecisionIndex parsed from the YAML content
§Example
use data_modelling_core::import::decision::DecisionImporter;
let importer = DecisionImporter::new();
let yaml = r#"
schema_version: "1.0"
decisions: []
next_number: 1
"#;
let index = importer.import_index(yaml).unwrap();
assert_eq!(index.next_number, 1);Sourcepub fn import_from_directory(
&self,
dir_path: &Path,
) -> Result<(Vec<Decision>, Vec<ImportError>), ImportError>
pub fn import_from_directory( &self, dir_path: &Path, ) -> Result<(Vec<Decision>, Vec<ImportError>), ImportError>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DecisionImporter
impl RefUnwindSafe for DecisionImporter
impl Send for DecisionImporter
impl Sync for DecisionImporter
impl Unpin for DecisionImporter
impl UnwindSafe for DecisionImporter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more