pub struct SchemaCache { /* private fields */ }Expand description
Thread-safe LRU cache for schema validators.
Caches parsed schemas to avoid re-parsing on every validation. Uses parking_lot RwLock for high-performance concurrent access.
§Example
use hedl_xml::schema::SchemaCache;
use std::path::Path;
let cache = SchemaCache::new(100);
// First call parses and caches
let validator = cache.get_or_load(Path::new("schema.xsd"))?;
// Second call uses cached validator
let validator2 = cache.get_or_load(Path::new("schema.xsd"))?;Implementations§
Source§impl SchemaCache
impl SchemaCache
Sourcepub fn get_or_load(
&self,
path: &Path,
) -> Result<Arc<SchemaValidator>, ValidationError>
pub fn get_or_load( &self, path: &Path, ) -> Result<Arc<SchemaValidator>, ValidationError>
Get cached validator or load from file.
If the schema is already cached, returns the cached validator. Otherwise, loads the schema from file and caches it.
§Arguments
path- Path to schema file
§Errors
Returns ValidationError if schema file cannot be loaded or parsed.
§Example
use hedl_xml::schema::SchemaCache;
use std::path::Path;
let cache = SchemaCache::new(10);
let validator = cache.get_or_load(Path::new("schema.xsd"))?;Trait Implementations§
Auto Trait Implementations§
impl Freeze for SchemaCache
impl !RefUnwindSafe for SchemaCache
impl Send for SchemaCache
impl Sync for SchemaCache
impl Unpin for SchemaCache
impl !UnwindSafe for SchemaCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more