Skip to main content

AsCodeOptions

Struct AsCodeOptions 

Source
#[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

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§exclude_type_guards: bool

Controls 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: bool

Requires 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: bool

Controls whether the runtime meta graph + diagnostics JSON blobs are baked into the generated Dfir::new(...) call.

§include_metrics_tracking: bool

Controls 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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AsCodeOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AsCodeOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.