pub struct SchemaCache { /* private fields */ }Expand description
Compiled schemas, keyed by the canonical digest of the schema.
Interpretation runs one schema per workflow generation, so the cache is
small, long-lived and worth its lock. Cloning a SchemaCache shares the
same store.
Implementations§
Source§impl SchemaCache
impl SchemaCache
Sourcepub fn compile(
&self,
schema: &Value,
) -> Result<CompiledSchema, SchemaCompileError>
pub fn compile( &self, schema: &Value, ) -> Result<CompiledSchema, SchemaCompileError>
Returns the compiled form of schema, compiling it on first sight.
§Errors
Returns SchemaCompileError when the schema is invalid. Invalid
schemas are not cached.
use serde_json::json;
use turnframe_provider::structured::SchemaCache;
let cache = SchemaCache::new();
let schema = json!({"type": "object"});
let first = cache.compile(&schema)?;
let second = cache.compile(&schema)?;
assert_eq!(first.fingerprint(), second.fingerprint());
assert_eq!(cache.len(), 1);Trait Implementations§
Source§impl Clone for SchemaCache
impl Clone for SchemaCache
Source§impl Debug for SchemaCache
impl Debug for SchemaCache
Auto Trait Implementations§
impl Freeze for SchemaCache
impl RefUnwindSafe for SchemaCache
impl Send for SchemaCache
impl Sync for SchemaCache
impl Unpin for SchemaCache
impl UnsafeUnpin 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