pub struct RoleBasedAccessControl { /* private fields */ }Expand description
Role-based access control (RBAC) for account components.
Instead of having one account holding every privilege, privileges are split into named
roles (for example MINTER, BURNER, PAUSER), and each procedure is guarded against
the caller’s role membership. It allows role assignment with domain isolation to minimize
the scope of damage from a compromised role.
§Security considerations
Access control is based on the note sender (the account ID that created the note), which
authenticates which account created a note but not the code that executed when it was
created. It is meaningful only when every account registered as a role member enforces
strong authentication. Registering a permissionless account (for example one using no_auth)
as a role member provides no access restriction: anyone can make such an account emit a
note with an arbitrary script root and that account’s ID as sender, defeating the sender check.
§Administration model
Role administration is fully role-based. Every role has an effective admin role:
its configured delegated admin when set, otherwise the built-in
ADMIN role. Only members of a role’s effective admin role may grant,
revoke, or re-point (set_role_admin) that role.
A component defined any role is configured with a live administration path for it (see
builder), which for a role left with the default admin means members of the
ADMIN role. The ADMIN role administers itself, so ADMIN membership can be granted,
revoked, and renounced through the standard API.
§Role hierarchy and exclusive delegation
Every role may have its admin delegated to another role via set_role_admin. Accounts
holding a role’s admin role are authorized to grant and revoke that role. For example,
accounts holding MINTER_ADMIN can manage the MINTER role but have no authority over
BURNER or PAUSER.
Delegation is exclusive: once a role’s admin is delegated to another role, the ADMIN
role loses all authority over it (grant, revoke, and further set_role_admin are then
gated on the delegated admin). This lets a sensitive role — say a token issuer — be placed
exclusively under a dedicated admin role and kept out of reach of the general
administrator. To hand authority back, the current delegated admin re-points the role
(passing 0 reverts it to the ADMIN role).
Both members and delegated admins can be configured at construction (see RoleConfig), which
establishes exclusive delegation atomically: a role configured with a delegated admin is never
reachable by ADMIN, not even transiently. Reaching the same configuration on an existing
account requires the sequence below, during which ADMIN still administers the role. That
window is also the only chance to repair a mistyped or hostile admin role, so a configured
delegation must be verified before account creation: initialization proves that some role can
administer the delegated role, never that the deployer controls it.
This supports a fully decentralized configuration: for each delegated role, (1) grant the
dedicated admin role’s members, (2) make it self-administering (set_role_admin(X, X) —
only safe once X has members), (3) delegate the managed role to it, and (4) revoke or
renounce all bootstrap ADMIN members, waiting for each step to commit before issuing
the next. Emptying ADMIN is permanent and forfeits every ADMIN-defaulted capability
(the Authority procedure→role map is fixed at account creation), so an account whose
gated procedures are not all mapped to live roles must never empty ADMIN. A
self-administering role has no quorum — any single member can evict the rest — so its
members should themselves be strongly authenticated (e.g. multisig) accounts.
The delegated admin of a role can itself be any role, including one that it admins.
Circular relationships are possible but should be designed with care, since each role
can then revoke the other. Only delegate to a role that already has members, and treat
emptying a role’s effective admin like ownership renouncement: the role stays
unmanageable until its effective admin is repopulated — for a self-administering role
(including ADMIN), never.
§Role semantics
A role is considered to exist when it has at least one member. Granting the first
member creates the role; revoking the last member removes it. As a consequence,
set_role_admin(A, B) stores the admin relationship in storage but does not make role
A exist until a member is granted. Once the last member of A is revoked,
get_role_member_count(A) returns 0, though the admin configuration is retained and
will apply the next time a member is granted.
§Membership lookup
has_role procedure is the primary guard used by procedures that assert the caller’s
role membership. get_role_member_count returns the number of accounts holding a role.
§Role symbol format
A RoleSymbol encodes up to 12 uppercase ASCII characters with underscores into a
single field element using the same packing as the token symbol type. Examples:
MINTER, MINTER_ADMIN, PAUSER. The zero field element is reserved and cannot be
used as a role symbol; attempting to do so panics with ERR_ROLE_SYMBOL_ZERO.
§Usage
Guarding a procedure in MASM so that only members of MINTER can call it:
pub proc mint
push.MINTER_ROLE_SYMBOL
exec.::miden::standards::access::rbac::assert_sender_has_role
# add mint logic
endImplementations§
Source§impl RoleBasedAccessControl
impl RoleBasedAccessControl
Sourcepub fn builder() -> RoleBasedAccessControlBuilder
pub fn builder() -> RoleBasedAccessControlBuilder
Returns an RBAC component initialized with the given roles, each carrying its members and
its delegated admin (see RoleConfig).
Roles are added with the role and
roles setters. Initializing no role at all is
allowed and produces a component with no roles and no administrator.
§Errors
Returns an error if:
- the same role is specified more than once.
- a role is configured with neither members nor a delegated admin.
- a role’s member count exceeds
u32::MAX. - a role’s effective admin — its delegated admin, or
ADMINwhen unset — can never hold members, which would leave the role permanently unmanageable. Setting an operational role without definingADMINis the common case:ADMINadministers itself, so nothing can ever populate it.
Source§impl RoleBasedAccessControl
impl RoleBasedAccessControl
Sourcepub const ADMIN_ROLE: &'static str = "ADMIN"
pub const ADMIN_ROLE: &'static str = "ADMIN"
The built-in default admin role symbol. A role whose delegated admin is unset is administered by members of this role.
Keep in sync with the ADMIN_ROLE constant in asm/standards/access/rbac.masm.
Sourcepub fn with_admins(
admins: impl IntoIterator<Item = AccountId>,
) -> Result<RoleBasedAccessControl, RoleBasedAccessControlError>
pub fn with_admins( admins: impl IntoIterator<Item = AccountId>, ) -> Result<RoleBasedAccessControl, RoleBasedAccessControlError>
Sourcepub fn admin_role() -> RoleSymbol
pub fn admin_role() -> RoleSymbol
Returns the built-in default admin RoleSymbol.
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 role_config_slot() -> &'static StorageSlotName
pub fn role_config_slot() -> &'static StorageSlotName
Returns the storage slot name for the per-role config map.
Sourcepub fn role_membership_slot() -> &'static StorageSlotName
pub fn role_membership_slot() -> &'static StorageSlotName
Returns the storage slot name for the per-role membership map.
Sourcepub fn role_config_slot_schema() -> (StorageSlotName, StorageSlotSchema)
pub fn role_config_slot_schema() -> (StorageSlotName, StorageSlotSchema)
Returns the schema entry for the per-role config map.
Sourcepub fn role_membership_slot_schema() -> (StorageSlotName, StorageSlotSchema)
pub fn role_membership_slot_schema() -> (StorageSlotName, StorageSlotSchema)
Returns the schema entry for the per-role membership map.
Sourcepub fn component_metadata() -> AccountComponentMetadata
pub fn component_metadata() -> AccountComponentMetadata
Returns the AccountComponentMetadata describing this component.
Trait Implementations§
Source§impl Clone for RoleBasedAccessControl
impl Clone for RoleBasedAccessControl
Source§fn clone(&self) -> RoleBasedAccessControl
fn clone(&self) -> RoleBasedAccessControl
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RoleBasedAccessControl
impl Debug for RoleBasedAccessControl
impl Eq for RoleBasedAccessControl
Source§impl From<RoleBasedAccessControl> for AccountComponent
impl From<RoleBasedAccessControl> for AccountComponent
Source§fn from(rbac: RoleBasedAccessControl) -> AccountComponent
fn from(rbac: RoleBasedAccessControl) -> AccountComponent
Source§impl PartialEq for RoleBasedAccessControl
impl PartialEq for RoleBasedAccessControl
impl StructuralPartialEq for RoleBasedAccessControl
Auto Trait Implementations§
impl Freeze for RoleBasedAccessControl
impl RefUnwindSafe for RoleBasedAccessControl
impl Send for RoleBasedAccessControl
impl Sync for RoleBasedAccessControl
impl Unpin for RoleBasedAccessControl
impl UnsafeUnpin for RoleBasedAccessControl
impl UnwindSafe for RoleBasedAccessControl
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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);