Skip to main content

BatchEngine

Struct BatchEngine 

Source
pub struct BatchEngine { /* private fields */ }
Available on crate feature worker-batch and (crate features worker-batch or worker-pool or worker) only.
Expand description

Core batch processing engine for DFE pipelines.

Provides two in-process processing modes (the run-loop drivers live in the driver module, gated on the transport feature):

  • process_mid_tier – parse JSON via SIMD, extract known fields, apply pre-route filters, then parallel transform via rayon. The standard path for most DFE apps (loader, archiver, transforms).

  • process_raw – skip parsing, apply pre-route on raw bytes, then parallel transform via rayon. For apps that handle raw bytes (receiver, binary protocols).

Both take the canonical Record slice (the same currency the WorkBatch carries), chunk large batches, and track stats atomically.

Inbound braking under memory pressure is no longer a blocking pause between chunks (the retired check_memory_pressure proto-actuator). It is now the self-regulation governor’s job: the inbound GATE pauses the source transport and the streaming byte-budget lever bounds peak in-flight memory. See run_governed. With the governor OFF, there is no active brake – that is the deliberate opt-out.

Implementations§

Source§

impl BatchEngine

Source

pub async fn run_workbatch<R, P, Sink, SinkFut, Ticker, TickerFut>( &self, receiver: &R, shutdown: CancellationToken, process: P, sink: Sink, commit: CommitMode, ticker: Option<(Duration, Ticker)>, ) -> Result<(), EngineError>
where R: TransportReceiver, P: Fn(WorkBatch<R::Token>) -> Result<WorkBatch<R::Token>, EngineError>, Sink: FnMut(&WorkBatch<R::Token>) -> SinkFut, SinkFut: Future<Output = Result<(), EngineError>>, Ticker: FnMut() -> TickerFut, TickerFut: Future<Output = Result<(), EngineError>>,

Available on crate feature transport only.

Unified on-demand WorkBatch driver – the default data-plane loop.

Drives one WorkBatch at a time through recv -> filter-DLQ policy -> ingress lease -> process -> sink -> commit. The driver does NOT pre-parse: process reads fields on demand via codec::parse. Pass-through apps pay zero parse cost.

  • process runs on the loop task (cancellation-aware between awaits) and may fan records out or in; it MUST preserve commit_tokens (use WorkBatch::map_records, which does so automatically).
  • sink is async and receives the WHOLE out-batch by reference.
  • commit selects CommitMode::Auto (engine commits after sink Ok) or CommitMode::SinkManaged (sink owns commit).
  • ticker is an optional (interval, fn) that fires on the interval inside the select loop (flush timers, periodic maintenance).

Stops cleanly when shutdown is cancelled.

§Errors

Returns EngineError::Transport if recv fails fatally, EngineError::FilterDlqUnrouted if inline-DLQ entries appear under the default FilterDlqPolicy::Reject, or the error returned by process.

A sink error (and, under CommitMode::Auto, a commit error) is TERMINAL: it stops the run loop and propagates. This is the ack barrier for the ORDERED/cumulative source commit (Kafka “commit up to offset N”): the failed block’s tokens are NOT committed, and – crucially – no LATER block is fetched and committed past them, which would silently skip the never-sent records (data loss). On restart the source re-delivers from the last committed watermark, preserving at-least-once. The app owns restart/retry policy.

Source

pub async fn run_workbatch_streaming<R, P, Sink, SinkFut, Ticker, TickerFut>( &self, receiver: &R, shutdown: CancellationToken, process: P, sink: Sink, commit: CommitMode, sub_block_bytes: u64, ticker: Option<(Duration, Ticker)>, ) -> Result<(), EngineError>
where R: TransportReceiver, P: Fn(WorkBatch<R::Token>) -> Result<WorkBatch<R::Token>, EngineError>, Sink: FnMut(&WorkBatch<R::Token>) -> SinkFut, SinkFut: Future<Output = Result<(), EngineError>>, Ticker: FnMut() -> TickerFut, TickerFut: Future<Output = Result<(), EngineError>>,

