ConfigBuilder

Struct ConfigBuilder 

Source
pub struct ConfigBuilder { /* private fields */ }
Expand description

使用流畅API创建Config实例的构建器

Implementations§

Source§

impl ConfigBuilder

Source

pub fn build(self) -> Result<Config, ConfigBuildError>

从当前构建器状态构建Config实例

§返回

包含Config实例或ConfigBuildError的Result

Source

pub fn build_openai(self) -> Result<OpenAI, ConfigBuildError>

从当前配置构建OpenAI客户端实例

§返回

包含OpenAI客户端实例或ConfigBuildError的Result

Source

pub fn api_key(self, api_key: impl Into<String>) -> Self

设置配置的API密钥

§参数
  • api_key - 要使用的API密钥
§返回

用于方法链的构建器实例

Source

pub fn base_url(self, base_url: impl Into<String>) -> Self

设置配置的基础URL

§参数
  • base_url - 要使用的基础URL
§返回

用于方法链的构建器实例

Source

pub fn retry_count(self, retry_count: usize) -> Self

设置配置的重试次数

§参数
  • retry_count - 重试次数
§返回

用于方法链的构建器实例

Source

pub fn timeout(self, timeout: Duration) -> Self

设置配置的请求超时时间

§参数
  • timeout - 超时值
§返回

用于方法链的构建器实例

Source

pub fn connect_timeout(self, connect_timeout: Duration) -> Self

设置配置的连接超时时间

§参数
  • connect_timeout - 连接超时值
§返回

用于方法链的构建器实例

Source

pub fn proxy(self, proxy: impl Into<String>) -> Self

为配置设置HTTP代理

§参数
  • proxy - 要使用的代理URL
§返回

用于方法链的构建器实例

Source

pub fn user_agent(self, user_agent: HeaderValue) -> Self

为配置设置自定义用户代理字符串

§参数
  • user_agent - 要使用的用户代理字符串
§返回

用于方法链的构建器实例

Source

pub fn header<K: IntoHeaderName>(self, key: K, value: HeaderValue) -> Self

向HTTP配置添加全局头。

§参数
  • key - 头名称
  • value - 头值
§返回

用于方法链的构建器实例

Source

pub fn body(self, key: impl Into<String>, value: impl Into<Value>) -> Self

向HTTP配置添加全局主体字段。

§参数
  • key - 主体字段名称
  • value - 主体字段值
§返回

用于方法链的构建器实例

Source

pub fn headers(self, headers: HeaderMap) -> Self

在HTTP配置中设置多个全局头。

§参数
  • headers - 头名称到值的映射
§返回

用于方法链的构建器实例

Source

pub fn bodys(self, bodys: Map<String, Value>) -> Self

在HTTP配置中设置多个全局主体字段。

§参数
  • bodys - 主体字段名称到值的映射
§返回

用于方法链的构建器实例

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,