pub trait Tape:
Send
+ Sync
+ Clone {
type Storage: Default;
// Required methods
fn recycle(self) -> Option<Self::Storage>;
fn vars(&self) -> &VarMap;
fn output_count(&self) -> usize;
}
Expand description
A tape represents something that can be evaluated by an evaluator
It includes some kind of storage (which could be empty) and the ability to look up variable mapping.
Tapes may be shared between threads, so they should be cheap to clone (i.e.
a wrapper around an Arc<..>
).
Required Associated Types§
Required Methods§
Sourcefn recycle(self) -> Option<Self::Storage>
fn recycle(self) -> Option<Self::Storage>
Tries to retrieve the internal storage from this tape
This matters most for JIT evaluators, whose tapes are regions of executable memory-mapped RAM (which is expensive to map and unmap).
Sourcefn vars(&self) -> &VarMap
fn vars(&self) -> &VarMap
Returns a mapping from Var
to evaluation index
This must be identical to Function::vars
on the Function
which
produced this tape.
Sourcefn output_count(&self) -> usize
fn output_count(&self) -> usize
Returns the number of outputs written by this tape
The order of outputs is set by the caller at tape construction, so we don’t need a map to determine the index of a particular output (unlike variables).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.