diff --git a/examples/one_shot_benchmark.rs b/examples/one_shot_benchmark.rs index 05c082eb..aaf52b06 100644 --- a/examples/one_shot_benchmark.rs +++ b/examples/one_shot_benchmark.rs @@ -12,7 +12,7 @@ use rsdd::repr::dtree::DTree; use rsdd::repr::var_label::VarLabel; use rsdd::repr::var_order::VarOrder; use rsdd::repr::vtree::VTree; -use rsdd::serialize::{ser_bdd, ser_sdd, ser_vtree}; +use rsdd::serialize::{BDDSerializer, SDDSerializer, VTreeSerializer}; use serde::{Deserialize, Serialize}; use serde_json::json; use std::fs::{self, File}; @@ -99,14 +99,14 @@ fn compile_sdd_dtree(str: String, _args: &Args) -> BenchResult { let sdd = builder.compile_cnf(&cnf); if let Some(path) = &_args.dump_sdd { - let json = ser_sdd::SDDSerializer::from_sdd(sdd); + let json = SDDSerializer::from_sdd(sdd); let mut file = File::create(path).unwrap(); let r = file.write_all(serde_json::to_string(&json).unwrap().as_bytes()); assert!(r.is_ok(), "Error writing file"); } if let Some(path) = &_args.dump_vtree { - let json = ser_vtree::VTreeSerializer::from_vtree(&vtree); + let json = VTreeSerializer::from_vtree(&vtree); let mut file = File::create(path).unwrap(); let r = file.write_all(serde_json::to_string(&json).unwrap().as_bytes()); assert!(r.is_ok(), "Error writing file"); @@ -129,14 +129,14 @@ fn compile_sdd_rightlinear(str: String, _args: &Args) -> BenchResult { let sdd = builder.compile_cnf(&cnf); if let Some(path) = &_args.dump_sdd { - let json = ser_sdd::SDDSerializer::from_sdd(sdd); + let json = SDDSerializer::from_sdd(sdd); let mut file = File::create(path).unwrap(); let r = file.write_all(serde_json::to_string(&json).unwrap().as_bytes()); assert!(r.is_ok(), "Error writing file"); } if let Some(path) = &_args.dump_vtree { - let json = ser_vtree::VTreeSerializer::from_vtree(&vtree); + let json = VTreeSerializer::from_vtree(&vtree); let mut file = File::create(path).unwrap(); let r = file.write_all(serde_json::to_string(&json).unwrap().as_bytes()); assert!(r.is_ok(), "Error writing file"); @@ -157,7 +157,7 @@ fn compile_bdd(str: String, _args: &Args) -> BenchResult { let bdd = builder.compile_cnf(&cnf); if let Some(path) = &_args.dump_bdd { - let json = ser_bdd::BDDSerializer::from_bdd(bdd); + let json = BDDSerializer::from_bdd(bdd); let mut file = File::create(path).unwrap(); let r = file.write_all(serde_json::to_string(&json).unwrap().as_bytes()); assert!(r.is_ok(), "Error writing file"); @@ -182,7 +182,7 @@ fn compile_bdd_dtree(str: String, _args: &Args) -> BenchResult { let bdd = builder.compile_plan(&plan); if let Some(path) = &_args.dump_bdd { - let json = ser_bdd::BDDSerializer::from_bdd(bdd); + let json = BDDSerializer::from_bdd(bdd); let mut file = File::create(path).unwrap(); let r = file.write_all(serde_json::to_string(&json).unwrap().as_bytes()); assert!(r.is_ok(), "Error writing file"); diff --git a/src/serialize/mod.rs b/src/serialize/mod.rs index 09d36ace..915e5163 100644 --- a/src/serialize/mod.rs +++ b/src/serialize/mod.rs @@ -1,5 +1,9 @@ //! contains representations of core datastructures that can be serialized -pub mod ser_bdd; -pub mod ser_sdd; -pub mod ser_vtree; +mod ser_bdd; +mod ser_sdd; +mod ser_vtree; + +pub use self::ser_bdd::*; +pub use self::ser_sdd::*; +pub use self::ser_vtree::*; diff --git a/src/wasm/mod.rs b/src/wasm/mod.rs index 71cfe7a4..ae184fc9 100644 --- a/src/wasm/mod.rs +++ b/src/wasm/mod.rs @@ -10,9 +10,7 @@ use crate::repr::dtree::DTree; use crate::repr::var_order::VarOrder; use crate::repr::wmc::WmcParams; use crate::repr::{cnf::Cnf, var_label::VarLabel, vtree::VTree}; -use crate::serialize::ser_sdd::SDDSerializer; -use crate::serialize::ser_vtree::VTreeSerializer; -use crate::serialize::{ser_bdd, ser_sdd, ser_vtree}; +use crate::serialize::{BDDSerializer, SDDSerializer, VTreeSerializer}; use crate::util::semirings::finitefield::FiniteField; use crate::util::semirings::semiring_traits::Semiring; use wasm_bindgen::prelude::*; @@ -42,7 +40,7 @@ pub fn vtree(cnf_input: String, vtree_type_input: JsValue) -> Result String { let builder = RobddBuilder::>::new_default_order_lru(cnf.num_vars()); let bdd = builder.compile_cnf(&cnf); - let json = ser_bdd::BDDSerializer::from_bdd(bdd); + let json = BDDSerializer::from_bdd(bdd); serde_json::to_string(&json).unwrap() } @@ -70,7 +68,7 @@ pub fn bdd_with_var_order(cnf_input: String, order: &[u64]) -> String { let builder = RobddBuilder::new(var_order, BddApplyTable::new(21)); let bdd = builder.compile_cnf(&cnf); - let json = ser_bdd::BDDSerializer::from_bdd(bdd); + let json = BDDSerializer::from_bdd(bdd); serde_json::to_string(&json).unwrap() } @@ -87,7 +85,7 @@ pub fn sdd(cnf_input: String, vtree_type_input: JsValue) -> Result Result { let res = SddModelCountResult { model_count: model_count.value(), - sdd: ser_sdd::SDDSerializer::from_sdd(sdd), - vtree: ser_vtree::VTreeSerializer::from_vtree(&vtree), + sdd: SDDSerializer::from_sdd(sdd), + vtree: VTreeSerializer::from_vtree(&vtree), }; Ok(serde_wasm_bindgen::to_value(&res)?)