mod canon;
mod conflict;
mod error;
pub mod field;
mod files;
mod layout;
mod record;
mod resolve;
mod resolve_conflicts;
mod resolve_decisions;
mod resolve_nodes;
pub mod schema;
mod unresolve;
mod unresolve_parts;
mod variants;
pub use conflict::{SideShape, side_shape};
pub use error::{Problem, ReadError, Site, SpecPath};
pub(crate) use files::keyed;
pub use files::{CATEGORIES, Content, Files, LABELS, LINT, MANIFEST, Role, TAGS, Tree};
pub use layout::{Sites, read_tree};
pub(crate) use layout::{check_tree, parse_files};
pub use record::{ConflictRec, Mode, Rec, Val};
pub use resolve::resolve;
pub use unresolve::unresolve;
pub(crate) use canon::canonicalize;
pub(crate) use files::{read_file, write_files};
pub(crate) use resolve_nodes::statement_of;
use crate::document::Document;
pub fn read(files: &Files) -> Result<Document, Vec<ReadError>> {
read_sited(files).map(|(document, _)| document)
}
pub fn read_sited(files: &Files) -> Result<(Document, Sites), Vec<ReadError>> {
let tree = read_tree(files)?;
let document = resolve(&tree)?;
Ok((document, Sites::of(&tree)))
}
#[must_use]
pub fn write(document: &Document) -> Files {
let mut tree = unresolve(document);
canonicalize(&mut tree);
write_files(&tree)
}
pub(crate) fn write_content(path: &SpecPath, role: Role, content: Content) -> Vec<u8> {
let mut tree = Tree::default();
tree.files.insert(path.clone(), (role, content));
canonicalize(&mut tree);
write_files(&tree)
.remove(path)
.expect("the writer writes the file")
}
pub(crate) fn variant_holds(record: &Rec) -> bool {
variants::check(record).is_ok()
}
#[must_use]
pub fn write_labels(document: &Document) -> Vec<u8> {
let mut tree = unresolve::unresolve_labels(document);
canonicalize(&mut tree);
write_files(&tree)
.remove(&SpecPath::new(LABELS))
.expect("the writer writes the bindings")
}