pub struct DocumentCache { /* private fields */ }Expand description
Documents that fn:document loads, parsed once and given to every transformation that
loads them again: the code lists a stylesheet reads, the same text under the same URI
for each document it validates.
DocumentCache::parse_loaded returns the tree Document::parse_loaded_with_max_depth
would build from the text, without parsing it again when the same text was parsed under
the same URI and maximum depth before: a copy of that tree, which is a new document
(created now, as a parse now would create it, for the document order of nodes in
different trees). The cache is shared between threads; it keeps at most
DocumentCache::MAX_DOCUMENTS documents of at most DocumentCache::MAX_BYTES of
text in all, and parses the others each time.
Implementations§
Source§impl DocumentCache
impl DocumentCache
Sourcepub const MAX_DOCUMENTS: usize = 64
pub const MAX_DOCUMENTS: usize = 64
The most documents a cache keeps.
Sourcepub fn parse_loaded(
&self,
text: String,
uri: &str,
max_depth: u32,
) -> Result<Rc<Document>, DocumentError>
pub fn parse_loaded( &self, text: String, uri: &str, max_depth: u32, ) -> Result<Rc<Document>, DocumentError>
The document Document::parse_loaded_with_max_depth parses from text, loaded
from uri: a copy of the one parsed before from the same text, URI and maximum
depth, or parsed now (and kept, room permitting).
§Errors
Those of Document::parse; a text that does not parse is not kept.