Available on crate feature transport only.

Streaming WorkBatch driver – the opt-in peak-memory-bounded path.

Identical loop shape to run_workbatch, but each received block is processed in consecutive byte-budget-sized SUB-BLOCKS rather than all at once. Peak in-flight ingress memory is bounded to ONE sub-block (~sub_block_bytes) instead of the whole block: the per-sub-block ingress lease is dropped (releasing those bytes) BEFORE the next sub-block is leased and processed.

The source acks for the WHOLE block are committed EXACTLY ONCE, after the FINAL sub-block’s sink returns Ok (under CommitMode::Auto) – so at-least-once is preserved: a sink error on any sub-block stops the block and skips the commit, so the WHOLE block is re-delivered. The sub-block views carry EMPTY commit_tokens; the batch’s tokens are committed once at the end.

sub_block_bytes is the target sum of payload.len() per sub-block (floor one record, so a record larger than the target is still its own sub-block and the loop never stalls). It is taken as a parameter so the path is testable; Phase 3 wires the byte budget from the governor.

Fan-out WITHIN a sub-block’s process is fine (records grow); the source acks are still the batch’s input tokens, committed once at the end.

§Errors

Same as run_workbatch.

Source

pub async fn run_governed<R, P, Sink, SinkFut, Ticker, TickerFut>( &self, receiver: &R, shutdown: CancellationToken, process: P, sink: Sink, commit: CommitMode, ticker: Option<(Duration, Ticker)>, ) -> Result<(), EngineError>
where R: TransportReceiver, P: Fn(WorkBatch<R::Token>) -> Result<WorkBatch<R::Token>, EngineError>, Sink: FnMut(&WorkBatch<R::Token>) -> SinkFut, SinkFut: Future<Output = Result<(), EngineError>>, Ticker: FnMut() -> TickerFut, TickerFut: Future<Output = Result<(), EngineError>>,

Available on crate features governor and transport only.

Governed WorkBatch driver – the default-ON self-regulation run path.

This is what a self-regulating app calls instead of choosing between run_workbatch and run_workbatch_streaming by hand. It dispatches on whether the byte-budget lever is wired (set_byte_budget, done by ServiceRuntime when self_regulation.enabled = true):

  • Governor ON (budget wired): streams each received block in sub-blocks sized to the CURRENT byte budget (re-read per block), bounds peak in-flight memory to one sub-block, and folds each block’s (bytes, process_time, ingest_interval) into the AIMD loop via observe. The recv max is capped to the budget’s poll-safety record_cap. While pressure is LOW the budget sits at its big start value, so the block becomes a SINGLE sub-block – no per-record overhead, behaviour matches the whole-batch loop.
  • Governor OFF (no budget): delegates verbatim to run_workbatch – byte-identical to pre-governor behaviour.

The inbound GATE (Kafka pause-partitions / HTTP-gRPC 503) is wired SEPARATELY into the receive transport, not here – this method is the driver-side lever (sub-block sizing + AIMD), the gate is the transport-side brake. The two share the same UnifiedPressure.

§Errors

Same as run_workbatch.

Source

