pub struct SketchImporter;Expand description
Sketch importer for parsing Excalidraw sketch YAML files
Implementations§
Source§impl SketchImporter
impl SketchImporter
Sourcepub fn new() -> SketchImporter
pub fn new() -> SketchImporter
Create a new Sketch importer instance
Sourcepub fn import(&self, yaml_content: &str) -> Result<Sketch, ImportError>
pub fn import(&self, yaml_content: &str) -> Result<Sketch, ImportError>
Import a sketch from YAML content
Optionally validates against the JSON schema if the schema-validation feature is enabled.
§Arguments
yaml_content- Sketch YAML content as a string
§Returns
A Sketch parsed from the YAML content
§Example
use data_modelling_core::import::sketch::SketchImporter;
let importer = SketchImporter::new();
let yaml = r#"
id: 770e8400-e29b-41d4-a716-446655440001
number: 1
title: "Architecture Diagram"
sketchType: architecture
status: published
excalidrawData: "{}"
createdAt: "2024-01-15T10:00:00Z"
updatedAt: "2024-01-15T10:00:00Z"
"#;
let sketch = importer.import(yaml).unwrap();
assert_eq!(sketch.title, "Architecture Diagram");Sourcepub fn import_without_validation(
&self,
yaml_content: &str,
) -> Result<Sketch, ImportError>
pub fn import_without_validation( &self, yaml_content: &str, ) -> Result<Sketch, ImportError>
Sourcepub fn import_index(
&self,
yaml_content: &str,
) -> Result<SketchIndex, ImportError>
pub fn import_index( &self, yaml_content: &str, ) -> Result<SketchIndex, ImportError>
Import a sketch index from YAML content
§Arguments
yaml_content- Sketch index YAML content (sketches.yaml)
§Returns
A SketchIndex parsed from the YAML content
§Example
use data_modelling_core::import::sketch::SketchImporter;
let importer = SketchImporter::new();
let yaml = r#"
schemaVersion: "1.0"
sketches: []
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<Sketch>, Vec<ImportError>), ImportError>
pub fn import_from_directory( &self, dir_path: &Path, ) -> Result<(Vec<Sketch>, Vec<ImportError>), ImportError>
Sourcepub fn import_by_domain(
&self,
dir_path: &Path,
domain: &str,
) -> Result<(Vec<Sketch>, Vec<ImportError>), ImportError>
pub fn import_by_domain( &self, dir_path: &Path, domain: &str, ) -> Result<(Vec<Sketch>, Vec<ImportError>), ImportError>
Trait Implementations§
Source§impl Default for SketchImporter
impl Default for SketchImporter
Source§fn default() -> SketchImporter
fn default() -> SketchImporter
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for SketchImporter
impl RefUnwindSafe for SketchImporter
impl Send for SketchImporter
impl Sync for SketchImporter
impl Unpin for SketchImporter
impl UnwindSafe for SketchImporter
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