pub struct CachingCompiler { /* private fields */ }Implementations§
Source§impl CachingCompiler
impl CachingCompiler
Sourcepub fn new<F>(capacity: usize, compile_fn: F) -> Self
pub fn new<F>(capacity: usize, compile_fn: F) -> Self
Create a CachingCompiler with a custom compile function and cache capacity.
§Arguments
capacity– Maximum number of entries held in the LRU cache.compile_fn– A closure (or function) that compiles aTLExprinto anEinsumGraph, returningErr(String)on failure.
Sourcepub fn compile(&mut self, expr: &TLExpr) -> Result<EinsumGraph, String>
pub fn compile(&mut self, expr: &TLExpr) -> Result<EinsumGraph, String>
Compile an expression, returning the cached result when available.
§Errors
Propagates any error produced by the underlying compile function on a cache miss.
Sourcepub fn compile_batch(
&mut self,
exprs: &[TLExpr],
) -> Vec<Result<EinsumGraph, String>>
pub fn compile_batch( &mut self, exprs: &[TLExpr], ) -> Vec<Result<EinsumGraph, String>>
Compile multiple expressions in order, sharing the cache across all of them.
Returns one Result per input expression in the same order.
Sourcepub fn cache_stats(&self) -> &CacheStats
pub fn cache_stats(&self) -> &CacheStats
Returns a reference to the current cache statistics.
Sourcepub fn invalidate(&mut self, expr: &TLExpr) -> bool
pub fn invalidate(&mut self, expr: &TLExpr) -> bool
Invalidate the cached result for a specific expression.
Returns true if an entry was present and removed.
Sourcepub fn fingerprint(expr: &TLExpr) -> ExprFingerprint
pub fn fingerprint(expr: &TLExpr) -> ExprFingerprint
Compute a structural ExprFingerprint for an expression.
Two structurally identical expressions will produce equal fingerprints.
Auto Trait Implementations§
impl Freeze for CachingCompiler
impl !RefUnwindSafe for CachingCompiler
impl Send for CachingCompiler
impl Sync for CachingCompiler
impl Unpin for CachingCompiler
impl UnsafeUnpin for CachingCompiler
impl !UnwindSafe for CachingCompiler
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