pub struct KnowledgeImporter;Expand description
Knowledge importer for parsing Knowledge Base article YAML files
Implementations§
Source§impl KnowledgeImporter
impl KnowledgeImporter
Sourcepub fn import(
&self,
yaml_content: &str,
) -> Result<KnowledgeArticle, ImportError>
pub fn import( &self, yaml_content: &str, ) -> Result<KnowledgeArticle, ImportError>
Import a knowledge article from YAML content
Optionally validates against the JSON schema if the schema-validation feature is enabled.
§Arguments
yaml_content- Knowledge article YAML content as a string
§Returns
A KnowledgeArticle parsed from the YAML content
§Example
use data_modelling_core::import::knowledge::KnowledgeImporter;
let importer = KnowledgeImporter::new();
let yaml = r#"
id: 660e8400-e29b-41d4-a716-446655440000
number: 1
title: "Data Classification Guide"
articleType: guide
status: published
summary: "This guide explains data classification."
content: "Data classification is essential for governance."
authors:
- "data-governance@example.com"
createdAt: "2024-01-15T10:00:00Z"
updatedAt: "2024-01-15T10:00:00Z"
"#;
let article = importer.import(yaml).unwrap();
assert_eq!(article.title, "Data Classification Guide");Sourcepub fn import_without_validation(
&self,
yaml_content: &str,
) -> Result<KnowledgeArticle, ImportError>
pub fn import_without_validation( &self, yaml_content: &str, ) -> Result<KnowledgeArticle, ImportError>
Sourcepub fn import_index(
&self,
yaml_content: &str,
) -> Result<KnowledgeIndex, ImportError>
pub fn import_index( &self, yaml_content: &str, ) -> Result<KnowledgeIndex, ImportError>
Import a knowledge index from YAML content
§Arguments
yaml_content- Knowledge index YAML content (knowledge.yaml)
§Returns
A KnowledgeIndex parsed from the YAML content
§Example
use data_modelling_core::import::knowledge::KnowledgeImporter;
let importer = KnowledgeImporter::new();
let yaml = r#"
schemaVersion: "1.0"
articles: []
nextNumber: 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<KnowledgeArticle>, Vec<ImportError>), ImportError>
pub fn import_from_directory( &self, dir_path: &Path, ) -> Result<(Vec<KnowledgeArticle>, Vec<ImportError>), ImportError>
Sourcepub fn import_by_domain(
&self,
dir_path: &Path,
domain: &str,
) -> Result<(Vec<KnowledgeArticle>, Vec<ImportError>), ImportError>
pub fn import_by_domain( &self, dir_path: &Path, domain: &str, ) -> Result<(Vec<KnowledgeArticle>, Vec<ImportError>), ImportError>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for KnowledgeImporter
impl RefUnwindSafe for KnowledgeImporter
impl Send for KnowledgeImporter
impl Sync for KnowledgeImporter
impl Unpin for KnowledgeImporter
impl UnwindSafe for KnowledgeImporter
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