pub struct Client { /* private fields */ }Expand description
Client for Agents for Amazon Bedrock Runtime
Client for invoking operations on Agents for Amazon Bedrock Runtime. Each operation on Agents for Amazon Bedrock Runtime 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_bedrockagentruntime::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_bedrockagentruntime::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.
Implementations§
Source§impl Client
impl Client
Sourcepub fn delete_agent_memory(&self) -> DeleteAgentMemoryFluentBuilder
pub fn delete_agent_memory(&self) -> DeleteAgentMemoryFluentBuilder
Constructs a fluent builder for the DeleteAgentMemory operation.
- The fluent builder is configurable:
agent_id(impl Into<String>)/set_agent_id(Option<String>):
required: trueThe unique identifier of the agent to which the alias belongs.
agent_alias_id(impl Into<String>)/set_agent_alias_id(Option<String>):
required: trueThe unique identifier of an alias of an agent.
memory_id(impl Into<String>)/set_memory_id(Option<String>):
required: falseThe unique identifier of the memory.
session_id(impl Into<String>)/set_session_id(Option<String>):
required: falseThe unique session identifier of the memory.
- On success, responds with
DeleteAgentMemoryOutput - On failure, responds with
SdkError<DeleteAgentMemoryError>
Source§impl Client
impl Client
Sourcepub fn generate_query(&self) -> GenerateQueryFluentBuilder
pub fn generate_query(&self) -> GenerateQueryFluentBuilder
Constructs a fluent builder for the GenerateQuery operation.
- The fluent builder is configurable:
query_generation_input(QueryGenerationInput)/set_query_generation_input(Option<QueryGenerationInput>):
required: trueSpecifies information about a natural language query to transform into SQL.
transformation_configuration(TransformationConfiguration)/set_transformation_configuration(Option<TransformationConfiguration>):
required: trueSpecifies configurations for transforming the natural language query into SQL.
- On success, responds with
GenerateQueryOutputwith field(s):queries(Option<Vec::<GeneratedQuery>>):A list of objects, each of which defines a generated query that can correspond to the natural language queries.
- On failure, responds with
SdkError<GenerateQueryError>
Source§impl Client
impl Client
Sourcepub fn get_agent_memory(&self) -> GetAgentMemoryFluentBuilder
pub fn get_agent_memory(&self) -> GetAgentMemoryFluentBuilder
Constructs a fluent builder for the GetAgentMemory operation.
This operation supports pagination; See into_paginator().
- The fluent builder is configurable:
next_token(impl Into<String>)/set_next_token(Option<String>):
required: falseIf the total number of results is greater than the maxItems value provided in the request, enter the token returned in the
nextTokenfield in the response in this field to return the next batch of results.max_items(i32)/set_max_items(Option<i32>):
required: falseThe maximum number of items to return in the response. If the total number of results is greater than this value, use the token returned in the response in the
nextTokenfield when making another request to return the next batch of results.agent_id(impl Into<String>)/set_agent_id(Option<String>):
required: trueThe unique identifier of the agent to which the alias belongs.
agent_alias_id(impl Into<String>)/set_agent_alias_id(Option<String>):
required: trueThe unique identifier of an alias of an agent.
memory_type(MemoryType)/set_memory_type(Option<MemoryType>):
required: trueThe type of memory.
memory_id(impl Into<String>)/set_memory_id(Option<String>):
required: trueThe unique identifier of the memory.
- On success, responds with
GetAgentMemoryOutputwith field(s):next_token(Option<String>):If the total number of results is greater than the maxItems value provided in the request, use this token when making another request in the
nextTokenfield to return the next batch of results.memory_contents(Option<Vec::<Memory>>):Contains details of the sessions stored in the memory
- On failure, responds with
SdkError<GetAgentMemoryError>
Source§impl Client
impl Client
Sourcepub fn invoke_agent(&self) -> InvokeAgentFluentBuilder
pub fn invoke_agent(&self) -> InvokeAgentFluentBuilder
Constructs a fluent builder for the InvokeAgent operation.
- The fluent builder is configurable:
session_state(SessionState)/set_session_state(Option<SessionState>):
required: falseContains parameters that specify various attributes of the session. For more information, see Control session context.
If you include
returnControlInvocationResultsin thesessionStatefield, theinputTextfield will be ignored.agent_id(impl Into<String>)/set_agent_id(Option<String>):
required: trueThe unique identifier of the agent to use.
agent_alias_id(impl Into<String>)/set_agent_alias_id(Option<String>):
required: trueThe alias of the agent to use.
session_id(impl Into<String>)/set_session_id(Option<String>):
required: trueThe unique identifier of the session. Use the same value across requests to continue the same conversation.
end_session(bool)/set_end_session(Option<bool>):
required: falseSpecifies whether to end the session with the agent or not.
enable_trace(bool)/set_enable_trace(Option<bool>):
required: falseSpecifies whether to turn on the trace or not to track the agent’s reasoning process. For more information, see Trace enablement.
input_text(impl Into<String>)/set_input_text(Option<String>):
required: falseThe prompt text to send the agent.
If you include
returnControlInvocationResultsin thesessionStatefield, theinputTextfield will be ignored.memory_id(impl Into<String>)/set_memory_id(Option<String>):
required: falseThe unique identifier of the agent memory.
bedrock_model_configurations(BedrockModelConfigurations)/set_bedrock_model_configurations(Option<BedrockModelConfigurations>):
required: falseModel performance settings for the request.
streaming_configurations(StreamingConfigurations)/set_streaming_configurations(Option<StreamingConfigurations>):
required: falseSpecifies the configurations for streaming.
To use agent streaming, you need permissions to perform the
bedrock:InvokeModelWithResponseStreamaction.source_arn(impl Into<String>)/set_source_arn(Option<String>):
required: falseThe ARN of the resource making the request.
- On success, responds with
InvokeAgentOutputwith field(s):completion(EventReceiver<ResponseStream, ResponseStreamError>):The agent’s response to the user prompt.
content_type(String):The MIME type of the input data in the request. The default value is
application/json.session_id(String):The unique identifier of the session with the agent.
memory_id(Option<String>):The unique identifier of the agent memory.
- On failure, responds with
SdkError<InvokeAgentError>
Source§impl Client
impl Client
Sourcepub fn invoke_flow(&self) -> InvokeFlowFluentBuilder
pub fn invoke_flow(&self) -> InvokeFlowFluentBuilder
Constructs a fluent builder for the InvokeFlow operation.
- The fluent builder is configurable:
flow_identifier(impl Into<String>)/set_flow_identifier(Option<String>):
required: trueThe unique identifier of the flow.
flow_alias_identifier(impl Into<String>)/set_flow_alias_identifier(Option<String>):
required: trueThe unique identifier of the flow alias.
inputs(FlowInput)/set_inputs(Option<Vec::<FlowInput>>):
required: trueA list of objects, each containing information about an input into the flow.
enable_trace(bool)/set_enable_trace(Option<bool>):
required: falseSpecifies whether to return the trace for the flow or not. Traces track inputs and outputs for nodes in the flow. For more information, see Track each step in your prompt flow by viewing its trace in Amazon Bedrock.
model_performance_configuration(ModelPerformanceConfiguration)/set_model_performance_configuration(Option<ModelPerformanceConfiguration>):
required: falseModel performance settings for the request.
execution_id(impl Into<String>)/set_execution_id(Option<String>):
required: falseThe unique identifier for the current flow execution. If you don’t provide a value, Amazon Bedrock creates the identifier for you.
- On success, responds with
InvokeFlowOutputwith field(s):response_stream(EventReceiver<FlowResponseStream, FlowResponseStreamError>):The output of the flow, returned as a stream. If there’s an error, the error is returned.
execution_id(Option<String>):The unique identifier for the current flow execution.
- On failure, responds with
SdkError<InvokeFlowError>
Source§impl Client
impl Client
Sourcepub fn invoke_inline_agent(&self) -> InvokeInlineAgentFluentBuilder
pub fn invoke_inline_agent(&self) -> InvokeInlineAgentFluentBuilder
Constructs a fluent builder for the InvokeInlineAgent operation.
- The fluent builder is configurable:
session_id(impl Into<String>)/set_session_id(Option<String>):
required: trueThe unique identifier of the session. Use the same value across requests to continue the same conversation.
customer_encryption_key_arn(impl Into<String>)/set_customer_encryption_key_arn(Option<String>):
required: falseThe Amazon Resource Name (ARN) of the Amazon Web Services KMS key to use to encrypt your inline agent.
end_session(bool)/set_end_session(Option<bool>):
required: falseSpecifies whether to end the session with the inline agent or not.
enable_trace(bool)/set_enable_trace(Option<bool>):
required: falseSpecifies whether to turn on the trace or not to track the agent’s reasoning process. For more information, see Using trace.
input_text(impl Into<String>)/set_input_text(Option<String>):
required: falseThe prompt text to send to the agent.
If you include
returnControlInvocationResultsin thesessionStatefield, theinputTextfield will be ignored.inline_session_state(InlineSessionState)/set_inline_session_state(Option<InlineSessionState>):
required: falseParameters that specify the various attributes of a sessions. You can include attributes for the session or prompt or, if you configured an action group to return control, results from invocation of the action group. For more information, see Control session context.
If you include
returnControlInvocationResultsin thesessionStatefield, theinputTextfield will be ignored.foundation_model(impl Into<String>)/set_foundation_model(Option<String>):
required: trueThe model identifier (ID) of the model to use for orchestration by the inline agent. For example,
meta.llama3-1-70b-instruct-v1:0.instruction(impl Into<String>)/set_instruction(Option<String>):
required: trueThe instructions that tell the inline agent what it should do and how it should interact with users.
idle_session_ttl_in_seconds(i32)/set_idle_session_ttl_in_seconds(Option<i32>):
required: falseThe number of seconds for which the inline agent should maintain session information. After this time expires, the subsequent
InvokeInlineAgentrequest begins a new session.A user interaction remains active for the amount of time specified. If no conversation occurs during this time, the session expires and the data provided before the timeout is deleted.
action_groups(AgentActionGroup)/set_action_groups(Option<Vec::<AgentActionGroup>>):
required: falseA list of action groups with each action group defining the action the inline agent needs to carry out.
knowledge_bases(KnowledgeBase)/set_knowledge_bases(Option<Vec::<KnowledgeBase>>):
required: falseContains information of the knowledge bases to associate with.
guardrail_configuration(GuardrailConfigurationWithArn)/set_guardrail_configuration(Option<GuardrailConfigurationWithArn>):
required: falseThe guardrails to assign to the inline agent.
prompt_override_configuration(PromptOverrideConfiguration)/set_prompt_override_configuration(Option<PromptOverrideConfiguration>):
required: falseConfigurations for advanced prompts used to override the default prompts to enhance the accuracy of the inline agent.
bedrock_model_configurations(InlineBedrockModelConfigurations)/set_bedrock_model_configurations(Option<InlineBedrockModelConfigurations>):
required: falseModel settings for the request.
streaming_configurations(StreamingConfigurations)/set_streaming_configurations(Option<StreamingConfigurations>):
required: falseSpecifies the configurations for streaming.
To use agent streaming, you need permissions to perform the
bedrock:InvokeModelWithResponseStreamaction.
- On success, responds with
InvokeInlineAgentOutputwith field(s):completion(EventReceiver<InlineAgentResponseStream, InlineAgentResponseStreamError>):content_type(String):The MIME type of the input data in the request. The default value is application/json.
session_id(String):The unique identifier of the session with the agent.
- On failure, responds with
SdkError<InvokeInlineAgentError>
Source§impl Client
impl Client
Sourcepub fn optimize_prompt(&self) -> OptimizePromptFluentBuilder
pub fn optimize_prompt(&self) -> OptimizePromptFluentBuilder
Constructs a fluent builder for the OptimizePrompt operation.
- The fluent builder is configurable:
input(InputPrompt)/set_input(Option<InputPrompt>):
required: trueContains the prompt to optimize.
target_model_id(impl Into<String>)/set_target_model_id(Option<String>):
required: trueThe unique identifier of the model that you want to optimize the prompt for.
- On success, responds with
OptimizePromptOutputwith field(s):optimized_prompt(EventReceiver<OptimizedPromptStream, OptimizedPromptStreamError>):The prompt after being optimized for the task.
- On failure, responds with
SdkError<OptimizePromptError>
Source§impl Client
impl Client
Sourcepub fn rerank(&self) -> RerankFluentBuilder
pub fn rerank(&self) -> RerankFluentBuilder
Constructs a fluent builder for the Rerank operation.
This operation supports pagination; See into_paginator().
- The fluent builder is configurable:
queries(RerankQuery)/set_queries(Option<Vec::<RerankQuery>>):
required: trueAn array of objects, each of which contains information about a query to submit to the reranker model.
sources(RerankSource)/set_sources(Option<Vec::<RerankSource>>):
required: trueAn array of objects, each of which contains information about the sources to rerank.
reranking_configuration(RerankingConfiguration)/set_reranking_configuration(Option<RerankingConfiguration>):
required: trueContains configurations for reranking.
next_token(impl Into<String>)/set_next_token(Option<String>):
required: falseIf the total number of results was greater than could fit in a response, a token is returned in the
nextTokenfield. You can enter that token in this field to return the next batch of results.
- On success, responds with
RerankOutputwith field(s):results(Vec::<RerankResult>):An array of objects, each of which contains information about the results of reranking.
next_token(Option<String>):If the total number of results is greater than can fit in the response, use this token in the
nextTokenfield when making another request to return the next batch of results.
- On failure, responds with
SdkError<RerankError>
Source§impl Client
impl Client
Sourcepub fn retrieve(&self) -> RetrieveFluentBuilder
pub fn retrieve(&self) -> RetrieveFluentBuilder
Constructs a fluent builder for the Retrieve operation.
This operation supports pagination; See into_paginator().
- The fluent builder is configurable:
knowledge_base_id(impl Into<String>)/set_knowledge_base_id(Option<String>):
required: trueThe unique identifier of the knowledge base to query.
retrieval_query(KnowledgeBaseQuery)/set_retrieval_query(Option<KnowledgeBaseQuery>):
required: trueContains the query to send the knowledge base.
retrieval_configuration(KnowledgeBaseRetrievalConfiguration)/set_retrieval_configuration(Option<KnowledgeBaseRetrievalConfiguration>):
required: falseContains configurations for the knowledge base query and retrieval process. For more information, see Query configurations.
guardrail_configuration(GuardrailConfiguration)/set_guardrail_configuration(Option<GuardrailConfiguration>):
required: falseGuardrail settings.
next_token(impl Into<String>)/set_next_token(Option<String>):
required: falseIf there are more results than can fit in the response, the response returns a
nextToken. Use this token in thenextTokenfield of another request to retrieve the next batch of results.
- On success, responds with
RetrieveOutputwith field(s):retrieval_results(Vec::<KnowledgeBaseRetrievalResult>):A list of results from querying the knowledge base.
guardrail_action(Option<GuadrailAction>):Specifies if there is a guardrail intervention in the response.
next_token(Option<String>):If there are more results than can fit in the response, the response returns a
nextToken. Use this token in thenextTokenfield of another request to retrieve the next batch of results.
- On failure, responds with
SdkError<RetrieveError>
Source§impl Client
impl Client
Sourcepub fn retrieve_and_generate(&self) -> RetrieveAndGenerateFluentBuilder
pub fn retrieve_and_generate(&self) -> RetrieveAndGenerateFluentBuilder
Constructs a fluent builder for the RetrieveAndGenerate operation.
- The fluent builder is configurable:
session_id(impl Into<String>)/set_session_id(Option<String>):
required: falseThe unique identifier of the session. When you first make a
RetrieveAndGeneraterequest, Amazon Bedrock automatically generates this value. You must reuse this value for all subsequent requests in the same conversational session. This value allows Amazon Bedrock to maintain context and knowledge from previous interactions. You can’t explicitly set thesessionIdyourself.input(RetrieveAndGenerateInput)/set_input(Option<RetrieveAndGenerateInput>):
required: trueContains the query to be made to the knowledge base.
retrieve_and_generate_configuration(RetrieveAndGenerateConfiguration)/set_retrieve_and_generate_configuration(Option<RetrieveAndGenerateConfiguration>):
required: falseContains configurations for the knowledge base query and retrieval process. For more information, see Query configurations.
session_configuration(RetrieveAndGenerateSessionConfiguration)/set_session_configuration(Option<RetrieveAndGenerateSessionConfiguration>):
required: falseContains details about the session with the knowledge base.
- On success, responds with
RetrieveAndGenerateOutputwith field(s):session_id(String):The unique identifier of the session. When you first make a
RetrieveAndGeneraterequest, Amazon Bedrock automatically generates this value. You must reuse this value for all subsequent requests in the same conversational session. This value allows Amazon Bedrock to maintain context and knowledge from previous interactions. You can’t explicitly set thesessionIdyourself.output(Option<RetrieveAndGenerateOutput>):Contains the response generated from querying the knowledge base.
citations(Option<Vec::<Citation>>):A list of segments of the generated response that are based on sources in the knowledge base, alongside information about the sources.
guardrail_action(Option<GuadrailAction>):Specifies if there is a guardrail intervention in the response.
- On failure, responds with
SdkError<RetrieveAndGenerateError>
Source§impl Client
impl Client
Sourcepub fn retrieve_and_generate_stream(
&self,
) -> RetrieveAndGenerateStreamFluentBuilder
pub fn retrieve_and_generate_stream( &self, ) -> RetrieveAndGenerateStreamFluentBuilder
Constructs a fluent builder for the RetrieveAndGenerateStream operation.
- The fluent builder is configurable:
session_id(impl Into<String>)/set_session_id(Option<String>):
required: falseThe unique identifier of the session. When you first make a
RetrieveAndGeneraterequest, Amazon Bedrock automatically generates this value. You must reuse this value for all subsequent requests in the same conversational session. This value allows Amazon Bedrock to maintain context and knowledge from previous interactions. You can’t explicitly set thesessionIdyourself.input(RetrieveAndGenerateInput)/set_input(Option<RetrieveAndGenerateInput>):
required: trueContains the query to be made to the knowledge base.
retrieve_and_generate_configuration(RetrieveAndGenerateConfiguration)/set_retrieve_and_generate_configuration(Option<RetrieveAndGenerateConfiguration>):
required: falseContains configurations for the knowledge base query and retrieval process. For more information, see Query configurations.
session_configuration(RetrieveAndGenerateSessionConfiguration)/set_session_configuration(Option<RetrieveAndGenerateSessionConfiguration>):
required: falseContains details about the session with the knowledge base.
- On success, responds with
RetrieveAndGenerateStreamOutputwith field(s):stream(EventReceiver<RetrieveAndGenerateStreamResponseOutput, RetrieveAndGenerateStreamResponseOutputError>):A stream of events from the model.
session_id(String):The session ID.
- On failure, responds with
SdkError<RetrieveAndGenerateStreamError>
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>
Returns self with the
fg()
set to
Color::BrightBlack.
§Example
println!("{}", value.bright_black());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>
Returns self with the
fg()
set to
Color::BrightGreen.
§Example
println!("{}", value.bright_green());Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Returns self with the
fg()
set to
Color::BrightYellow.
§Example
println!("{}", value.bright_yellow());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>
Returns self with the
fg()
set to
Color::BrightMagenta.
§Example
println!("{}", value.bright_magenta());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>
Returns self with the
fg()
set to
Color::BrightWhite.
§Example
println!("{}", value.bright_white());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>
Returns self with the
bg()
set to
Color::BrightBlack.
§Example
println!("{}", value.on_bright_black());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>
Returns self with the
bg()
set to
Color::BrightGreen.
§Example
println!("{}", value.on_bright_green());Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Returns self with the
bg()
set to
Color::BrightYellow.
§Example
println!("{}", value.on_bright_yellow());Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Returns self with the
bg()
set to
Color::BrightBlue.
§Example
println!("{}", value.on_bright_blue());Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Returns self with the
bg()
set to
Color::BrightMagenta.
§Example
println!("{}", value.on_bright_magenta());Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Returns self with the
bg()
set to
Color::BrightCyan.
§Example
println!("{}", value.on_bright_cyan());Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Returns self with the
bg()
set to
Color::BrightWhite.
§Example
println!("{}", value.on_bright_white());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 underline(&self) -> Painted<&T>
fn underline(&self) -> Painted<&T>
Returns self with the
attr()
set to
Attribute::Underline.
§Example
println!("{}", value.underline());Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Returns self with the
attr()
set to
Attribute::RapidBlink.
§Example
println!("{}", value.rapid_blink());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);