Skip to main content

IrItem

Enum IrItem 

Source
pub enum IrItem {
    Type {
        shape: TypeShape,
    },
    Fn {
        receiver: Option<TyId>,
        params: Vec<(String, TyId)>,
        ret: TyId,
        body: IrExpr,
        effectful: bool,
    },
    Agent {
        def: String,
        key: (String, TyId),
        state: Vec<StoreFieldIr>,
        handlers: Vec<IrHandler>,
        invariants: Vec<IrPredicate>,
        transitions: Vec<IrPredicate>,
    },
    Service {
        def: String,
        protocol: ProtocolIr,
        handlers: Vec<IrHandler>,
        policy: Option<PolicyIr>,
    },
    Capability {
        def: String,
        ops: Vec<OpSig>,
    },
    Provider {
        def: String,
        cap: String,
        body: ProviderBody,
    },
}
Expand description

P6.6’s real declaration IR (design/bynk-greenfield-compiler.md §6.6, #1161) — a top-level declaration’s own shape, the payload bynk_lower::lower_type_item_ir/bynk_lower::lower_fn_item_ir construct. Identity is adapted per this module’s own “no arena” substitution (DefId -> Arc<TypeDecl>/Arc<FnDecl>, the same substitution Record/GlobalRef already made).

Type, Fn, Agent (P6.10, #1169), Service (P6.11, #1171), Capability (P6.12, #1173) and Provider (P6.14, #1174) exist as variants. Actor is still deferred (Decision D, #1161, matching the issue’s own title: “Agent/Service/Actor/Capability/Provider deferred”). This is a different posture from Match’s own payload (IrPat/IrArm/Exhaustive/MatchForm), which had to exist — even genuinely uninhabited — the moment IrExprKind::Match’s own field list was written, because IrExprKind is one enum whose whole Part 6.2 shape landed in a single slice (P6.1) and never grows a new variant after. IrItem carries no such constraint: nothing outside this module matches on it exhaustively yet (no consumer at all, same posture as every prior P6.x slice), so a later slice can add a wholly new variant rather than needing a placeholder reserved here in advance. Each deferred variant has its own real, distinct blocker, not a shared “later” (full grounding in #1161’s own Decision D — Service’s own two blockers, closed by #1170/#1171, are recorded on IrItem::Service’s own doc comment rather than kept here as a stale bullet):

  • Actor — #1172’s own investigation settled this one as a non-build decision, not an unbuilt gap: the reference’s own sketch (Actor { def, scheme: AuthScheme, identity: Option<TyId>, claims: Option<IrExpr> }, bynk-greenfield-compiler.md:1133) is the wrong shape for this codebase, on three independent findings. (1) claims: Option<IrExpr> is unbuildable, not merely unbuilt: an actor refinement’s own predicate (hasClaim/claimEquals, ActorRefinement::predicate) is validated only structurally (bynk-check/src/actors.rs’s parse_claim_predicate) — no Callee, no expr_types entry, no typing at all, because claims are deliberately untyped JSON (context_checks.rs’s own refinement_predicate_unsupported note) and lowered straight to a JS string by claim_predicate_to_js. An IrExpr here would mean inventing a typing for a surface the checker deliberately never gave one. (2) scheme: AuthScheme names a type the reference defines nowhere else (:1133/:1847 only) — the same “referenced, not specified” gap Capability’s own OpSig carried before OpSig settled it (P6.12, #1173), except here a real 5-variant candidate already ships (bynk-check::actors::Scheme), so this piece alone is specifiable. (3) The decisive finding: every real consumer of actor data — the five bynk-check seam resolvers the shipped emitter consumes (bearer_seam_for/oidc_seam_for/signature_seam_for/ sum_members_for/caller_binder_for, bynk-check/src/actors.rs) and the reference’s own R8.11 (deps derivation)/R8.13 (boundary-wrapper verification) — is handler-keyed, not declaration-keyed: binder presence, sum-member ordering, and which scheme’s config applies are all facts about a handler’s own by clause, not the actor declaration in isolation. This is exactly why the two actor-shaped IR additions that did have a real consumer (ActorBinder, and IrHandler’s own actors: Vec<String>, review of #1180) both landed on IrHandler, not a new IrItem variant — a {def, scheme, identity} record beside IrItem::Service’s handlers would have zero consumers and would not discharge R6.13 for actors at all, the “carve when a dependency arrives, not on appetite” anti-pattern R10.3 already argues against elsewhere in this track. Revisit only if a real phase-7 printer needs declaration-level actor data beyond what IrHandler::binder/IrHandler::actors already carry — not before.

  • Provider — #1174’s own investigation found this one buildable this slice, unlike Actor: the real ProviderDecl (bynk-syntax/src/ast.rs:582-600) already carries the exact Bynk/External dispatch the reference’s own // Bynk ops | External(module) comment names (never a real Rust enum in the document itself — the same “referenced, not specified” gap Capability’s own OpSig carried before #1173 settled it), via external: bool plus ops: Vec<ProviderOp> (empty exactly when external is true, per the field’s own doc comment, bynk-syntax/src/ast.rs:592-595). And unlike CapabilityOp, a ProviderOp’s own body is a real, fully type-checked handler body — check_provider_decls (bynk-check/src/context_checks.rs:626) pushes every op through checker::check_handler_body (:667) with the provider’s own given as its capability scope and no self/state/store binding at all (HandlerBodyCheck::new’s own “everything optional empty” default, bynk-check/src/checker.rs:1055) — so bynk_lower::lower_provider_op_ir mirrors bynk_lower::lower_fn_body_ir (ADR 0334 panic-on-miss, not bynk_lower::lower_op_sig_ir’s lenient Ty::Unit fallback: this body’s types are checker-guaranteed to resolve, same as a fn’s) with no receiver/self and no rigid type variables (ProviderOp carries none of its own, bynk-syntax/src/ast.rs:604-611). ProviderBody::Bynk’s own ops: Vec<ProviderOpIr> is real per-op signature-plus-body, one ProviderOpIr per bynk_lower::lower_provider_op_ir call, in declaration order.

    given is carried, module is not — the two omissions are not symmetric (review of #1186). R8.1’s own Provider{Bynk} row is export class with a deps constructor (bynk-greenfield-compiler.md:1309), built today straight off ProviderDecl::given (bynk-emit/src/project.rs:2608-2620) — unlike module, given is not one-phase-up data, it lives on the very ProviderDecl this function already holds, and it is not reconstructible from the lowered op bodies alone: an unused given capability, a cross-context given B.Cap prefix (CapRef::context, v0.15), and declaration order would all silently vanish if this variant carried only ops. So ProviderBody::Bynk also carries given: Vec<CapRefIr>CapRefIr adapts CapRef under this module’s usual “no arena, bare name” substitution (context’s own QualifiedName flattened via .joined()), leaving resolving a prefix against consumes/aliases to whichever future project-level pass also resolves modulebynk_lower::lower_provider_item_ir does no more than bynk_lower::lower_capability_item_ir already declines to do for a capability op’s own type refs. ProviderBody::External deliberately carries no module field, despite the reference’s own parenthetical — that name lives one phase up from this per-context CheckedProgram, on the adapter’s own binding "<module>" clause (BindingDecl::module, bynk-syntax/src/ast.rs:186), resolved only by the whole-project pass into adapter_bindings: HashMap<String, AdapterBinding> (bynk-check/src/project_model.rs:729) — data no other lower_X_item_ir function in this module reaches either. Nothing needs it yet: R8.1’s own emission table already gives Provider{External} “nothing — the binding module supplies it” (bynk-greenfield-compiler.md:1310), i.e. even phase 7’s own per-item printer does not consume a module name — only the still-AST-driven project.rs’s existing import wiring does (bynk-emit/src/project.rs:2675-2678), untouched by this slice. Revisit only once a real project-level IR/linking phase gives this module something to thread the module name through.

Variants§

§

Type

A type declaration. shape covers all three real TypeShape forms. P6.39: def: Arc<TypeDecl> dropped — its one production consumer (emitter.rs’s type_shape_for call site) already ignored it via .., and no other reader existed.

Fields

§

Fn

A fn declaration — free function or method alike (FnName::Free/ FnName::Method); which IrItem::Fns a future printer re-attaches under which IrItem::Type’s own namespace (R8.1) is phase 7’s own concern, not decided here. P6.39: def: Arc<FnDecl> dropped — lower_fn_item_ir (the one constructor) has no production call site at all today; every other field remains, so the constructor and this variant both survive, just without the raw declaration.

Fields

§receiver: Option<TyId>

The method receiver’s own type, generic in the owning type’s own rigid variables (e.g. Box[A]’s self is Ty::Named { name: "Box", args: [Ty::Var("A")], .. }) — None for a free function. Not in params: self is never in f.params either (FnDecl::has_self gates it, mirrored by bynk_lower::lower_fn_body_ir’s own binding), but body still references it as Local { name: "self" } when has_self is true — a consumer that walks body needs this field to know what that bare name resolves to, rather than re-deriving the generic-receiver type itself from def.

§params: Vec<(String, TyId)>

Adapts the reference’s own bare Vec<LocalId> to Vec<(String, TyId)> (Decision E, #1161) — no arena exists to look a param’s type back up from its name alone once this IrItem outlives the LowerIrCtx that resolved it, unlike every other Decision-B “name only” substitution in this module, where the type is either implied by context or carried alongside on the same node (e.g. IrExpr::ty).

§ret: TyId
§body: IrExpr

bynk_lower::lower_fn_body_ir’s own return value, unchanged (#1141) — this constructor adds no further transformation.

§effectful: bool

Derived once from ret’s structural shape (Ty::Fn’s own doc comment, bynk-check/src/checker.rs: effectful iff ret is Effect[_]), never threaded from anywhere else — the same single-source-of-truth discipline this module already follows for BindingMode/Exhaustive.

§

Agent

P6.10’s real IrItem::Agent (Part 6.6, R6.13, #1169) — bynk_lower::lower_agent_item_ir’s own return value, assembling every P6.7–P6.9 ingredient (StoreFieldIr, CommitShape/IrPredicate, IrHandler) that had no IrItem variant to land in until now. Matches the reference’s own sketch (bynk-greenfield-compiler.md:1129-1131) field-for-field, under this module’s already-established substitutions.

Fields

§def: String

The agent’s own declared name — this module’s usual “no arena” substitution for the reference’s own DefId, but not the same substitution IrItem::Type/IrItem::Fn made (Arc<TypeDecl>/Arc<FnDecl>): unlike types/fns, TypedCommons carries no Arc-wrapped agents table to source a cheap pointer from (UnitTable::agents/CommonsItem::Agent are both a plain, owned AgentDecl), and Callee::Agent { agent: String, handler: String } already establishes bare-name identity as sufficient for this checked output — a full AgentDecl clone (its own handler bodies included) would be needless weight this module’s other String-identity fields (GlobalRef::tag, Callee::Store::field, …) don’t carry either.

§key: (String, TyId)

key id: Type adapted from the reference’s own bare (LocalId, TyId) (Decision B extended): the bound name plus its resolved type, the same Vec<(String, TyId)>-per-entry substitution IrItem::Fn::params already made for a Vec<LocalId>.

§state: Vec<StoreFieldIr>

Every store field, bynk_lower::lower_store_field_ir’s own return value, in declaration order.

§handlers: Vec<IrHandler>

Every on call handler, bynk_lower::lower_handler_ir’s own return value, in declaration order.

§invariants: Vec<IrPredicate>

Every invariant, bynk_lower::lower_invariant_ir’s own return value, in declaration order — the same already-lowered list each handlers entry’s own commit: CommitShape::Transactional (when it is one) carries a copy of, not a fresh lowering.

§transitions: Vec<IrPredicate>

Every transition, bynk_lower::lower_transition_ir’s own return value, in declaration order — same relationship to handlers as invariants.

§

Service

P6.11’s real IrItem::Service (Part 6.6, R6.13, #1171) — bynk_lower::lower_service_item_ir’s own return value, the sibling assembly to IrItem::Agent. Matches the reference’s own sketch (bynk-greenfield-compiler.md:1132) field-for-field. Closes the two blockers this variant carried while deferred: a real service IrHandler needed the binder-persistence bynk-check change #1170 made, and the CORS/security-headers/request-body-size policy surface the reference sketch never shows at all now has a real, specified shape (ProtocolIr/PolicyIr).

Fields

§def: String

The service’s own declared name — same reasoning as IrItem::Agent’s own def: UnitTable::services is a plain owned HashMap<String, ServiceDecl>, no Arc to borrow cheaply, and bare-name identity is already sufficient for this checked output.

§protocol: ProtocolIr

bynk_lower::lower_protocol_ir’s own return value.

§handlers: Vec<IrHandler>

Every handler, bynk_lower::lower_service_handler_ir’s own return value, in declaration order.

§policy: Option<PolicyIr>

bynk_lower::lower_policy_ir’s own return value — None whenever protocol is not ProtocolIr::Http, not just when the source declares none of cors/security/limits. See PolicyIr’s own doc comment for why this is Option, not the reference’s own unconditional PolicyIr field.

§

Capability

P6.12’s real IrItem::Capability (Part 6.6, R6.13, #1173) — bynk_lower::lower_capability_item_ir’s own return value. Matches the reference’s own sketch (bynk-greenfield-compiler.md:1134) field-for-field, once OpSig fills in the type the sketch names but never defines.

Fields

§def: String

The capability’s own declared name — same reasoning as IrItem::Agent/IrItem::Service’s own def: UnitTable::capabilities is a plain owned HashMap<String, CapabilityDecl>, no Arc to borrow cheaply, and bare-name identity is already sufficient — Callee::Capability { cap: String, op: String } (bynk-check/src/checker.rs) already resolves a same-context capability call by name alone.

§ops: Vec<OpSig>

Every operation, bynk_lower::lower_op_sig_ir’s own return value, in declaration order.

§

Provider

P6.14’s real IrItem::Provider (Part 6.6, R6.13, #1174) — bynk_lower::lower_provider_item_ir’s own return value. Matches the reference’s own sketch (bynk-greenfield-compiler.md:1135) field-for-field, once ProviderBody fills in the type the sketch’s own comment names but never defines as a real Rust enum.

Fields

§def: String

The provider’s own declared name (ProviderDecl::provider_name, “used in tests/config to select impls”, bynk-syntax/src/ast.rs:586) — distinct from cap below even though UnitTable::providers happens to key by capability name today (“one provider per capability in v0.5”, bynk-check/src/symbols.rs): the reference’s own sketch keeps def/cap as two separate DefIds, and a provider’s own identity is never actually the capability it implements. Same “no arena, bare name is enough” substitution as IrItem::Agent/Service/Capability’s own def.

§cap: String

The capability this provider implements (ProviderDecl::capability) — same bare-name substitution as def; resolves against Callee::Capability’s own cap: String the identical way IrItem::Capability::def does.

§body: ProviderBody

bynk_lower::lower_provider_item_ir’s own Bynk/External dispatch, read straight off ProviderDecl::external.

Trait Implementations§

Source§

impl Clone for IrItem

Source§

fn clone(&self) -> IrItem

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for IrItem

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> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

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

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

§

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

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

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

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

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

Source§

type Error = 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.