1pub mod dotl;
14pub mod dxf;
15mod report;
16pub mod svg;
17pub mod zip;
18
19use dotloom_engine::{
20 ApplyOptions, Command, CommitReport, Engine, EngineError, NewEntity, Transaction,
21 document::{Color, LayerId},
22};
23
24pub use dotl::{DotlError, DotlFile, DotlLimits, LoadReport, Manifest, read_dotl, write_dotl};
25pub use report::{ConversionReport, Loss, LossKind};
26
27pub fn import_into(
29 engine: &mut Engine,
30 label: &str,
31 layers: &[(String, Option<Color>)],
32 entities: Vec<(usize, NewEntity)>,
33) -> Result<CommitReport, EngineError> {
34 let ids = engine.reserve_ids(layers.len());
35 let mut commands = Vec::with_capacity(layers.len() + entities.len());
36 let mut layer_ids = Vec::with_capacity(layers.len());
37 for ((name, color), id) in layers.iter().zip(ids) {
38 let lid = LayerId(id);
39 layer_ids.push(lid);
40 commands.push(Command::AddLayer { id: Some(lid), name: name.clone() });
41 if let Some(c) = color {
42 commands.push(Command::UpdateLayer {
43 id: lid,
44 patch: dotloom_engine::LayerPatch { color: Some(*c), ..Default::default() },
45 });
46 }
47 }
48 for (li, mut e) in entities {
49 e.layer = layer_ids.get(li).copied();
50 commands.push(Command::CreateEntity { id: None, entity: e });
51 }
52 engine.apply(Transaction::new(label, commands), ApplyOptions::default())
53}