pub struct Client { /* private fields */ }Expand description
Client for AWS IoT Data Plane
Client for invoking operations on AWS IoT Data Plane. Each operation on AWS IoT Data Plane 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_iotdataplane::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_iotdataplane::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 DeleteConnection operation has
a Client::delete_connection, 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.delete_connection()
.client_id("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 delete_connection(&self) -> DeleteConnectionFluentBuilder
pub fn delete_connection(&self) -> DeleteConnectionFluentBuilder
Constructs a fluent builder for the DeleteConnection operation.
- The fluent builder is configurable:
client_id(impl Into<String>)/set_client_id(Option<String>):
required: trueThe unique identifier of the MQTT client to disconnect. The client ID can’t start with a dollar sign ($).
MQTT client IDs must be URL encoded (percent-encoded) when they contain characters that are not valid in HTTP requests, such as spaces, forward slashes (/), and UTF-8 characters.
clean_session(bool)/set_clean_session(Option<bool>):
required: falseSpecifies whether to remove the client’s persistent session state when disconnecting. Set to
TRUEto delete all session information, including subscriptions and queued messages. Set toFALSEto preserve the session state for persistent sessions. For clean sessions this parameter will be ignored. By default, this is set toFALSE(preserves the session state).prevent_will_message(bool)/set_prevent_will_message(Option<bool>):
required: falseControls if Amazon Web Services IoT Core publishes the client’s Last Will and Testament (LWT) message upon disconnection. Set to
TRUEto prevent publishing the LWT message. Set toFALSEto ensure that LWT is published. By default, this is set toFALSE(LWT message is published).
- On success, responds with
DeleteConnectionOutput - On failure, responds with
SdkError<DeleteConnectionError>
Source§impl Client
impl Client
Sourcepub fn delete_thing_shadow(&self) -> DeleteThingShadowFluentBuilder
pub fn delete_thing_shadow(&self) -> DeleteThingShadowFluentBuilder
Constructs a fluent builder for the DeleteThingShadow operation.
- The fluent builder is configurable:
thing_name(impl Into<String>)/set_thing_name(Option<String>):
required: trueThe name of the thing.
shadow_name(impl Into<String>)/set_shadow_name(Option<String>):
required: falseThe name of the shadow.
- On success, responds with
DeleteThingShadowOutputwith field(s):payload(Blob):The state information, in JSON format.
- On failure, responds with
SdkError<DeleteThingShadowError>
Source§impl Client
impl Client
Sourcepub fn get_connection(&self) -> GetConnectionFluentBuilder
pub fn get_connection(&self) -> GetConnectionFluentBuilder
Constructs a fluent builder for the GetConnection operation.
- The fluent builder is configurable:
client_id(impl Into<String>)/set_client_id(Option<String>):
required: trueThe unique identifier of the MQTT client to retrieve connection information. The client ID can’t start with a dollar sign ($).
MQTT client IDs must be URL encoded (percent-encoded) when they contain characters that are not valid in HTTP requests, such as spaces, forward slashes (/), and UTF-8 characters.
include_socket_information(bool)/set_include_socket_information(Option<bool>):
required: falseSpecifies if socket information (sourcePort, targetPort, sourceIp, targetIp) should be included in the GetConnection response. Set to
TRUEto include socket information. Set toFALSEto omit socket information. By default, this is set toFALSE. See the developer guide for how to authorize this parameter.
- On success, responds with
GetConnectionOutputwith field(s):connected(bool):The connection state of the client. Returns
trueif the client is currently connected, orfalseif the client is not connected.thing_name(Option<String>):The name of the thing associated with the principal of the MQTT client, if applicable.
clean_session(bool):Indicates whether the client is using a clean session. Returns
truefor clean sessions orfalsefor persistent sessions.source_ip(Option<String>):The IP address of the client that initiated the connection.
source_port(i32):The client’s source port.
target_ip(Option<String>):The IP address of the Amazon Web Services IoT Core endpoint that the client connected to. For clients connected to VPC endpoints, this is the private IP address of the network interface the client is connected to.
target_port(i32):The port number of the Amazon Web Services IoT Core endpoint that the client connected to.
keep_alive_duration(i32):The keep-alive interval in seconds that the client specified when establishing the connection.
connected_since(i64):Unix timestamp (in milliseconds) indicating when the client connected. Present only when connected is true.
disconnected_since(i64):Unix timestamp (in milliseconds) indicating when the client disconnected. Present only when connected is false. This information is available for 30 minutes after the client disconnects.
disconnect_reason(Option<String>):The reason for the last disconnection, if the client is currently disconnected. See the developer guide for valid disconnect reasons.
session_expiry(i64):The session expiry interval in seconds for the MQTT client connection. This is configured by the user. This value indicates how long the session will remain active after the client disconnects.
client_id(Option<String>):The unique identifier of the MQTT client. This is the same client ID that was used when the client established the connection.
vpc_endpoint_id(Option<String>):The ID of the VPC endpoint. Present for clients connected to IoT Core via a VPC endpoint.
- On failure, responds with
SdkError<GetConnectionError>
Source§impl Client
impl Client
Sourcepub fn get_retained_message(&self) -> GetRetainedMessageFluentBuilder
pub fn get_retained_message(&self) -> GetRetainedMessageFluentBuilder
Constructs a fluent builder for the GetRetainedMessage operation.
- The fluent builder is configurable:
topic(impl Into<String>)/set_topic(Option<String>):
required: trueThe topic name of the retained message to retrieve.
- On success, responds with
GetRetainedMessageOutputwith field(s):topic(Option<String>):The topic name to which the retained message was published.
payload(Option<Blob>):The Base64-encoded message payload of the retained message body.
qos(i32):The quality of service (QoS) level used to publish the retained message.
last_modified_time(i64):The Epoch date and time, in milliseconds, when the retained message was stored by IoT.
user_properties(Option<Blob>):A base64-encoded JSON string that includes an array of JSON objects, or null if the retained message doesn’t include any user properties.
The following example
userPropertiesparameter is a JSON string that represents two user properties. Note that it will be base64-encoded:[{“deviceName”: “alpha”}, {“deviceCnt”: “45”}]
- On failure, responds with
SdkError<GetRetainedMessageError>
Source§impl Client
impl Client
Sourcepub fn get_thing_shadow(&self) -> GetThingShadowFluentBuilder
pub fn get_thing_shadow(&self) -> GetThingShadowFluentBuilder
Constructs a fluent builder for the GetThingShadow operation.
- The fluent builder is configurable:
thing_name(impl Into<String>)/set_thing_name(Option<String>):
required: trueThe name of the thing.
shadow_name(impl Into<String>)/set_shadow_name(Option<String>):
required: falseThe name of the shadow.
- On success, responds with
GetThingShadowOutputwith field(s):payload(Option<Blob>):The state information, in JSON format.
- On failure, responds with
SdkError<GetThingShadowError>
Source§impl Client
impl Client
Sourcepub fn list_named_shadows_for_thing(
&self,
) -> ListNamedShadowsForThingFluentBuilder
pub fn list_named_shadows_for_thing( &self, ) -> ListNamedShadowsForThingFluentBuilder
Constructs a fluent builder for the ListNamedShadowsForThing operation.
- The fluent builder is configurable:
thing_name(impl Into<String>)/set_thing_name(Option<String>):
required: trueThe name of the thing.
next_token(impl Into<String>)/set_next_token(Option<String>):
required: falseThe token to retrieve the next set of results.
page_size(i32)/set_page_size(Option<i32>):
required: falseThe result page size.
- On success, responds with
ListNamedShadowsForThingOutputwith field(s):results(Option<Vec::<String>>):The list of shadows for the specified thing.
next_token(Option<String>):The token to use to get the next set of results, or null if there are no additional results.
timestamp(i64):The Epoch date and time the response was generated by IoT.
- On failure, responds with
SdkError<ListNamedShadowsForThingError>
Source§impl Client
impl Client
Sourcepub fn list_retained_messages(&self) -> ListRetainedMessagesFluentBuilder
pub fn list_retained_messages(&self) -> ListRetainedMessagesFluentBuilder
Constructs a fluent builder for the ListRetainedMessages operation.
This operation supports pagination; See into_paginator().
- The fluent builder is configurable:
next_token(impl Into<String>)/set_next_token(Option<String>):
required: falseTo retrieve the next set of results, the
nextTokenvalue from a previous response; otherwise null to receive the first set of results.max_results(i32)/set_max_results(Option<i32>):
required: falseThe maximum number of results to return at one time.
- On success, responds with
ListRetainedMessagesOutputwith field(s):retained_topics(Option<Vec::<RetainedMessageSummary>>):A summary list the account’s retained messages. The information returned doesn’t include the message payloads of the retained messages.
next_token(Option<String>):The token for the next set of results, or null if there are no additional results.
- On failure, responds with
SdkError<ListRetainedMessagesError>
Source§impl Client
impl Client
Sourcepub fn list_subscriptions(&self) -> ListSubscriptionsFluentBuilder
pub fn list_subscriptions(&self) -> ListSubscriptionsFluentBuilder
Constructs a fluent builder for the ListSubscriptions operation.
This operation supports pagination; See into_paginator().
- The fluent builder is configurable:
client_id(impl Into<String>)/set_client_id(Option<String>):
required: trueThe unique identifier of the MQTT client to list subscriptions for. The client ID can’t start with a dollar sign ($).
MQTT client IDs must be URL encoded (percent-encoded) when they contain characters that are not valid in HTTP requests, such as spaces, forward slashes (/), and UTF-8 characters.
next_token(impl Into<String>)/set_next_token(Option<String>):
required: falseTo retrieve the next set of results, the
nextTokenvalue from a previous response; otherwise null to receive the first set of results.max_results(i32)/set_max_results(Option<i32>):
required: falseThe maximum number of subscriptions to return in a single request. By default, this is set to 20.
- On success, responds with
ListSubscriptionsOutputwith field(s):subscriptions(Option<Vec::<SubscriptionSummary>>):A list of topic filters and their associated Quality of Service (QoS) levels that the client is subscribed to.
next_token(Option<String>):The token to use to get the next set of results, or null if there are no additional results.
- On failure, responds with
SdkError<ListSubscriptionsError>
Source§impl Client
impl Client
Sourcepub fn publish(&self) -> PublishFluentBuilder
pub fn publish(&self) -> PublishFluentBuilder
Constructs a fluent builder for the Publish operation.
- The fluent builder is configurable:
topic(impl Into<String>)/set_topic(Option<String>):
required: trueThe name of the MQTT topic.
qos(i32)/set_qos(Option<i32>):
required: falseThe Quality of Service (QoS) level. The default QoS level is 0.
retain(bool)/set_retain(Option<bool>):
required: falseA Boolean value that determines whether to set the RETAIN flag when the message is published.
Setting the RETAIN flag causes the message to be retained and sent to new subscribers to the topic.
Valid values:
true|falseDefault value:
falsepayload(Blob)/set_payload(Option<Blob>):
required: falseThe message body. MQTT accepts text, binary, and empty (null) message payloads.
Publishing an empty (null) payload with retain =
truedeletes the retained message identified by topic from Amazon Web Services IoT Core.user_properties(impl Into<String>)/set_user_properties(Option<String>):
required: falseA JSON string that contains an array of JSON objects. If you don’t use Amazon Web Services SDK or CLI, you must encode the JSON string to base64 format before adding it to the HTTP header.
userPropertiesis an HTTP header value in the API.The following example
userPropertiesparameter is a JSON string which represents two User Properties. Note that it needs to be base64-encoded:[{“deviceName”: “alpha”}, {“deviceCnt”: “45”}]payload_format_indicator(PayloadFormatIndicator)/set_payload_format_indicator(Option<PayloadFormatIndicator>):
required: falseAn
Enumstring value that indicates whether the payload is formatted as UTF-8.payloadFormatIndicatoris an HTTP header value in the API.content_type(impl Into<String>)/set_content_type(Option<String>):
required: falseA UTF-8 encoded string that describes the content of the publishing message.
response_topic(impl Into<String>)/set_response_topic(Option<String>):
required: falseA UTF-8 encoded string that’s used as the topic name for a response message. The response topic is used to describe the topic which the receiver should publish to as part of the request-response flow. The topic must not contain wildcard characters.
correlation_data(impl Into<String>)/set_correlation_data(Option<String>):
required: falseThe base64-encoded binary data used by the sender of the request message to identify which request the response message is for when it’s received.
correlationDatais an HTTP header value in the API.message_expiry(i64)/set_message_expiry(Option<i64>):
required: falseA user-defined integer value that represents the message expiry interval in seconds. If absent, the message doesn’t expire. For more information about the limits of
messageExpiry, see Amazon Web Services IoT Core message broker and protocol limits and quotas from the Amazon Web Services Reference Guide.
- On success, responds with
PublishOutput - On failure, responds with
SdkError<PublishError>
Source§impl Client
impl Client
Sourcepub fn send_direct_message(&self) -> SendDirectMessageFluentBuilder
pub fn send_direct_message(&self) -> SendDirectMessageFluentBuilder
Constructs a fluent builder for the SendDirectMessage operation.
- The fluent builder is configurable:
client_id(impl Into<String>)/set_client_id(Option<String>):
required: trueThe unique identifier of the MQTT client to send the message to.
Client IDs must not exceed 128 characters and can’t start with a dollar sign ($). MQTT client IDs must be URL encoded (percent-encoded) when they contain characters that are not valid in HTTP requests, such as spaces, forward slashes (/), and UTF-8 characters. For more information, see Amazon Web Services IoT Core message broker and protocol limits and quotas.
topic(impl Into<String>)/set_topic(Option<String>):
required: trueThe topic of the outbound MQTT Publish message to the receiving client. For more information, see Amazon Web Services IoT Core message broker and protocol limits and quotas.
content_type(impl Into<String>)/set_content_type(Option<String>):
required: falseThe MQTT5 content type property forwarded to the receiving client (for example,
application/json).response_topic(impl Into<String>)/set_response_topic(Option<String>):
required: falseA UTF-8 encoded string that’s used as the topic name for a response message. The response topic describes the topic which the receiver should publish to as part of the request-response flow. The topic must not contain wildcard characters. For more information, see Amazon Web Services IoT Core message broker and protocol limits and quotas.
confirmation(bool)/set_confirmation(Option<bool>):
required: falseA Boolean value that specifies whether to wait for delivery confirmation from the receiving client.
When set to
true, the API delivers the message at QoS 1 and waits for the client to send a delivery confirmation (PUBACK) before returning a successful response. If delivery confirmation is not received within the specifiedtimeoutperiod, the API returns HTTP 504.When set to
false, the API delivers the message at QoS 0 and returns after Amazon Web Services IoT Core attempts to deliver the message.Valid values:
true|falseDefault value:
falsetimeout(i32)/set_timeout(Option<i32>):
required: falseAn integer that represents the maximum time, in seconds, to wait for a delivery confirmation (PUBACK) from the receiving client after the message has been delivered. This parameter is only used when
confirmationis set totrue. Ifconfirmationisfalse, this parameter is ignored.The total API response time may be higher than this value due to internal processing. Set your HTTP client timeout to a value greater than this parameter.
Valid range: 1 to 15 seconds.
Default value:
5seconds.payload(Blob)/set_payload(Option<Blob>):
required: falseThe message body. MQTT accepts text, binary, and empty (null) message payloads.
user_properties(impl Into<String>)/set_user_properties(Option<String>):
required: falseA JSON string that contains an array of JSON objects. If you don’t use Amazon Web Services SDK or CLI, you must encode the JSON string to base64 format before adding it to the HTTP header.
userPropertiesis an HTTP header value in the API.For MQTT 3.1.1 clients, user properties are silently dropped.
The following example
userPropertiesparameter is a JSON string which represents two User Properties. Note that it needs to be base64-encoded:[{“deviceName”: “alpha”}, {“deviceCnt”: “45”}]payload_format_indicator(PayloadFormatIndicator)/set_payload_format_indicator(Option<PayloadFormatIndicator>):
required: falseAn
Enumstring value that indicates whether the payload is formatted as UTF-8.payloadFormatIndicatoris an HTTP header value in the API.correlation_data(impl Into<String>)/set_correlation_data(Option<String>):
required: falseThe base64-encoded binary data used by the sender of the request message to identify which request the response message is for when it’s received.
correlationDatais an HTTP header value in the API.
- On success, responds with
SendDirectMessageOutputwith field(s):message(Option<String>):The status message indicating the result of the operation.
trace_id(Option<String>):A unique identifier for the request. Include this value when contacting Amazon Web Services Support for troubleshooting.
- On failure, responds with
SdkError<SendDirectMessageError>
Source§impl Client
impl Client
Sourcepub fn update_thing_shadow(&self) -> UpdateThingShadowFluentBuilder
pub fn update_thing_shadow(&self) -> UpdateThingShadowFluentBuilder
Constructs a fluent builder for the UpdateThingShadow operation.
- The fluent builder is configurable:
thing_name(impl Into<String>)/set_thing_name(Option<String>):
required: trueThe name of the thing.
shadow_name(impl Into<String>)/set_shadow_name(Option<String>):
required: falseThe name of the shadow.
payload(Blob)/set_payload(Option<Blob>):
required: trueThe state information, in JSON format.
- On success, responds with
UpdateThingShadowOutputwith field(s):payload(Option<Blob>):The state information, in JSON format.
- On failure, responds with
SdkError<UpdateThingShadowError>
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 !RefUnwindSafe for Client
impl !UnwindSafe for Client
impl Freeze for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin 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
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<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>
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);