xsd_schema/document/
mod.rs1pub mod buffer;
12pub mod builder;
13pub mod element_index;
14pub mod error;
15pub mod namespace;
16pub mod navigator;
17pub mod node;
18pub mod page;
19pub mod qname;
20pub mod source_spans;
21pub mod strings;
22pub mod type_remap;
23pub mod typed_builder;
24
25pub use buffer::BufferDocument;
26pub use builder::BufferDocumentBuilder;
27pub use element_index::ElementIndex;
28pub use error::BufferDocumentError;
29pub use namespace::{
30 NamespaceChain, NamespaceNode, NamespacePageFactory, NsRef, NS_PAGE_MASK, NS_PAGE_SHIFT,
31 NS_PAGE_SIZE,
32};
33pub use navigator::BufferDocNavigator;
34pub use node::{
35 node_ref_from, page_of, slot_of, Node, NodeType, NULL, PAGE_MASK, PAGE_SHIFT, PAGE_SIZE,
36};
37pub use page::NodePages;
38pub use qname::{QNameAtom, QNameTable, EMPTY_QNAME};
39pub use source_spans::NodeSourceSpans;
40pub use strings::StringStore;
41pub use type_remap::{BindingRemapTable, NodeSchemaBinding};
42pub use typed_builder::{build_typed_document, SilentValidationSink};
43
44#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
46pub enum DocumentKind {
47 #[default]
49 Full,
50 Fragment,
52}
53
54#[derive(Clone, Copy, Debug, PartialEq, Eq)]
56pub struct BufferDocumentOptions {
57 pub kind: DocumentKind,
59 pub track_source_locations: bool,
61}
62
63impl Default for BufferDocumentOptions {
64 fn default() -> Self {
65 Self {
66 kind: DocumentKind::Full,
67 track_source_locations: false,
68 }
69 }
70}
71
72impl BufferDocumentOptions {
73 pub fn full() -> Self {
75 Self {
76 kind: DocumentKind::Full,
77 track_source_locations: true,
78 }
79 }
80
81 pub fn fragment() -> Self {
83 Self {
84 kind: DocumentKind::Fragment,
85 track_source_locations: false,
86 }
87 }
88}
89
90#[cfg(test)]
91mod tests {
92 use super::*;
93
94 #[test]
95 fn document_kind_default_is_full() {
96 assert_eq!(DocumentKind::default(), DocumentKind::Full);
97 }
98
99 #[test]
100 fn options_default() {
101 let opts = BufferDocumentOptions::default();
102 assert_eq!(opts.kind, DocumentKind::Full);
103 assert!(!opts.track_source_locations);
104 }
105
106 #[test]
107 fn options_full() {
108 let opts = BufferDocumentOptions::full();
109 assert_eq!(opts.kind, DocumentKind::Full);
110 assert!(opts.track_source_locations);
111 }
112
113 #[test]
114 fn options_fragment() {
115 let opts = BufferDocumentOptions::fragment();
116 assert_eq!(opts.kind, DocumentKind::Fragment);
117 assert!(!opts.track_source_locations);
118 }
119}