pub trait TickClosure {
type Metrics: MetricsState;
}Expand description
Base trait of the tick closure traits: names the MetricsState typestate of the context the
closure expects, so that Dfir<Tick> can be parameterized by the closure alone.
On its own, this bound gives access to a Dfir’s metadata (Dfir::meta_graph,
Dfir::metrics, …) but not to any runner. The tick closure traits form a small hierarchy;
bound on the one that matches what you need to do with the graph:
TickClosure(this trait): inspect only.TickClosureSync: run a tick synchronously (Dfir::run_tick_sync,Dfir::run_available_sync).TickClosureAsync: run a tick as a future (Dfir::run_tick,Dfir::run_available,Dfir::run).TickClosureBoth: both. Implemented automatically for any type implementing the two above. This is what functions returning a concrete generated graph promise:Dfir<impl TickClosureBoth<Metrics = ..>>.
Concrete closures ([TickClosureFn]) implement all of them. The type-erased wrappers implement
only what their vtable carries, so that erasing a graph for one kind of runner does not
instantiate the code for the other: [TickClosureErasedSync] is Sync-only,
[TickClosureErasedAsync] is Async-only, and [TickClosureErased] is both.
Required Associated Types§
Sourcetype Metrics: MetricsState
type Metrics: MetricsState
Whether the context passed to this closure tracks metrics. See MetricsState.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".