pub async fn run_workbatch_parsed<R, P, Sink, SinkFut, Ticker, TickerFut>( &self, receiver: &R, shutdown: CancellationToken, process_parsed: P, sink: Sink, commit: CommitMode, ticker: Option<(Duration, Ticker)>, ) -> Result<(), EngineError>
where R: TransportReceiver, P: Fn(ParsedBatch<'_, R::Token>) -> Result<WorkBatch<R::Token>, EngineError>, Sink: FnMut(&WorkBatch<R::Token>) -> SinkFut, SinkFut: Future<Output = Result<(), EngineError>>, Ticker: FnMut() -> TickerFut, TickerFut: Future<Output = Result<(), EngineError>>,

Available on crate feature transport only.

Unified pre-parsed WorkBatch driver – the opt-in hot path.

Identical loop shape to run_workbatch, except the driver PRE-PARSES the whole block via codec::parse (SIMD JSON / native MsgPack) on the worker pool and hands process_parsed a ParsedBatch (records + aligned parsed payloads + shared FieldInterner). This keeps the batch-parse + interner throughput win for apps that opt in.

Records that fail to parse are handled per the configured ParseErrorAction (Dlq -> dlq_entries, Skip -> drop+counted, FailBatch -> terminal no-commit) – see ParsedBatch for the parse-failure contract. process_parsed returns the final WorkBatch and MUST preserve the input commit_tokens.

§Errors

Same as run_workbatch.

Source§

impl BatchEngine

Source

pub fn new(config: BatchProcessingConfig) -> Self

Create a standalone engine with its own worker pool.

Uses WorkerPoolConfig::default() for the pool. Prefer with_pool when a ServiceRuntime pool exists.

Source

pub fn with_pool( pool: Arc<AdaptiveWorkerPool>, config: BatchProcessingConfig, ) -> Self

Create an engine that reuses an existing worker pool.

This is the preferred constructor when ServiceRuntime is available, as it avoids creating a second rayon thread pool.

Source

pub fn set_byte_budget(&mut self, budget: Arc<ByteBudgetController>)

Available on crate feature governor only.

Wire the self-regulation byte-budget lever (governor feature).

Called by ServiceRuntime::build() when the governor is enabled. Once wired, run_governed streams the input in budget-sized sub-blocks and drives the AIMD loop per block. Without it (governor off), run_governed falls back to the whole-batch loop.

Source

pub fn is_self_regulated(&self) -> bool

Available on crate feature governor only.

Whether the self-regulation byte-budget lever is wired (governor feature). When false, run_governed is the whole-batch loop.

Source

pub fn with_filter_dlq_policy(self, policy: FilterDlqPolicy) -> Self

Available on crate feature transport only.

Set the policy for inbound-filter DLQ entries in the run loops.

Default is FilterDlqPolicy::Reject – the run loop errors if an inbound action: dlq filter produces entries and no routing is set, so dead-letters are never silently dropped.

Source

pub fn from_cascade(key: &str) -> Result<Self, ConfigError>

Load configuration from the cascade and create a standalone engine.

§Errors

Returns ConfigError if the cascade contains invalid data.

Source

pub fn stats(&self) -> &Arc<PipelineStats>

Pipeline statistics (atomic, lock-free).

Source

pub fn pool(&self) -> &Arc<AdaptiveWorkerPool>

Underlying worker pool.

Source

pub fn config(&self) -> &BatchProcessingConfig

Engine configuration.

Source

pub fn auto_wire( &mut self, metrics_manager: &MetricsManager, memory_guard: Option<&Arc<MemoryGuard>>, )

Auto-wire engine with infrastructure components.

Called by ServiceRuntime::build(). Apps never call this directly.

Source

pub fn process_mid_tier<O, E, F>( &self, messages: &[Record], transform: F, ) -> Vec<Result<O, E>>
where O: Send, E: Send + From<String>, F: Fn(&mut ParsedMessage) -> Result<O, E> + Sync,

Available on crate feature transport only.

Parse, filter, and transform a batch of raw messages.

Pipeline phases per chunk:

  1. Pre-route – SIMD field extraction + filter evaluation (sequential, ~100 ns/msg)
  2. Parsesonic_rs::from_slice + known-field extraction (sequential, ~1-5 µs/msg)
  3. Transform – user closure via rayon par_iter_mut (parallel)

Results contain one entry per non-filtered message. Filtered messages are silently removed (their commit tokens remain accessible via the original slice). DLQ’d and parse-error messages produce Err entries.

Source

pub fn process_raw<O, E, F>( &self, messages: &[Record], transform: F, ) -> Vec<Result<O, E>>
where O: Send, E: Send + From<String>, F: Fn(&Record) -> Result<O, E> + Sync,

Available on crate feature transport only.

Pre-route and transform a batch of records without parsing.

The transform closure receives immutable Record references. Use this for apps that handle raw bytes directly (e.g. receiver forwarding).

Trait Implementations§

Source§

impl Debug for BatchEngine

Source§

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

Formats the value using the given formatter. 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> AnyExt for T
where T: Any + ?Sized,

Source§

fn downcast_ref<T>(this: &Self) -> Option<&T>
where T: Any,

Attempts to downcast this to T behind reference
Source§

fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>
where T: Any,

Attempts to downcast this to T behind mutable reference
Source§

fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>
where T: Any,

Attempts to downcast this to T behind Rc pointer
Source§

fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>
where T: Any,

Attempts to downcast this to T behind Arc pointer
Source§

fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>
where T: Any,

Attempts to downcast this to T behind Box pointer
Source§

fn downcast_move<T>(this: Self) -> Option<T>
where T: Any, Self: Sized,

Attempts to downcast owned Self to T, useful only in generic context as a workaround for specialization
Source§

impl<T> AsDebug for T
where T: Debug,

Source§

fn as_debug(&self) -> &dyn Debug

Returns self as a &dyn Debug trait object.
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T, X> CoerceTo<T> for X
where T: CoerceFrom<X> + ?Sized,

Source§

fn coerce_rc_to(self: Rc<X>) -> Rc<T>

Source§

fn coerce_box_to(self: Box<X>) -> Box<T>

Source§

fn coerce_ref_to(&self) -> &T

Source§

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

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<D> OwoColorize for D

Source§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
Source§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
Source§

fn black(&self) -> FgColorDisplay<'_, Black, Self>

Change the foreground color to black
Source§

fn on_black(&self) -> BgColorDisplay<'_, Black, Self>

Change the background color to black
Source§

fn red(&self) -> FgColorDisplay<'_, Red, Self>

Change the foreground color to red
Source§

fn on_red(&self) -> BgColorDisplay<'_, Red, Self>

Change the background color to red
Source§

fn green(&self) -> FgColorDisplay<'_, Green, Self>

Change the foreground color to green
Source§

fn on_green(&self) -> BgColorDisplay<'_, Green, Self>

Change the background color to green
Source§

fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>

Change the foreground color to yellow
Source§

fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>

Change the background color to yellow
Source§

fn blue(&self) -> FgColorDisplay<'_, Blue, Self>

Change the foreground color to blue
Source§

fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>

Change the background color to blue
Source§

fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to magenta
Source§

fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to magenta
Source§

fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to purple
Source§

fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to purple
Source§

fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>

Change the foreground color to cyan
Source§

fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>

Change the background color to cyan
Source§

fn white(&self) -> FgColorDisplay<'_, White, Self>

Change the foreground color to white
Source§

fn on_white(&self) -> BgColorDisplay<'_, White, Self>

Change the background color to white
Source§

fn default_color(&self) -> FgColorDisplay<'_, Default, Self>

Change the foreground color to the terminal default
Source§

fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>

Change the background color to the terminal default
Source§

fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>

Change the foreground color to bright black
Source§

fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>

Change the background color to bright black
Source§

fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>

Change the foreground color to bright red
Source§

fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>

Change the background color to bright red
Source§

fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>

Change the foreground color to bright green
Source§

fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>

Change the background color to bright green
Source§

fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>

Change the foreground color to bright yellow
Source§

fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>

Change the background color to bright yellow
Source§

fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>

Change the foreground color to bright blue
Source§

fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>

Change the background color to bright blue
Source§

fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright magenta
Source§

fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright magenta
Source§

fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright purple
Source§

fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright purple
Source§

fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>

Change the foreground color to bright cyan
Source§

fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>

Change the background color to bright cyan
Source§

fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>

Change the foreground color to bright white
Source§

fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>

Change the background color to bright white
Source§

fn bold(&self) -> BoldDisplay<'_, Self>

Make the text bold
Source§

fn dimmed(&self) -> DimDisplay<'_, Self>

Make the text dim
Source§

fn italic(&self) -> ItalicDisplay<'_, Self>

Make the text italicized
Source§

fn underline(&self) -> UnderlineDisplay<'_, Self>

Make the text underlined
Make the text blink
Make the text blink (but fast!)
Source§

fn reversed(&self) -> ReversedDisplay<'_, Self>

Swap the foreground and background colors
Source§

fn hidden(&self) -> HiddenDisplay<'_, Self>

Hide the text
Source§

fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>

Cross out the text
Source§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more
Source§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more
Source§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
Source§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
Source§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
Source§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
Source§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
Source§

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

Source§

fn fg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the foreground set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like red() and green(), which have the same functionality but are pithier.

§Example

Set foreground color to white using fg():

use yansi::{Paint, Color};

painted.fg(Color::White);

Set foreground color to white using white().

use yansi::Paint;

painted.white();
Source§

fn primary(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Primary].

§Example
println!("{}", value.primary());
Source§

fn fixed(&self, color: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Fixed].

§Example
println!("{}", value.fixed(color));
Source§

fn rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Rgb].

