pub struct Client { /* private fields */ }Expand description
Client for CloudWatch Observability Access Manager
Client for invoking operations on CloudWatch Observability Access Manager. Each operation on CloudWatch Observability Access Manager is a method on this
this struct. .send() MUST be invoked on the generated operations to dispatch the request to the service.
§Constructing a Client
A Config is required to construct a client. For most use cases, the aws-config
crate should be used to automatically resolve this config using
aws_config::load_from_env(), since this will resolve an SdkConfig which can be shared
across multiple different AWS SDK clients. This config resolution process can be customized
by calling aws_config::from_env() instead, which returns a ConfigLoader that uses
the builder pattern to customize the default config.
In the simplest case, creating a client looks as follows:
let config = aws_config::load_from_env().await;
let client = aws_sdk_oam::Client::new(&config);Occasionally, SDKs may have additional service-specific values that can be set on the Config that
is absent from SdkConfig, or slightly different settings for a specific client may be desired.
The Builder struct implements From<&SdkConfig>, so setting these specific settings can be
done as follows:
let sdk_config = ::aws_config::load_from_env().await;
let config = aws_sdk_oam::config::Builder::from(&sdk_config)
.some_service_specific_setting("value")
.build();See the aws-config docs and Config for more information on customizing configuration.
Note: Client construction is expensive due to connection thread pool initialization, and should be done once at application start-up.
§Using the Client
A client has a function for every operation that can be performed by the service.
For example, the CreateLink operation has
a Client::create_link, function which returns a builder for that operation.
The fluent builder ultimately has a send() function that returns an async future that
returns a result, as illustrated below:
let result = client.create_link()
.label_template("example")
.send()
.await;The underlying HTTP requests that get made by this can be modified with the customize_operation
function on the fluent builder. See the customize module for more
information.
Implementations§
Source§impl Client
impl Client
Sourcepub fn create_link(&self) -> CreateLinkFluentBuilder
pub fn create_link(&self) -> CreateLinkFluentBuilder
Constructs a fluent builder for the CreateLink operation.
- The fluent builder is configurable:
label_template(impl Into<String>)/set_label_template(Option<String>):
required: trueSpecify a friendly human-readable name to use to identify this source account when you are viewing data from it in the monitoring account.
You can use a custom label or use the following variables:
-
$AccountNameis the name of the account -
$AccountEmailis the globally unique email address of the account -
$AccountEmailNoDomainis the email address of the account without the domain name
In the Amazon Web Services GovCloud (US-East) and Amazon Web Services GovCloud (US-West) Regions, the only supported option is to use custom labels, and the
$AccountName,$AccountEmail, and$AccountEmailNoDomainvariables all resolve as account-id instead of the specified variable.-
resource_types(ResourceType)/set_resource_types(Option<Vec::<ResourceType>>):
required: trueAn array of strings that define which types of data that the source account shares with the monitoring account.
sink_identifier(impl Into<String>)/set_sink_identifier(Option<String>):
required: trueThe ARN of the sink to use to create this link. You can use ListSinks to find the ARNs of sinks.
For more information about sinks, see CreateSink.
tags(impl Into<String>, impl Into<String>)/set_tags(Option<HashMap::<String, String>>):
required: falseAssigns one or more tags (key-value pairs) to the link.
Tags can help you organize and categorize your resources. You can also use them to scope user permissions by granting a user permission to access or change only resources with certain tag values.
For more information about using tags to control access, see Controlling access to Amazon Web Services resources using tags.
link_configuration(LinkConfiguration)/set_link_configuration(Option<LinkConfiguration>):
required: falseUse this structure to optionally create filters that specify that only some metric namespaces or log groups are to be shared from the source account to the monitoring account.
- On success, responds with
CreateLinkOutputwith field(s):arn(Option<String>):The ARN of the link that is newly created.
id(Option<String>):The random ID string that Amazon Web Services generated as part of the link ARN.
label(Option<String>):The label that you assigned to this link. If the
labelTemplateincludes variables, this field displays the variables resolved to their actual values.label_template(Option<String>):The exact label template that you specified, with the variables not resolved.
resource_types(Option<Vec::<String>>):The resource types supported by this link.
sink_arn(Option<String>):The ARN of the sink that is used for this link.
tags(Option<HashMap::<String, String>>):The tags assigned to the link.
link_configuration(Option<LinkConfiguration>):This structure includes filters that specify which metric namespaces and which log groups are shared from the source account to the monitoring account.
- On failure, responds with
SdkError<CreateLinkError>
Source§impl Client
impl Client
Sourcepub fn create_sink(&self) -> CreateSinkFluentBuilder
pub fn create_sink(&self) -> CreateSinkFluentBuilder
Constructs a fluent builder for the CreateSink operation.
- The fluent builder is configurable:
name(impl Into<String>)/set_name(Option<String>):
required: trueA name for the sink.
tags(impl Into<String>, impl Into<String>)/set_tags(Option<HashMap::<String, String>>):
required: falseAssigns one or more tags (key-value pairs) to the link.
Tags can help you organize and categorize your resources. You can also use them to scope user permissions by granting a user permission to access or change only resources with certain tag values.
For more information about using tags to control access, see Controlling access to Amazon Web Services resources using tags.
- On success, responds with
CreateSinkOutputwith field(s):arn(Option<String>):The ARN of the sink that is newly created.
id(Option<String>):The random ID string that Amazon Web Services generated as part of the sink ARN.
name(Option<String>):The name of the sink.
tags(Option<HashMap::<String, String>>):The tags assigned to the sink.
- On failure, responds with
SdkError<CreateSinkError>
Source§impl Client
impl Client
Sourcepub fn delete_link(&self) -> DeleteLinkFluentBuilder
pub fn delete_link(&self) -> DeleteLinkFluentBuilder
Constructs a fluent builder for the DeleteLink operation.
- The fluent builder is configurable:
identifier(impl Into<String>)/set_identifier(Option<String>):
required: trueThe ARN of the link to delete.
- On success, responds with
DeleteLinkOutput - On failure, responds with
SdkError<DeleteLinkError>
Source§impl Client
impl Client
Sourcepub fn delete_sink(&self) -> DeleteSinkFluentBuilder
pub fn delete_sink(&self) -> DeleteSinkFluentBuilder
Constructs a fluent builder for the DeleteSink operation.
- The fluent builder is configurable:
identifier(impl Into<String>)/set_identifier(Option<String>):
required: trueThe ARN of the sink to delete.
- On success, responds with
DeleteSinkOutput - On failure, responds with
SdkError<DeleteSinkError>
Source§impl Client
impl Client
Sourcepub fn get_link(&self) -> GetLinkFluentBuilder
pub fn get_link(&self) -> GetLinkFluentBuilder
Constructs a fluent builder for the GetLink operation.
- The fluent builder is configurable:
identifier(impl Into<String>)/set_identifier(Option<String>):
required: trueThe ARN of the link to retrieve information for.
include_tags(bool)/set_include_tags(Option<bool>):
required: falseSpecifies whether to include the tags associated with the link in the response. When
IncludeTagsis set totrueand the caller has the required permission,oam:ListTagsForResource, the API will return the tags for the specified resource. If the caller doesn’t have the required permission,oam:ListTagsForResource, the API will raise an exception.The default value is
false.
- On success, responds with
GetLinkOutputwith field(s):arn(Option<String>):The ARN of the link.
id(Option<String>):The random ID string that Amazon Web Services generated as part of the link ARN.
label(Option<String>):The label that you assigned to this link, with the variables resolved to their actual values.
label_template(Option<String>):The exact label template that was specified when the link was created, with the template variables not resolved.
resource_types(Option<Vec::<String>>):The resource types supported by this link.
sink_arn(Option<String>):The ARN of the sink that is used for this link.
tags(Option<HashMap::<String, String>>):The tags assigned to the link.
link_configuration(Option<LinkConfiguration>):This structure includes filters that specify which metric namespaces and which log groups are shared from the source account to the monitoring account.
- On failure, responds with
SdkError<GetLinkError>
Source§impl Client
impl Client
Sourcepub fn get_sink(&self) -> GetSinkFluentBuilder
pub fn get_sink(&self) -> GetSinkFluentBuilder
Constructs a fluent builder for the GetSink operation.
- The fluent builder is configurable:
identifier(impl Into<String>)/set_identifier(Option<String>):
required: trueThe ARN of the sink to retrieve information for.
include_tags(bool)/set_include_tags(Option<bool>):
required: falseSpecifies whether to include the tags associated with the sink in the response. When
IncludeTagsis set totrueand the caller has the required permission,oam:ListTagsForResource, the API will return the tags for the specified resource. If the caller doesn’t have the required permission,oam:ListTagsForResource, the API will raise an exception.The default value is
false.
- On success, responds with
GetSinkOutputwith field(s):arn(Option<String>):The ARN of the sink.
id(Option<String>):The random ID string that Amazon Web Services generated as part of the sink ARN.
name(Option<String>):The name of the sink.
tags(Option<HashMap::<String, String>>):The tags assigned to the sink.
- On failure, responds with
SdkError<GetSinkError>
Source§impl Client
impl Client
Sourcepub fn get_sink_policy(&self) -> GetSinkPolicyFluentBuilder
pub fn get_sink_policy(&self) -> GetSinkPolicyFluentBuilder
Constructs a fluent builder for the GetSinkPolicy operation.
- The fluent builder is configurable:
sink_identifier(impl Into<String>)/set_sink_identifier(Option<String>):
required: trueThe ARN of the sink to retrieve the policy of.
- On success, responds with
GetSinkPolicyOutputwith field(s):sink_arn(Option<String>):The ARN of the sink.
sink_id(Option<String>):The random ID string that Amazon Web Services generated as part of the sink ARN.
policy(Option<String>):The policy that you specified, in JSON format.
- On failure, responds with
SdkError<GetSinkPolicyError>
Source§impl Client
impl Client
Sourcepub fn list_attached_links(&self) -> ListAttachedLinksFluentBuilder
pub fn list_attached_links(&self) -> ListAttachedLinksFluentBuilder
Constructs a fluent builder for the ListAttachedLinks operation.
This operation supports pagination; See into_paginator().
- The fluent builder is configurable:
max_results(i32)/set_max_results(Option<i32>):
required: falseLimits the number of returned links to the specified number.
next_token(impl Into<String>)/set_next_token(Option<String>):
required: falseThe token for the next set of items to return. You received this token from a previous call.
sink_identifier(impl Into<String>)/set_sink_identifier(Option<String>):
required: trueThe ARN of the sink that you want to retrieve links for.
- On success, responds with
ListAttachedLinksOutputwith field(s):items(Vec::<ListAttachedLinksItem>):An array of structures that contain the information about the attached links.
next_token(Option<String>):The token to use when requesting the next set of links.
- On failure, responds with
SdkError<ListAttachedLinksError>
Source§impl Client
impl Client
Sourcepub fn list_links(&self) -> ListLinksFluentBuilder
pub fn list_links(&self) -> ListLinksFluentBuilder
Constructs a fluent builder for the ListLinks operation.
This operation supports pagination; See into_paginator().
- The fluent builder is configurable:
max_results(i32)/set_max_results(Option<i32>):
required: falseLimits the number of returned links to the specified number.
next_token(impl Into<String>)/set_next_token(Option<String>):
required: falseThe token for the next set of items to return. You received this token from a previous call.
- On success, responds with
ListLinksOutputwith field(s):items(Vec::<ListLinksItem>):An array of structures that contain the information about the returned links.
next_token(Option<String>):The token to use when requesting the next set of links.
- On failure, responds with
SdkError<ListLinksError>
Source§impl Client
impl Client
Sourcepub fn list_sinks(&self) -> ListSinksFluentBuilder
pub fn list_sinks(&self) -> ListSinksFluentBuilder
Constructs a fluent builder for the ListSinks operation.
This operation supports pagination; See into_paginator().
- The fluent builder is configurable:
max_results(i32)/set_max_results(Option<i32>):
required: falseLimits the number of returned links to the specified number.
next_token(impl Into<String>)/set_next_token(Option<String>):
required: falseThe token for the next set of items to return. You received this token from a previous call.
- On success, responds with
ListSinksOutputwith field(s):items(Vec::<ListSinksItem>):An array of structures that contain the information about the returned sinks.
next_token(Option<String>):The token to use when requesting the next set of sinks.
- On failure, responds with
SdkError<ListSinksError>
Source§impl Client
impl Client
Constructs a fluent builder for the ListTagsForResource operation.
- The fluent builder is configurable:
resource_arn(impl Into<String>)/set_resource_arn(Option<String>):
required: trueThe ARN of the resource that you want to view tags for.
The ARN format of a sink is
arn:aws:oam:Region:account-id:sink/sink-idThe ARN format of a link is
arn:aws:oam:Region:account-id:link/link-idFor more information about ARN format, see CloudWatch Logs resources and operations.
Unlike tagging permissions in other Amazon Web Services services, to retrieve the list of tags for links or sinks you must have the
oam:RequestTagpermission. Theaws:ReguestTagpermission does not allow you to tag and untag links and sinks.
- On success, responds with
ListTagsForResourceOutputwith field(s):tags(Option<HashMap::<String, String>>):The list of tags associated with the requested resource.>
- On failure, responds with
SdkError<ListTagsForResourceError>
Source§impl Client
impl Client
Sourcepub fn put_sink_policy(&self) -> PutSinkPolicyFluentBuilder
pub fn put_sink_policy(&self) -> PutSinkPolicyFluentBuilder
Constructs a fluent builder for the PutSinkPolicy operation.
- The fluent builder is configurable:
sink_identifier(impl Into<String>)/set_sink_identifier(Option<String>):
required: trueThe ARN of the sink to attach this policy to.
policy(impl Into<String>)/set_policy(Option<String>):
required: trueThe JSON policy to use. If you are updating an existing policy, the entire existing policy is replaced by what you specify here.
The policy must be in JSON string format with quotation marks escaped and no newlines.
For examples of different types of policies, see the Examples section on this page.
- On success, responds with
PutSinkPolicyOutputwith field(s):sink_arn(Option<String>):The ARN of the sink.
sink_id(Option<String>):The random ID string that Amazon Web Services generated as part of the sink ARN.
policy(Option<String>):The policy that you specified.
- On failure, responds with
SdkError<PutSinkPolicyError>
Source§impl Client
impl Client
Sourcepub fn tag_resource(&self) -> TagResourceFluentBuilder
pub fn tag_resource(&self) -> TagResourceFluentBuilder
Constructs a fluent builder for the TagResource operation.
- The fluent builder is configurable:
resource_arn(impl Into<String>)/set_resource_arn(Option<String>):
required: trueThe ARN of the resource that you’re adding tags to.
The ARN format of a sink is
arn:aws:oam:Region:account-id:sink/sink-idThe ARN format of a link is
arn:aws:oam:Region:account-id:link/link-idFor more information about ARN format, see CloudWatch Logs resources and operations.
tags(impl Into<String>, impl Into<String>)/set_tags(Option<HashMap::<String, String>>):
required: trueThe list of key-value pairs to associate with the resource.
- On success, responds with
TagResourceOutput - On failure, responds with
SdkError<TagResourceError>
Source§impl Client
impl Client
Sourcepub fn untag_resource(&self) -> UntagResourceFluentBuilder
pub fn untag_resource(&self) -> UntagResourceFluentBuilder
Constructs a fluent builder for the UntagResource operation.
- The fluent builder is configurable:
resource_arn(impl Into<String>)/set_resource_arn(Option<String>):
required: trueThe ARN of the resource that you’re removing tags from.
The ARN format of a sink is
arn:aws:oam:Region:account-id:sink/sink-idThe ARN format of a link is
arn:aws:oam:Region:account-id:link/link-idFor more information about ARN format, see CloudWatch Logs resources and operations.
tag_keys(impl Into<String>)/set_tag_keys(Option<Vec::<String>>):
required: trueThe list of tag keys to remove from the resource.
- On success, responds with
UntagResourceOutput - On failure, responds with
SdkError<UntagResourceError>
Source§impl Client
impl Client
Sourcepub fn update_link(&self) -> UpdateLinkFluentBuilder
pub fn update_link(&self) -> UpdateLinkFluentBuilder
Constructs a fluent builder for the UpdateLink operation.
- The fluent builder is configurable:
identifier(impl Into<String>)/set_identifier(Option<String>):
required: trueThe ARN of the link that you want to update.
resource_types(ResourceType)/set_resource_types(Option<Vec::<ResourceType>>):
required: trueAn array of strings that define which types of data that the source account will send to the monitoring account.
Your input here replaces the current set of data types that are shared.
link_configuration(LinkConfiguration)/set_link_configuration(Option<LinkConfiguration>):
required: falseUse this structure to filter which metric namespaces and which log groups are to be shared from the source account to the monitoring account.
include_tags(bool)/set_include_tags(Option<bool>):
required: falseSpecifies whether to include the tags associated with the link in the response after the update operation. When
IncludeTagsis set totrueand the caller has the required permission,oam:ListTagsForResource, the API will return the tags for the specified resource. If the caller doesn’t have the required permission,oam:ListTagsForResource, the API will raise an exception.The default value is
false.
- On success, responds with
UpdateLinkOutputwith field(s):arn(Option<String>):The ARN of the link that you have updated.
id(Option<String>):The random ID string that Amazon Web Services generated as part of the sink ARN.
label(Option<String>):The label assigned to this link, with the variables resolved to their actual values.
label_template(Option<String>):The exact label template that was specified when the link was created, with the template variables not resolved.
resource_types(Option<Vec::<String>>):The resource types now supported by this link.
sink_arn(Option<String>):The ARN of the sink that is used for this link.
tags(Option<HashMap::<String, String>>):The tags assigned to the link.
link_configuration(Option<LinkConfiguration>):This structure includes filters that specify which metric namespaces and which log groups are shared from the source account to the monitoring account.
- On failure, responds with
SdkError<UpdateLinkError>
Source§impl Client
impl Client
Sourcepub fn from_conf(conf: Config) -> Self
pub fn from_conf(conf: Config) -> Self
Creates a new client from the service Config.
§Panics
This method will panic in the following cases:
- Retries or timeouts are enabled without a
sleep_implconfigured. - Identity caching is enabled without a
sleep_implandtime_sourceconfigured. - No
behavior_versionis provided.
The panic message for each of these will have instructions on how to resolve them.
Source§impl Client
impl Client
Sourcepub fn new(sdk_config: &SdkConfig) -> Self
pub fn new(sdk_config: &SdkConfig) -> Self
Creates a new client from an SDK Config.
§Panics
- This method will panic if the
sdk_configis missing an async sleep implementation. If you experience this panic, set thesleep_implon the Config passed into this function to fix it. - This method will panic if the
sdk_configis missing an HTTP connector. If you experience this panic, set thehttp_connectoron the Config passed into this function to fix it. - This method will panic if no
BehaviorVersionis provided. If you experience this panic, setbehavior_versionon the Config or enable thebehavior-version-latestCargo feature.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> 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>
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);