DcProjectionContext

Struct DcProjectionContext 

Source
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 DcProjectionPolicy

Active policy dictating diagnostics, strictness, and error recovery actions.

§shared_context: Option<&'ctx SharedValueContext>

Optional enclosing document context for lexical identifier resolution.

§reference_scope: SharedValueContext

Document-local lexical scope tracking scoped definitions (Dc 541..542).

§annotations: Vec<DcFieldAnnotation>

Accumulated field annotations produced during projection.

§annotating: bool

Flag indicating whether field annotations should be recorded.

§record_depth: usize

Current record nesting depth.

§container_depth: usize

Current non-record container projection nesting depth.

§current_position: u64

Current 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>

Source

pub fn new( arena: &'a DcSyntaxArena<'a>, policy: &'ctx DcProjectionPolicy, ) -> Self

Creates a new projection context over the given arena and policy.

Source

pub fn resolver(&self) -> &dyn SyntaxRuleResolver

Returns the active syntax rule resolver.

Source

pub fn evaluator(&self) -> Option<&dyn DcExpressionEvaluator>

Returns the active expression evaluator, if configured.

Source

pub fn with_syntax_resolver(self, resolver: &'a dyn SyntaxRuleResolver) -> Self

Sets a custom syntax rule resolver on this projection context.

Source

pub fn with_evaluator(self, evaluator: &'a dyn DcExpressionEvaluator) -> Self

Sets an expression evaluator on this projection context.

Source

pub fn set_syntax_resolver(&mut self, resolver: &'a dyn SyntaxRuleResolver)

Sets a custom syntax rule resolver on this context in-place.

Source

pub fn set_evaluator(&mut self, evaluator: &'a dyn DcExpressionEvaluator)

Sets an expression evaluator on this context in-place.

Source

pub fn canonical_token(&self, token: DcChar) -> DcChar

Returns the canonical token representation for token.

Source

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.

Source

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.

Source

pub fn token_fills_role(&self, token: impl Into<u128>, role: DcRole) -> bool

Returns true if token fills role.

Source

pub fn with_shared_context( arena: &'a DcSyntaxArena<'a>, policy: &'ctx DcProjectionPolicy, shared_context: Option<&'ctx SharedValueContext>, ) -> Self

Creates a new projection context with an optional enclosing shared context.

Source

pub fn with_shared_context_and_resolver( arena: &'a DcSyntaxArena<'a>, policy: &'ctx DcProjectionPolicy, shared_context: Option<&'ctx SharedValueContext>, binary_resolver: Option<&'ctx mut dyn DcBinaryResolver>, ) -> Self

Creates a new projection context with an optional shared context and binary resolver.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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).

Source

pub fn diagnostics(&self) -> &[SyntaxDiagnostic]

Returns anomalies retained during projection, including quiet recovery.

Source

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.

Source

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.

Source

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.

Source

pub fn resolve_shared<T: Any + Send + Sync>( &self, binding: impl Into<DcMstring>, ) -> Result<Arc<T>>

Resolves a shared reference name against the local or outer shared context.

Source

pub fn enter_reference_scope(&mut self)

Enters a local lexical scope (Dc 541).

Source

pub fn exit_reference_scope(&mut self) -> Result<()>

Exits a local lexical scope (Dc 542).

Source

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.

Source

pub fn is_representation_set_token(&self, token: u128) -> bool

Returns true if token represents a full or partial alternative-representation wrapper.

Source

pub fn is_representation_set_node(&self, node: &DcSyntaxNode<'_>) -> bool

Returns true if node is an alternative-representation container or tagged construct.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn unwrap_equivalent_matching<F>( &self, node_id: NodeId, predicate: F, ) -> Result<NodeId>
where F: FnMut(NodeId) -> bool,

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.

Source

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.

Source

pub fn decode_equivalent<T, F>( &mut self, node_id: NodeId, decode_fn: F, ) -> Result<T>
where F: FnMut(&mut Self, NodeId) -> 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.

Source

pub fn decode_transparent<T, F>( &mut self, node_id: NodeId, decode_fn: F, ) -> Result<T>
where F: FnMut(&mut Self, NodeId) -> 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.

Source

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.

Source

pub fn decode_field_candidates<F>( &mut self, spec: FieldProjectionSpec, decode_fn: F, ) -> Result<(FieldProjectionSpec, Result<bool>)>
where F: FnMut(&mut Self, 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.

Source

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.

Source

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.

Source

pub fn unwrap_bound_reference( &self, node_id: NodeId, ) -> Result<Option<DcMstring>>

Unwraps a bound reference (Dc 540 or Dc 276 + identifier).

Source

pub fn unwrap_transparent_matching<F>( &self, node_id: NodeId, predicate: F, ) -> Result<NodeId>
where F: FnMut(NodeId) -> bool,

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.

Source

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).

Source

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§

Source§

impl Debug for DcProjectionContext<'_, '_>

Source§

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

Formats the value using the given formatter. Read more

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§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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
§

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

§

fn exact_from(value: T) -> U

§

impl<T, U> ExactInto<U> for T
where U: ExactFrom<T>,

§

fn exact_into(self) -> U

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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
§

impl<T, U> OverflowingInto<U> for T
where U: OverflowingFrom<T>,

§

fn overflowing_into(self) -> (U, bool)

§

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

§

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 primary(&self) -> Painted<&T>

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

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

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

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

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

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));
§

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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>

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

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

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

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

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

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));
§

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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 bold(&self) -> Painted<&T>

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

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

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

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

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

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

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

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

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());
§

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

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

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

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

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

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

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

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

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

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 mask(&self) -> Painted<&T>

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

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

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

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

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

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

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

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

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());
§

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

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

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

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

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

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

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

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

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

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);
§

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

Create a new [Painted] with a default [Style]. Read more
§

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: 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
§

impl<T, U> RoundingInto<U> for T
where U: RoundingFrom<T>,

§

fn rounding_into(self, rm: RoundingMode) -> (U, Ordering)

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, U> SaturatingInto<U> for T
where U: SaturatingFrom<T>,

§

fn saturating_into(self) -> U

§

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

§

fn to_debug_string(&self) -> String

Returns the String produced by Ts Debug implementation.

§Examples
use malachite_base::strings::ToDebugString;

assert_eq!([1, 2, 3].to_debug_string(), "[1, 2, 3]");
assert_eq!(
    [vec![2, 3], vec![], vec![4]].to_debug_string(),
    "[[2, 3], [], [4]]"
);
assert_eq!(Some(5).to_debug_string(), "Some(5)");
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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T, U> WrappingInto<U> for T
where U: WrappingFrom<T>,

§

fn wrapping_into(self) -> U

§

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

§

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

§

impl<T> ErasedDestructor for T
where T: 'static,

§

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