Skip to main content

ContextCache

Trait ContextCache 

Source
pub trait ContextCache {
    // Required methods
    fn get(&self, key: &str) -> Option<Arc<ProcessedContext>>;
    fn put(&self, key: String, context: Arc<ProcessedContext>);
}
Expand description

Where processed contexts are kept between documents.

Processing a context costs far more than using one, and nearly every document a server receives names the same few. This crate is no_std and keeps no state of its own, so the caller supplies the store — behind a mutex, typically — and decides how much it may hold. A cache holds what one Registry resolved, and must be used with that registry only.

Only a document’s own top-level @context is cached. A context nested in the document, or scoped to a term, depends on the context around it.

Required Methods§

Source

fn get(&self, key: &str) -> Option<Arc<ProcessedContext>>

The context processed under key, if kept.

Source

fn put(&self, key: String, context: Arc<ProcessedContext>)

Keep a context processed under key.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§