§Example
println!("{}", value.rgb(r, g, b));
Source§

fn black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Black].

§Example
println!("{}", value.black());
Source§

fn red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Red].

§Example
println!("{}", value.red());
Source§

fn green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Green].

§Example
println!("{}", value.green());
Source§

fn yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Yellow].

§Example
println!("{}", value.yellow());
Source§

fn blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Blue].

§Example
println!("{}", value.blue());
Source§

fn magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Magenta].

§Example
println!("{}", value.magenta());
Source§

fn cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Cyan].

§Example
println!("{}", value.cyan());
Source§

fn white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: White].

§Example
println!("{}", value.white());
Source§

fn bright_black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlack].

§Example
println!("{}", value.bright_black());
Source§

fn bright_red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightRed].

§Example
println!("{}", value.bright_red());
Source§

fn bright_green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightGreen].

§Example
println!("{}", value.bright_green());
Source§

fn bright_yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightYellow].

§Example
println!("{}", value.bright_yellow());
Source§

fn bright_blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlue].

§Example
println!("{}", value.bright_blue());
Source§

fn bright_magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.bright_magenta());
Source§

fn bright_cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightCyan].

§Example
println!("{}", value.bright_cyan());
Source§

fn bright_white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightWhite].

§Example
println!("{}", value.bright_white());
Source§

