pub struct AuthNetworkAccount { /* private fields */ }Expand description
An AccountComponent implementing an authentication scheme that restricts what notes an
account can consume to a fixed allowlist of note script roots, and what transaction scripts may
run against the account to a fixed allowlist of tx script roots.
This is intended for network-owned accounts (e.g. the AggLayer bridge or a network faucet) whose only legitimate inputs are a known, finite set of system-issued notes and scripts.
The component exports a single auth procedure, auth_network_transaction, that rejects the
transaction unless:
- the transaction script root, if any, is present in the component’s tx-script allowlist, and
- every consumed input note has a script root present in the component’s note-script allowlist.
If both checks pass, the procedure pays the transaction fee by creating a public TX_FEE
note funded from the account’s vault in the native fee asset at rate 1/1 (see
miden::standards::fee::pay_fee and miden::standards::fee::native_conversion_info). On
chains with a zero verification base fee no note is created.
Because a network account has no signature gate by default, a transaction script is an unconstrained code path that could call the account’s procedures directly. The tx-script allowlist constrains this to a fixed set of owner-approved scripts; an empty tx-script allowlist permits no transaction scripts at all.
IMPORTANT: an allowlisted root pins a script’s code (its MAST root), not the inputs it runs
on. A tx script still receives caller-controlled TX_SCRIPT_ARGS and advice-provider inputs,
and a note script receives caller-controlled NOTE_ARGS; on an open network account anyone can
supply those. A root should therefore only be allowlisted when the script’s effect is safe for
every possible input. The canonical example is a tx script that sets the transaction
expiration delta to a hardcoded constant: its effect is fixed regardless of caller or inputs,
and the kernel only ever lets a script tighten the current transaction’s expiration window
(never extend it), so the worst a caller can do is make their own transaction expire sooner.
Allowlisting a script whose effect depends on its inputs re-opens the very code path the
allowlist exists to constrain.
The note allowlist is stored in the standardized NetworkAccountNoteAllowlist slot so
off-chain services can identify a network account by checking for this slot.
Both allowlists can be updated after deployment via the add_allowed_note_script /
remove_allowed_note_script and add_allowed_tx_script / remove_allowed_tx_script account
procedures. These are gated by the account-wide
Authority component, which must be composed onto the
account in OwnerControlled or
RbacControlled mode.
AuthControlled mode is unsafe here
because this component’s auth scheme is intentionally permissionless, so authorization to mutate
the allowlists must come from an owner or a role rather than from the auth scheme itself.
An update is driven by a note the authorized party sends to the account. That admin note’s own script root must already be in the note-script allowlist so the transaction passes auth. The auth procedure reads the allowlists from the transaction’s initial state, so an update only takes effect from the next transaction.
§Fee policy
This component owns the fee-policy related storage slots and procedures. It carries the
FeePolicyManager it was constructed with, which configures those slots, and, when expanded
into AccountComponents, yields the components of the manager’s registered fee policies right
after itself. The auth procedure also collects fees from FEE_SPONSORSHIP input notes,
denominated in the configured fee asset.
Because every network transaction pays a fee, the fee policy is not optional: the component is
constructed from a FeePolicyManager, which initializes the slots from the manager’s active
policy, allowed policies and fee asset.
§Sponsorship policy
Paying the fee also sponsors every network output note the transaction creates, out of this
account’s vault. The component’s SponsorshipPolicy decides whether that spending is bounded
by what the account collected in the same transaction. It defaults to
SponsorshipPolicy::AtMostCollectedFees, so an account only forwards value it collected.
Accounts that are meant to subsidise their own outgoing notes opt into
SponsorshipPolicy::Unlimited.
Implementations§
Source§impl AuthNetworkAccount
impl AuthNetworkAccount
Sourcepub const NAME: &'static str = "miden::standards::auth::network_account"
pub const NAME: &'static str = "miden::standards::auth::network_account"
The name of the component.
Sourcepub fn new(
allowed_notes: BTreeSet<NoteScriptRoot>,
fee_policy_manager: FeePolicyManager,
) -> Result<AuthNetworkAccount, NetworkAccountNoteAllowlistError>
pub fn new( allowed_notes: BTreeSet<NoteScriptRoot>, fee_policy_manager: FeePolicyManager, ) -> Result<AuthNetworkAccount, NetworkAccountNoteAllowlistError>
Creates a new AuthNetworkAccount component configured with the standard network-account
defaults on top of the provided input-note script roots, paying fees per the given
FeePolicyManager.
On top of allowed_notes, the following default configuration is always applied (use
custom for a variant that applies none of it):
- The standardized
NetworkAccountConfigNotescript root is added to the note allowlist, so the account’s allowlists can be updated after deployment by sending that note. - The
FeeSponsorshipNotescript root is added to the note allowlist. A network account collects prepaid fees by consuming these notes, so without it, fees could not be collected. Allowlisting it is safe: the note’s own script refuses consumption without the note it sponsors, and fee collection asserts every consumed note’s fee is covered by the sponsorships bound to it. - The tx-script allowlist contains the
ExpirationTransactionScriptroot, which the network transaction builder attaches to every network transaction, so the account is serviceable by the network.
The active policy, allowed policies and fee asset of fee_policy_manager initialize the
three fee-policy storage slots this component owns. The manager is carried by the component
and the components of its registered policies are emitted alongside it when the component is
expanded (see the IntoIterator impl), so the caller does not install them separately.
Sourcepub fn default_allowed_note_scripts() -> [NoteScriptRoot; 2]
pub fn default_allowed_note_scripts() -> [NoteScriptRoot; 2]
Returns the note script roots added to every standard network account’s allowlist.
Sourcepub fn custom(
allowed_notes: BTreeSet<NoteScriptRoot>,
fee_policy_manager: FeePolicyManager,
) -> Result<AuthNetworkAccount, NetworkAccountNoteAllowlistError>
pub fn custom( allowed_notes: BTreeSet<NoteScriptRoot>, fee_policy_manager: FeePolicyManager, ) -> Result<AuthNetworkAccount, NetworkAccountNoteAllowlistError>
Creates a raw AuthNetworkAccount component from the given note-script allowlist, with an
empty tx-script allowlist and without any default configuration.
Most callers should use Self::new to include the defaults.
Sourcepub fn with_sponsorship_policy(
self,
sponsorship_policy: SponsorshipPolicy,
) -> AuthNetworkAccount
pub fn with_sponsorship_policy( self, sponsorship_policy: SponsorshipPolicy, ) -> AuthNetworkAccount
Sets the SponsorshipPolicy bounding how much the account spends sponsoring the network
notes it creates.
Sourcepub fn with_allowed_tx_scripts(
self,
allowed_tx_script_roots: impl IntoIterator<Item = TransactionScriptRoot>,
) -> AuthNetworkAccount
pub fn with_allowed_tx_scripts( self, allowed_tx_script_roots: impl IntoIterator<Item = TransactionScriptRoot>, ) -> AuthNetworkAccount
Extends the tx-script allowlist with the given transaction script roots, keeping any that are already allowlisted.
Only tx scripts whose effect is safe for every possible input should be allowlisted: a root
pins the script’s code but not its TX_SCRIPT_ARGS or advice inputs, which the (arbitrary)
transaction submitter controls. See the AuthNetworkAccount type docs for the full
rationale.
Sourcepub const fn name() -> AccountComponentName
pub const fn name() -> AccountComponentName
Returns the canonical AccountComponentName of this component.
Sourcepub fn code() -> &'static AccountComponentCode
pub fn code() -> &'static AccountComponentCode
Returns the AccountComponentCode of this component.
Sourcepub fn allowed_notes(&self) -> &NetworkAccountNoteAllowlist
pub fn allowed_notes(&self) -> &NetworkAccountNoteAllowlist
Returns the NetworkAccountNoteAllowlist of this component.
Sourcepub fn allowed_tx_scripts(&self) -> &NetworkAccountTxScriptAllowlist
pub fn allowed_tx_scripts(&self) -> &NetworkAccountTxScriptAllowlist
Returns the NetworkAccountTxScriptAllowlist of this component.
Sourcepub fn sponsorship_policy(&self) -> SponsorshipPolicy
pub fn sponsorship_policy(&self) -> SponsorshipPolicy
Returns the SponsorshipPolicy of this component.
Sourcepub fn add_allowed_note_script_root() -> AccountProcedureRoot
pub fn add_allowed_note_script_root() -> AccountProcedureRoot
Returns the procedure root of the add_allowed_note_script procedure exposed by this
component.
Sourcepub fn remove_allowed_note_script_root() -> AccountProcedureRoot
pub fn remove_allowed_note_script_root() -> AccountProcedureRoot
Returns the procedure root of the remove_allowed_note_script procedure exposed by this
component.
Sourcepub fn add_allowed_tx_script_root() -> AccountProcedureRoot
pub fn add_allowed_tx_script_root() -> AccountProcedureRoot
Returns the procedure root of the add_allowed_tx_script procedure exposed by this
component.
Sourcepub fn remove_allowed_tx_script_root() -> AccountProcedureRoot
pub fn remove_allowed_tx_script_root() -> AccountProcedureRoot
Returns the procedure root of the remove_allowed_tx_script procedure exposed by this
component.
Sourcepub fn estimate_note_fee_root() -> AccountProcedureRoot
pub fn estimate_note_fee_root() -> AccountProcedureRoot
Returns the procedure root of the estimate_note_fee procedure exposed by this component.
Sourcepub fn set_fee_policy_root() -> AccountProcedureRoot
pub fn set_fee_policy_root() -> AccountProcedureRoot
Returns the procedure root of the set_fee_policy procedure exposed by this component.
Sourcepub fn get_fee_policy_root() -> AccountProcedureRoot
pub fn get_fee_policy_root() -> AccountProcedureRoot
Returns the procedure root of the get_fee_policy procedure exposed by this component.
Sourcepub fn get_fee_asset_id_root() -> AccountProcedureRoot
pub fn get_fee_asset_id_root() -> AccountProcedureRoot
Returns the procedure root of the get_fee_asset_id procedure exposed by this component.
Sourcepub fn add_allowed_fee_policy_root() -> AccountProcedureRoot
pub fn add_allowed_fee_policy_root() -> AccountProcedureRoot
Returns the procedure root of the add_allowed_fee_policy account procedure.
Sourcepub fn remove_allowed_fee_policy_root() -> AccountProcedureRoot
pub fn remove_allowed_fee_policy_root() -> AccountProcedureRoot
Returns the procedure root of the remove_allowed_fee_policy account procedure.
Sourcepub fn allowed_note_scripts_slot() -> &'static StorageSlotName
pub fn allowed_note_scripts_slot() -> &'static StorageSlotName
Returns the storage slot holding the allowlist of allowed input-note script roots.
Sourcepub fn allowed_note_scripts_slot_schema() -> (StorageSlotName, StorageSlotSchema)
pub fn allowed_note_scripts_slot_schema() -> (StorageSlotName, StorageSlotSchema)
Returns the storage slot schema for the note-script allowlist slot.
Sourcepub fn allowed_tx_scripts_slot() -> &'static StorageSlotName
pub fn allowed_tx_scripts_slot() -> &'static StorageSlotName
Returns the storage slot holding the allowlist of allowed transaction script roots.
Sourcepub fn allowed_tx_scripts_slot_schema() -> (StorageSlotName, StorageSlotSchema)
pub fn allowed_tx_scripts_slot_schema() -> (StorageSlotName, StorageSlotSchema)
Returns the storage slot schema for the tx-script allowlist slot.
Sourcepub fn sponsorship_policy_slot() -> &'static StorageSlotName
pub fn sponsorship_policy_slot() -> &'static StorageSlotName
Returns the storage slot holding the sponsorship policy.
Sourcepub fn sponsorship_policy_slot_schema() -> (StorageSlotName, StorageSlotSchema)
pub fn sponsorship_policy_slot_schema() -> (StorageSlotName, StorageSlotSchema)
Returns the storage slot schema for the sponsorship policy slot.
Sourcepub fn component_metadata() -> AccountComponentMetadata
pub fn component_metadata() -> AccountComponentMetadata
Returns the AccountComponentMetadata for this component.
Trait Implementations§
Source§impl IntoIterator for AuthNetworkAccount
impl IntoIterator for AuthNetworkAccount
Source§fn into_iter(self) -> <AuthNetworkAccount as IntoIterator>::IntoIter
fn into_iter(self) -> <AuthNetworkAccount as IntoIterator>::IntoIter
Expands the configuration into its AccountComponents: the auth component itself and all
fee policy components registered with the FeePolicyManager.
Source§type Item = AccountComponent
type Item = AccountComponent
Source§type IntoIter = IntoIter<AccountComponent>
type IntoIter = IntoIter<AccountComponent>
Auto Trait Implementations§
impl Freeze for AuthNetworkAccount
impl RefUnwindSafe for AuthNetworkAccount
impl Send for AuthNetworkAccount
impl Sync for AuthNetworkAccount
impl Unpin for AuthNetworkAccount
impl UnsafeUnpin for AuthNetworkAccount
impl UnwindSafe for AuthNetworkAccount
Blanket Implementations§
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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);