pub mod buffer;
pub mod builder;
pub mod element_index;
pub mod error;
pub mod namespace;
pub mod navigator;
pub mod node;
pub mod page;
pub mod qname;
pub mod source_spans;
pub mod strings;
pub mod type_remap;
pub mod typed_builder;
pub use buffer::BufferDocument;
pub use builder::BufferDocumentBuilder;
pub use element_index::ElementIndex;
pub use error::BufferDocumentError;
pub use namespace::{
NamespaceChain, NamespaceNode, NamespacePageFactory, NsRef, NS_PAGE_MASK, NS_PAGE_SHIFT,
NS_PAGE_SIZE,
};
pub use navigator::BufferDocNavigator;
pub use node::{
node_ref_from, page_of, slot_of, Node, NodeType, NULL, PAGE_MASK, PAGE_SHIFT, PAGE_SIZE,
};
pub use page::NodePages;
pub use qname::{QNameAtom, QNameTable, EMPTY_QNAME};
pub use source_spans::NodeSourceSpans;
pub use strings::StringStore;
pub use type_remap::{BindingRemapTable, NodeSchemaBinding};
pub use typed_builder::{build_typed_document, SilentValidationSink};
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum DocumentKind {
#[default]
Full,
Fragment,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct BufferDocumentOptions {
pub kind: DocumentKind,
pub track_source_locations: bool,
}
impl Default for BufferDocumentOptions {
fn default() -> Self {
Self {
kind: DocumentKind::Full,
track_source_locations: false,
}
}
}
impl BufferDocumentOptions {
pub fn full() -> Self {
Self {
kind: DocumentKind::Full,
track_source_locations: true,
}
}
pub fn fragment() -> Self {
Self {
kind: DocumentKind::Fragment,
track_source_locations: false,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn document_kind_default_is_full() {
assert_eq!(DocumentKind::default(), DocumentKind::Full);
}
#[test]
fn options_default() {
let opts = BufferDocumentOptions::default();
assert_eq!(opts.kind, DocumentKind::Full);
assert!(!opts.track_source_locations);
}
#[test]
fn options_full() {
let opts = BufferDocumentOptions::full();
assert_eq!(opts.kind, DocumentKind::Full);
assert!(opts.track_source_locations);
}
#[test]
fn options_fragment() {
let opts = BufferDocumentOptions::fragment();
assert_eq!(opts.kind, DocumentKind::Fragment);
assert!(!opts.track_source_locations);
}
}