fn bg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the background set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like on_red() and on_green(), which have the same functionality but are pithier.

§Example

Set background color to red using fg():

use yansi::{Paint, Color};

painted.bg(Color::Red);

Set background color to red using on_red().

use yansi::Paint;

painted.on_red();
Source§

fn on_primary(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Primary].

§Example
println!("{}", value.on_primary());
Source§

fn on_fixed(&self, color: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Fixed].

§Example
println!("{}", value.on_fixed(color));
Source§

fn on_rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Rgb].

§Example
println!("{}", value.on_rgb(r, g, b));
Source§

fn on_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Black].

§Example
println!("{}", value.on_black());
Source§

fn on_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Red].

§Example
println!("{}", value.on_red());
Source§

fn on_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Green].

§Example
println!("{}", value.on_green());
Source§

fn on_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Yellow].

§Example
println!("{}", value.on_yellow());
Source§

fn on_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Blue].

§Example
println!("{}", value.on_blue());
Source§

fn on_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Magenta].

§Example
println!("{}", value.on_magenta());
Source§

fn on_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Cyan].

§Example
println!("{}", value.on_cyan());
Source§

fn on_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: White].

§Example
println!("{}", value.on_white());
Source§

fn on_bright_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlack].

§Example
println!("{}", value.on_bright_black());
Source§

