pub struct ClientConfig {
pub base_url: String,
pub timeout: Duration,
pub stream_idle_timeout: Duration,
pub retry: RetryConfig,
pub stream_reconnect: ReconnectConfig,
pub require_tls: bool,
pub internal_token_provider: Option<InternalTokenProvider>,
}Expand description
Base configuration for a generated REST client.
Fields§
§base_url: StringBase URL prefix (e.g., https://billing.internal).
Combined with the base path declared in the projection trait.
timeout: DurationDeadline applied to a single unary attempt — NOT to the whole logical
call. A #[retryable] method may make up to retry.max_attempts attempts,
so the worst-case wall-clock for a logical call is bounded by
max_attempts × (timeout + retry.max_delay) (the per-retry backoff is
itself clamped to RetryConfig::max_delay, including a server-advised
Retry-After). There is deliberately no separate whole-call budget field.
stream_idle_timeout: DurationPer-item idle deadline for streams of any framing: the maximum gap
between two received wire chunks before the stream is treated as timed
out. A long-lived stream is NOT bounded by timeout
(which would kill a healthy slow stream); it is bounded by this larger
idle deadline instead. Defaults to 60s (> the unary default).
This is idle, not quiet: any wire chunk resets it, including ones that dispatch no item (an SSE keepalive comment, a multipart part header block arriving on its own).
retry: RetryConfigRetry policy applied to methods marked #[retryable].
stream_reconnect: ReconnectConfigReconnect policy for streams of any framing. By default
max_attempts: 0 — stream failures bubble up unchanged. Set explicitly
to opt into transparent re-open on a transient failure.
Two limits are deliberate rather than accidental:
- It applies only to a method whose open is immediate
(
#[streaming] fn). A fallible open (#[streaming] async fn) carries domain semantics the client must not blindly repeat — a re-open can collide with an exclusion lease the first open acquired, and its failure would land as a stream item, past the caller’s open-time error handling. Generated code therefore passesReconnectConfig::disabledfor a fallible open regardless of this value. - Resume via
Last-Event-IDis SSE-only. A reconnectedmultipart/mixedstream re-issues the original request with no resume token, because the framing has none. The transport still reopens it, but that is a blind restart, not a resume: the server replays the body from its first part, so any items already delivered before the failure are delivered again (at-least-once, with no marker for the restart). Enable reconnect for a multipart stream only where the consumer tolerates duplicates; one needing exactly-once must instead leave reconnect disabled and run its own reopen loop with application-level dedup.
require_tls: boolWhen true, the generated client refuses plaintext http:// and
requires TLS (toolkit_http::TransportSecurity::TlsOnly) for every
request — including the bearer-carrying Authorization header, which
otherwise would ride whatever scheme base_url uses. Defaults to
false, preserving the platform’s existing in-mesh
service-to-service convention where plaintext HTTP inside a secured
network boundary is an accepted, deliberate choice (see
build_default_http_client).
Set this when a resolved endpoint may cross an untrusted network.
internal_token_provider: Option<InternalTokenProvider>Source of the platform-plane internal credential attached to methods
whose plane marker is PlatformSecurityContext (carried as
X-ToolKit-Internal-Token). None (the default) attaches nothing —
legitimate for Profile 1 / in-process (InternalCredential::None);
the requirement is enforced server-side. The bootstrap layer populates
this from the process’s selected InternalCredential. Tenant-plane
methods (SecurityContext) never consult it; they forward the caller’s
bearer token from the argument.
Implementations§
Source§impl ClientConfig
impl ClientConfig
Sourcepub fn new(base_url: impl Into<String>) -> ClientConfig
pub fn new(base_url: impl Into<String>) -> ClientConfig
Create a new config with sensible defaults.
Sourcepub fn with_timeout(self, timeout: Duration) -> ClientConfig
pub fn with_timeout(self, timeout: Duration) -> ClientConfig
Override the per-call (unary) timeout.
Sourcepub fn with_stream_idle_timeout(self, idle: Duration) -> ClientConfig
pub fn with_stream_idle_timeout(self, idle: Duration) -> ClientConfig
Override the per-item stream idle deadline (max gap between wire
chunks). See Self::stream_idle_timeout.
Sourcepub fn with_retry(self, retry: RetryConfig) -> ClientConfig
pub fn with_retry(self, retry: RetryConfig) -> ClientConfig
Override the retry policy.
Sourcepub fn with_stream_reconnect(
self,
stream_reconnect: ReconnectConfig,
) -> ClientConfig
pub fn with_stream_reconnect( self, stream_reconnect: ReconnectConfig, ) -> ClientConfig
Override the stream reconnect policy. Use
ReconnectConfig::disabled() to disable (the default) or
ReconnectConfig::enabled() to opt in. See
Self::stream_reconnect for what it does and does not govern.
Sourcepub fn with_require_tls(self, require_tls: bool) -> ClientConfig
pub fn with_require_tls(self, require_tls: bool) -> ClientConfig
Require TLS (reject plaintext http://) for this client. See
Self::require_tls.
Sourcepub fn with_internal_token_provider(
self,
provider: impl Into<Option<InternalTokenProvider>>,
) -> ClientConfig
pub fn with_internal_token_provider( self, provider: impl Into<Option<InternalTokenProvider>>, ) -> ClientConfig
Set (or clear) the platform-plane internal-credential provider. See
Self::internal_token_provider. Accepts either an
InternalTokenProvider or an Option<InternalTokenProvider>, so the
bootstrap layer can pass through whatever the process selected without a
branch.
Trait Implementations§
Source§impl Clone for ClientConfig
impl Clone for ClientConfig
Source§fn clone(&self) -> ClientConfig
fn clone(&self) -> ClientConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ClientConfig
impl !UnwindSafe for ClientConfig
impl Freeze for ClientConfig
impl Send for ClientConfig
impl Sync for ClientConfig
impl Unpin for ClientConfig
impl UnsafeUnpin for ClientConfig
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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<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);Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
Source§fn decompression(self) -> Decompression<Self>where
Self: Sized,
fn decompression(self) -> Decompression<Self>where
Self: Sized,
Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
Source§fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
Source§fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
Source§fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
x-request-id as the header name. Read moreSource§fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
Source§fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
x-request-id as the header name. Read moreSource§fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>where
Self: Sized,
fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>where
Self: Sized,
500 Internal Server responses. Read moreSource§fn request_body_limit(self, limit: usize) -> RequestBodyLimit<Self>where
Self: Sized,
fn request_body_limit(self, limit: usize) -> RequestBodyLimit<Self>where
Self: Sized,
413 Payload Too Large responses. Read moreSource§impl<T> WithSecurityContext for T
impl<T> WithSecurityContext for T
Source§fn security_ctx<'a>(&'a self, ctx: &'a SecurityContext) -> Secured<'a, T>where
T: Sized,
fn security_ctx<'a>(&'a self, ctx: &'a SecurityContext) -> Secured<'a, T>where
T: Sized,
Secured wrapper. Read more