#[non_exhaustive]pub struct AsCodeOptions {
pub exclude_type_guards: bool,
pub require_flame_attribution: bool,
pub exclude_meta: bool,
pub include_metrics_tracking: bool,
}Expand description
Options for DfirGraph::as_code_with_options.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.exclude_type_guards: boolControls whether type guards are emitted in codegen.
Type guards are identity wrapper functions emitted around each operator (and in some
operators’ own codegen, e.g. check_stream in source_stream, or the pivot_run_sg_*
function joining the pull and push halves of a subgraph), which pin down the Item/Meta
types flowing between operators so that type errors in user code are reported at the
offending operator rather than somewhere downstream. They have no runtime effect, but they
make the generated code significantly more verbose.
Excluding type guards may result in worse error messages for hand-written DFIR. However, front-ends which already type-check the dataflow themselves (e.g. Hydro) and inject their own type hints can safely exclude them to produce much more compact generated code.
Note that the per-operator type guard wrapper is also what gives streaming operators (e.g.
map, filter) a named stack frame in profiles/flamegraphs, since the wrapper struct’s
pull/push impls live inside a function named after the operator. Set
Self::require_flame_attribution to keep those wrappers even when type guards are
excluded.
require_flame_attribution: boolRequires that every operator gets a named stack frame for profiler/flamegraph attribution,
even when Self::exclude_type_guards is set.
Operators which do work outside the pull/push pipeline (e.g. fold, join) always get
attribution via their work_fn thunks. Streaming operators (e.g. map, filter) only get
attribution via the per-operator type guard wrapper, so this option forces that wrapper to
be emitted when type guards are otherwise excluded. Has no effect when type guards are
included (the default).
exclude_meta: boolControls whether the runtime meta graph + diagnostics JSON blobs are baked into the generated
Dfir::new(...) call.
include_metrics_tracking: boolControls whether metrics are tracked. Metrics tracking is opt-in: no tracking code is generated unless this is set.
This selects the MetricsState typestate of the generated Dfir’s Context: when set,
Context<DfirMetrics> is used and Dfir::metrics() is available; when unset,
Context<()> is used, which statically guarantees that there is no metrics state (and no
Dfir::metrics() accessor) at runtime.
Trait Implementations§
Source§impl Clone for AsCodeOptions
impl Clone for AsCodeOptions
Source§impl Debug for AsCodeOptions
impl Debug for AsCodeOptions
Auto Trait Implementations§
impl Freeze for AsCodeOptions
impl RefUnwindSafe for AsCodeOptions
impl Send for AsCodeOptions
impl Sync for AsCodeOptions
impl Unpin for AsCodeOptions
impl UnsafeUnpin for AsCodeOptions
impl UnwindSafe for AsCodeOptions
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more