pub struct DcProjectionContext<'a, 'ctx> {
pub arena: &'a DcSyntaxArena<'a>,
pub policy: &'ctx DcProjectionPolicy,
pub shared_context: Option<&'ctx SharedValueContext>,
pub reference_scope: SharedValueContext,
pub annotations: Vec<DcFieldAnnotation>,
pub annotating: bool,
pub record_depth: usize,
pub container_depth: usize,
pub current_position: u64,
pub binary_resolver: Option<&'ctx mut dyn DcBinaryResolver>,
pub resolver: Option<&'a dyn SyntaxRuleResolver>,
pub evaluator: Option<&'a dyn DcExpressionEvaluator>,
/* private fields */
}Expand description
Execution context for projecting typed values from parsed syntax nodes in a DcSyntaxArena.
Fields§
§arena: &'a DcSyntaxArena<'a>Borrowed syntax arena containing all parsed CST nodes for the document or frame.
policy: &'ctx DcProjectionPolicyActive policy dictating diagnostics, strictness, and error recovery actions.
Optional enclosing document context for lexical identifier resolution.
reference_scope: SharedValueContextDocument-local lexical scope tracking scoped definitions (Dc 541..542).
annotations: Vec<DcFieldAnnotation>Accumulated field annotations produced during projection.
annotating: boolFlag indicating whether field annotations should be recorded.
record_depth: usizeCurrent record nesting depth.
container_depth: usizeCurrent non-record container projection nesting depth.
current_position: u64Current stream or node byte offset for diagnostics.
binary_resolver: Option<&'ctx mut dyn DcBinaryResolver>Optional stream-backed resolver for DeferredStream binary payloads.
resolver: Option<&'a dyn SyntaxRuleResolver>Optional syntax rule resolver overlay for character classification and equivalence.
evaluator: Option<&'a dyn DcExpressionEvaluator>Optional expression evaluator for dynamic/Scheme/Lisp-like expression resolution.
Implementations§
Source§impl<'a, 'ctx> DcProjectionContext<'a, 'ctx>
impl<'a, 'ctx> DcProjectionContext<'a, 'ctx>
Sourcepub fn new(
arena: &'a DcSyntaxArena<'a>,
policy: &'ctx DcProjectionPolicy,
) -> Self
pub fn new( arena: &'a DcSyntaxArena<'a>, policy: &'ctx DcProjectionPolicy, ) -> Self
Creates a new projection context over the given arena and policy.
Sourcepub fn resolver(&self) -> &dyn SyntaxRuleResolver
pub fn resolver(&self) -> &dyn SyntaxRuleResolver
Returns the active syntax rule resolver.
Sourcepub fn evaluator(&self) -> Option<&dyn DcExpressionEvaluator>
pub fn evaluator(&self) -> Option<&dyn DcExpressionEvaluator>
Returns the active expression evaluator, if configured.
Sourcepub fn with_syntax_resolver(self, resolver: &'a dyn SyntaxRuleResolver) -> Self
pub fn with_syntax_resolver(self, resolver: &'a dyn SyntaxRuleResolver) -> Self
Sets a custom syntax rule resolver on this projection context.
Sourcepub fn with_evaluator(self, evaluator: &'a dyn DcExpressionEvaluator) -> Self
pub fn with_evaluator(self, evaluator: &'a dyn DcExpressionEvaluator) -> Self
Sets an expression evaluator on this projection context.
Sourcepub fn set_syntax_resolver(&mut self, resolver: &'a dyn SyntaxRuleResolver)
pub fn set_syntax_resolver(&mut self, resolver: &'a dyn SyntaxRuleResolver)
Sets a custom syntax rule resolver on this context in-place.
Sourcepub fn set_evaluator(&mut self, evaluator: &'a dyn DcExpressionEvaluator)
pub fn set_evaluator(&mut self, evaluator: &'a dyn DcExpressionEvaluator)
Sets an expression evaluator on this context in-place.
Sourcepub fn canonical_token(&self, token: DcChar) -> DcChar
pub fn canonical_token(&self, token: DcChar) -> DcChar
Returns the canonical token representation for token.
Sourcepub fn tokens_equivalent(&self, a: impl Into<u128>, b: impl Into<u128>) -> bool
pub fn tokens_equivalent(&self, a: impl Into<u128>, b: impl Into<u128>) -> bool
Returns true if two tokens are identical or declared logically equivalent.
Sourcepub fn any_token_equivalent(
&self,
token: impl Into<u128>,
candidates: &[u128],
) -> bool
pub fn any_token_equivalent( &self, token: impl Into<u128>, candidates: &[u128], ) -> bool
Returns true if token is identical or declared logically equivalent to any
candidate in candidates.
Sourcepub fn token_fills_role(&self, token: impl Into<u128>, role: DcRole) -> bool
pub fn token_fills_role(&self, token: impl Into<u128>, role: DcRole) -> bool
Returns true if token fills role.
Creates a new projection context with an optional enclosing shared context.
Creates a new projection context with an optional shared context and binary resolver.
Sourcepub fn with_all_resolvers(
arena: &'a DcSyntaxArena<'a>,
policy: &'ctx DcProjectionPolicy,
shared_context: Option<&'ctx SharedValueContext>,
binary_resolver: Option<&'ctx mut dyn DcBinaryResolver>,
resolver: Option<&'a dyn SyntaxRuleResolver>,
evaluator: Option<&'a dyn DcExpressionEvaluator>,
) -> Self
pub fn with_all_resolvers( arena: &'a DcSyntaxArena<'a>, policy: &'ctx DcProjectionPolicy, shared_context: Option<&'ctx SharedValueContext>, binary_resolver: Option<&'ctx mut dyn DcBinaryResolver>, resolver: Option<&'a dyn SyntaxRuleResolver>, evaluator: Option<&'a dyn DcExpressionEvaluator>, ) -> Self
Creates a new projection context with full shared context, binary resolver, syntax rule resolver, and optional expression evaluator.
Sourcepub fn from_eval_context(
arena: &'a DcSyntaxArena<'a>,
eval_ctx: &'a SyntaxEvalContext<'a>,
policy: &'ctx DcProjectionPolicy,
) -> Self
pub fn from_eval_context( arena: &'a DcSyntaxArena<'a>, eval_ctx: &'a SyntaxEvalContext<'a>, policy: &'ctx DcProjectionPolicy, ) -> Self
Creates a projection context inheriting the resolver and evaluator from a crate::navigator::SyntaxEvalContext.
Sourcepub fn materialize_binary(
&mut self,
payload: &BinaryPayloadRef<'a>,
) -> Result<Cow<'a, [u8]>>
pub fn materialize_binary( &mut self, payload: &BinaryPayloadRef<'a>, ) -> Result<Cow<'a, [u8]>>
Materializes a crate::navigator::BinaryPayloadRef using the attached
DcBinaryResolver if available, or from in-memory bytes otherwise.
§Errors
Returns an error if the payload is DeferredStream without a resolver,
or if reading/checksum verification fails.
Sourcepub fn node(&self, id: NodeId) -> Result<&'a DcSyntaxNode<'a>>
pub fn node(&self, id: NodeId) -> Result<&'a DcSyntaxNode<'a>>
Returns a reference to the syntax node corresponding to id.
§Errors
Returns an error if id is not present in the arena.
Sourcepub fn handle_remaining_nodes(&mut self, nodes: &[NodeId]) -> Result<()>
pub fn handle_remaining_nodes(&mut self, nodes: &[NodeId]) -> Result<()>
Reports parsed nodes left over after typed projection.
§Errors
Returns an error for missing nodes or if the policy rejects leftovers.
Sourcepub fn strip_leading_document_most_recent_root<'r>(
&self,
roots: &'r [NodeId],
) -> &'r [NodeId]
pub fn strip_leading_document_most_recent_root<'r>( &self, roots: &'r [NodeId], ) -> &'r [NodeId]
Skips a leading Dc 641 "Global graph system block most recent node ID at time of document creation"
or Dc 340 "Begin execution environment description" document header node when present before the payload root(s).
Sourcepub fn diagnostics(&self) -> &[SyntaxDiagnostic]
pub fn diagnostics(&self) -> &[SyntaxDiagnostic]
Returns anomalies retained during projection, including quiet recovery.
Sourcepub fn handle_diagnostic(
&mut self,
action: DiagnosticAction,
message: impl Into<String>,
) -> Result<()>
pub fn handle_diagnostic( &mut self, action: DiagnosticAction, message: impl Into<String>, ) -> Result<()>
Records a projection anomaly and applies the caller’s chosen action.
§Errors
Returns an error when the action rejects the anomaly.
Sourcepub fn handle_unconsumed_or_incomplete(
&mut self,
unconsumed_descriptions: &[String],
missing_fields: &[&'static str],
) -> Result<()>
pub fn handle_unconsumed_or_incomplete( &mut self, unconsumed_descriptions: &[String], missing_fields: &[&'static str], ) -> Result<()>
Checks for unconsumed Dc elements or missing required fields after decoding a container or document, consulting the projection policy in a single place.
§Errors
Returns an error if the active policy rejects unconsumed elements or missing fields.
Sourcepub fn with_projection_depth<R>(
&mut self,
node_id: NodeId,
f: impl FnOnce(&mut Self) -> Result<R>,
) -> Result<R>
pub fn with_projection_depth<R>( &mut self, node_id: NodeId, f: impl FnOnce(&mut Self) -> Result<R>, ) -> Result<R>
Executes f while tracking projection recursion depth against policy.max_depth.
Resolves a shared reference name against the local or outer shared context.
Sourcepub fn enter_reference_scope(&mut self)
pub fn enter_reference_scope(&mut self)
Enters a local lexical scope (Dc 541).
Sourcepub fn exit_reference_scope(&mut self) -> Result<()>
pub fn exit_reference_scope(&mut self) -> Result<()>
Exits a local lexical scope (Dc 542).
Sourcepub fn decode_declaration<T: Any + Send + Sync + DcMixedDecode + 'static>(
&mut self,
node_id: NodeId,
) -> Result<Arc<T>>
pub fn decode_declaration<T: Any + Send + Sync + DcMixedDecode + 'static>( &mut self, node_id: NodeId, ) -> Result<Arc<T>>
Decodes an assignment declaration (Dc 269) and registers it in the local reference scope.
Sourcepub fn is_representation_set_token(&self, token: u128) -> bool
pub fn is_representation_set_token(&self, token: u128) -> bool
Returns true if token represents a full or partial alternative-representation wrapper.
Sourcepub fn is_representation_set_node(&self, node: &DcSyntaxNode<'_>) -> bool
pub fn is_representation_set_node(&self, node: &DcSyntaxNode<'_>) -> bool
Returns true if node is an alternative-representation container or tagged construct.
Sourcepub fn find_bound_assignment(&self, name: &DcMstr) -> Option<NodeId>
pub fn find_bound_assignment(&self, name: &DcMstr) -> Option<NodeId>
Finds an assignment declaration (ident = value or lang.assign(ident, value)) in the arena
by its identifier name, searching in reverse document order.
Sourcepub fn find_bound_assignment_at(
&self,
name: &DcMstr,
at_node_id: NodeId,
) -> Option<NodeId>
pub fn find_bound_assignment_at( &self, name: &DcMstr, at_node_id: NodeId, ) -> Option<NodeId>
Finds an assignment declaration (ident = value or lang.assign(ident, value)) visible
at at_node_id, honoring Dc 541 "Enter identifier scope" .. Dc 542 "Exit identifier scope"
lexical scope boundaries and reverse-chronological shadowing prior to at_node_id.
Sourcepub fn resolve_expression_node(&self, node_id: NodeId) -> Result<Option<NodeId>>
pub fn resolve_expression_node(&self, node_id: NodeId) -> Result<Option<NodeId>>
Resolves a bound or named reference to its value’s CST NodeId if possible.
Sourcepub fn resolve_expression_or_self(&self, node_id: NodeId) -> Result<NodeId>
pub fn resolve_expression_or_self(&self, node_id: NodeId) -> Result<NodeId>
Resolves an expression node to its target NodeId, or returns node_id unchanged.
Sourcepub fn transparent_candidates(&self, node_id: NodeId) -> Result<Vec<NodeId>>
pub fn transparent_candidates(&self, node_id: NodeId) -> Result<Vec<NodeId>>
Extracts all concrete candidate node IDs after unwrapping optional (Dc 315),
expression (Dc 540, Dc 276, Dc 279), and equivalent/partially-equivalent
(Dc 397, Dc 538) wrappers.
Sourcepub fn equivalent_candidates(&self, node_id: NodeId) -> Result<Vec<NodeId>>
pub fn equivalent_candidates(&self, node_id: NodeId) -> Result<Vec<NodeId>>
Extracts all candidate representation node IDs from an equivalent or partially
equivalent representations container (Dc 397 or Dc 398), filtering out
type headers and list element separators.
If node_id is not an equivalent representation set, returns a single-element
vector containing node_id.
Sourcepub fn unwrap_equivalent_matching<F>(
&self,
node_id: NodeId,
predicate: F,
) -> Result<NodeId>
pub fn unwrap_equivalent_matching<F>( &self, node_id: NodeId, predicate: F, ) -> Result<NodeId>
Unwraps equivalent representation containers (Dc 397 or Dc 398) to a child
matching the predicate, or the first valid candidate if none or no predicate given.
Sourcepub fn unwrap_equivalent_or_self(&self, node_id: NodeId) -> Result<NodeId>
pub fn unwrap_equivalent_or_self(&self, node_id: NodeId) -> Result<NodeId>
Unwraps equivalent representation containers (Dc 397 or Dc 398) or expression
nodes (Dc 540, Dc 276, Dc 279) to their primary child.
Sourcepub fn decode_equivalent<T, F>(
&mut self,
node_id: NodeId,
decode_fn: F,
) -> Result<T>
pub fn decode_equivalent<T, F>( &mut self, node_id: NodeId, decode_fn: F, ) -> Result<T>
Attempts to decode a typed value from an equivalent representation set by testing candidate representation children in sequence and selecting the first candidate that decodes cleanly without error.
Sourcepub fn decode_transparent<T, F>(
&mut self,
node_id: NodeId,
decode_fn: F,
) -> Result<T>
pub fn decode_transparent<T, F>( &mut self, node_id: NodeId, decode_fn: F, ) -> Result<T>
Transparently decodes a target type from node_id, unwrapping optionals (Dc 315),
resolving bound references (Dc 540, Dc 276) and routine invocations (Dc 279),
and selecting a candidate from equivalent or partially equivalent representation sets
(Dc 397, Dc 398) that decodes cleanly.
Sourcepub fn extract_field_projection_spec(
&self,
child_id: NodeId,
) -> Result<FieldProjectionSpec>
pub fn extract_field_projection_spec( &self, child_id: NodeId, ) -> Result<FieldProjectionSpec>
Extracts the field tag, value node, and source node for a struct or variant child node.
Sourcepub fn decode_field_candidates<F>(
&mut self,
spec: FieldProjectionSpec,
decode_fn: F,
) -> Result<(FieldProjectionSpec, Result<bool>)>
pub fn decode_field_candidates<F>( &mut self, spec: FieldProjectionSpec, decode_fn: F, ) -> Result<(FieldProjectionSpec, Result<bool>)>
Evaluates a field-decoding closure across transparent candidates (Dc 397, Dc 398,
Dc 315) when a struct or enum-variant field entry is wrapped in a representation set.
Sourcepub fn unwrap_optional_node(
&mut self,
node_id: NodeId,
) -> Result<Option<NodeId>>
pub fn unwrap_optional_node( &mut self, node_id: NodeId, ) -> Result<Option<NodeId>>
Unwraps an optional marker (Dc 315 or Dc 316).
Returns Ok(None) for absent, Ok(Some(inner_id)) for present.
Sourcepub fn unwrap_format_representation(
&self,
node_id: NodeId,
) -> Result<Option<(DcChar, NodeId)>>
pub fn unwrap_format_representation( &self, node_id: NodeId, ) -> Result<Option<(DcChar, NodeId)>>
Unwraps a format representation container (511 [format] [payload] 512).
Returns Ok(Some((format, payload_id))) if this is a format representation.
Sourcepub fn unwrap_bound_reference(
&self,
node_id: NodeId,
) -> Result<Option<DcMstring>>
pub fn unwrap_bound_reference( &self, node_id: NodeId, ) -> Result<Option<DcMstring>>
Unwraps a bound reference (Dc 540 or Dc 276 + identifier).
Sourcepub fn unwrap_transparent_matching<F>(
&self,
node_id: NodeId,
predicate: F,
) -> Result<NodeId>
pub fn unwrap_transparent_matching<F>( &self, node_id: NodeId, predicate: F, ) -> Result<NodeId>
Repeatedly unwraps transparent wrappers (397/398/561 equivalent lists,
315 optionals, and 540/276 reference nodes), using predicate
to select a preferred candidate child from representation sets.
Sourcepub fn unwrap_transparent(&self, node_id: NodeId) -> Result<NodeId>
pub fn unwrap_transparent(&self, node_id: NodeId) -> Result<NodeId>
Repeatedly unwraps transparent wrappers (397/398/561 equivalent lists,
315 optionals, and 540/276/279 expression nodes).
Sourcepub fn extract_kv_map_entries(
&mut self,
node_id: NodeId,
) -> Result<(DcKvMapEncoding, Vec<Result<(NodeId, NodeId, Range<usize>, u64)>>)>
pub fn extract_kv_map_entries( &mut self, node_id: NodeId, ) -> Result<(DcKvMapEncoding, Vec<Result<(NodeId, NodeId, Range<usize>, u64)>>)>
Extracts key-value map entries from a Dc 559..560 or legacy Dc 313..314
container, returning the map encoding and per-entry (key_id, val_id, span, start_pos)
results so callers can process valid entries before reporting a later malformed entry.
§Errors
Returns an error if node_id is not a key-value map container.
Trait Implementations§
Auto Trait Implementations§
impl<'a, 'ctx> Freeze for DcProjectionContext<'a, 'ctx>
impl<'a, 'ctx> !RefUnwindSafe for DcProjectionContext<'a, 'ctx>
impl<'a, 'ctx> !Send for DcProjectionContext<'a, 'ctx>
impl<'a, 'ctx> !Sync for DcProjectionContext<'a, 'ctx>
impl<'a, 'ctx> Unpin for DcProjectionContext<'a, 'ctx>
impl<'a, 'ctx> !UnwindSafe for DcProjectionContext<'a, 'ctx>
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§impl<T, U> ExactFrom<T> for Uwhere
U: TryFrom<T>,
impl<T, U> ExactFrom<T> for Uwhere
U: TryFrom<T>,
fn exact_from(value: T) -> U
§impl<T, U> ExactInto<U> for Twhere
U: ExactFrom<T>,
impl<T, U> ExactInto<U> for Twhere
U: ExactFrom<T>,
fn exact_into(self) -> U
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more§impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
fn overflowing_into(self) -> (U, bool)
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§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();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§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();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§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();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§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();§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>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.§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);