pub struct BatchEngine { /* private fields */ }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
impl BatchEngine
Sourcepub 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.
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>>,
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.
processruns on the loop task (cancellation-aware between awaits) and may fan records out or in; it MUST preservecommit_tokens(useWorkBatch::map_records, which does so automatically).sinkis async and receives the WHOLE out-batch by reference.commitselectsCommitMode::Auto(engine commits after sinkOk) orCommitMode::SinkManaged(sink owns commit).tickeris 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.
Sourcepub 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.
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>>,
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.
Sourcepub 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.
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>>,
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 viaobserve. The recvmaxis capped to the budget’s poll-safetyrecord_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.
Sourcepub 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.
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>>,
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
impl BatchEngine
Sourcepub fn new(config: BatchProcessingConfig) -> Self
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.
Sourcepub fn with_pool(
pool: Arc<AdaptiveWorkerPool>,
config: BatchProcessingConfig,
) -> Self
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.
Sourcepub fn set_byte_budget(&mut self, budget: Arc<ByteBudgetController>)
Available on crate feature governor only.
pub fn set_byte_budget(&mut self, budget: Arc<ByteBudgetController>)
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.
Sourcepub fn is_self_regulated(&self) -> bool
Available on crate feature governor only.
pub fn is_self_regulated(&self) -> bool
governor only.Whether the self-regulation byte-budget lever is wired (governor
feature). When false, run_governed is the
whole-batch loop.
Sourcepub fn with_filter_dlq_policy(self, policy: FilterDlqPolicy) -> Self
Available on crate feature transport only.
pub fn with_filter_dlq_policy(self, policy: FilterDlqPolicy) -> Self
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.
Sourcepub fn from_cascade(key: &str) -> Result<Self, ConfigError>
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.
Sourcepub fn stats(&self) -> &Arc<PipelineStats> ⓘ
pub fn stats(&self) -> &Arc<PipelineStats> ⓘ
Pipeline statistics (atomic, lock-free).
Sourcepub fn pool(&self) -> &Arc<AdaptiveWorkerPool> ⓘ
pub fn pool(&self) -> &Arc<AdaptiveWorkerPool> ⓘ
Underlying worker pool.
Sourcepub fn config(&self) -> &BatchProcessingConfig
pub fn config(&self) -> &BatchProcessingConfig
Engine configuration.
Sourcepub fn auto_wire(
&mut self,
metrics_manager: &MetricsManager,
memory_guard: Option<&Arc<MemoryGuard>>,
)
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.
Sourcepub fn process_mid_tier<O, E, F>(
&self,
messages: &[Record],
transform: F,
) -> Vec<Result<O, E>>
Available on crate feature transport only.
pub fn process_mid_tier<O, E, F>( &self, messages: &[Record], transform: F, ) -> Vec<Result<O, E>>
transport only.Parse, filter, and transform a batch of raw messages.
Pipeline phases per chunk:
- Pre-route – SIMD field extraction + filter evaluation (sequential, ~100 ns/msg)
- Parse –
sonic_rs::from_slice+ known-field extraction (sequential, ~1-5 µs/msg) - 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.
Sourcepub fn process_raw<O, E, F>(
&self,
messages: &[Record],
transform: F,
) -> Vec<Result<O, E>>
Available on crate feature transport only.
pub fn process_raw<O, E, F>( &self, messages: &[Record], transform: F, ) -> Vec<Result<O, E>>
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§
Auto Trait Implementations§
impl !RefUnwindSafe for BatchEngine
impl !UnwindSafe for BatchEngine
impl Freeze for BatchEngine
impl Send for BatchEngine
impl Sync for BatchEngine
impl Unpin for BatchEngine
impl UnsafeUnpin for BatchEngine
Blanket Implementations§
Source§impl<T> AnyExt for T
impl<T> AnyExt for T
Source§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
T behind referenceSource§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
T behind mutable referenceSource§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
T behind Rc pointerSource§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
T behind Arc pointerSource§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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
fn coerce_rc_to(self: Rc<X>) -> Rc<T>
fn coerce_box_to(self: Box<X>) -> Box<T>
fn coerce_ref_to(&self) -> &T
fn coerce_mut_to(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read moreSource§fn fg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
Source§fn bg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
Source§fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
Source§fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
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 bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
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>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
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 rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
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 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.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
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);