fn on_bright_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightRed].

§Example
println!("{}", value.on_bright_red());
Source§

fn on_bright_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightGreen].

§Example
println!("{}", value.on_bright_green());
Source§

fn on_bright_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightYellow].

§Example
println!("{}", value.on_bright_yellow());
Source§

fn on_bright_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlue].

§Example
println!("{}", value.on_bright_blue());
Source§

fn on_bright_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.on_bright_magenta());
Source§

fn on_bright_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightCyan].

§Example
println!("{}", value.on_bright_cyan());
Source§

fn on_bright_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightWhite].

§Example
println!("{}", value.on_bright_white());
Source§

fn attr(&self, value: Attribute) -> Painted<&T>

Enables the styling Attribute value.

This method should be used rarely. Instead, prefer to use attribute-specific builder methods like bold() and underline(), which have the same functionality but are pithier.

§Example

Make text bold using attr():

use yansi::{Paint, Attribute};

painted.attr(Attribute::Bold);

Make text bold using using bold().

use yansi::Paint;

painted.bold();
Source§

fn bold(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Bold].

§Example
println!("{}", value.bold());
Source§

fn dim(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Dim].

§Example
println!("{}", value.dim());
Source§

fn italic(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Italic].

§Example
println!("{}", value.italic());
Source§

fn underline(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Underline].

§Example
println!("{}", value.underline());

Returns self with the attr() set to [Attribute :: Blink].

§Example
println!("{}", value.blink());

Returns self with the attr() set to [Attribute :: RapidBlink].

§Example
println!("{}", value.rapid_blink());
Source§

fn invert(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Invert].

§Example
println!("{}", value.invert());
Source§

fn conceal(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Conceal].

§Example
println!("{}", value.conceal());
Source§

fn strike(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Strike].

§Example
println!("{}", value.strike());
Source§

fn quirk(&self, value: Quirk) -> Painted<&T>

Enables the yansi Quirk value.

This method should be used rarely. Instead, prefer to use quirk-specific builder methods like mask() and wrap(), which have the same functionality but are pithier.

§Example

Enable wrapping using .quirk():

use yansi::{Paint, Quirk};

painted.quirk(Quirk::Wrap);

Enable wrapping using wrap().

use yansi::Paint;

painted.wrap();
Source§

fn mask(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Mask].

§Example
println!("{}", value.mask());
Source§

fn wrap(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Wrap].

§Example
println!("{}", value.wrap());
Source§

fn linger(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Linger].

§Example
println!("{}", value.linger());
Source§

fn clear(&self) -> Painted<&T>

👎Deprecated since 1.0.1:

renamed to resetting() due to conflicts with Vec::clear(). The clear() method will be removed in a future release.

Returns self with the quirk() set to [Quirk :: Clear].

§Example
println!("{}", value.clear());
Source§

fn resetting(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Resetting].

§Example
println!("{}", value.resetting());
Source§

fn bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Bright].

§Example
println!("{}", value.bright());
Source§

fn on_bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: OnBright].

§Example
println!("{}", value.on_bright());
Source§

fn whenever(&self, value: Condition) -> Painted<&T>

Conditionally enable styling based on whether the Condition value applies. Replaces any previous condition.

See the crate level docs for more details.

§Example

Enable styling painted only when both stdout and stderr are TTYs:

use yansi::{Paint, Condition};

painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);
Source§

fn new(self) -> Painted<Self>
where Self: Sized,

Create a new Painted with a default Style. Read more
Source§

fn paint<S>(&self, style: S) -> Painted<&Self>
where S: Into<Style>,

Apply a style wholesale to self. Any previous style is replaced. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more