Skip to main content

CallOptions

Struct CallOptions 

Source
#[non_exhaustive]
pub struct CallOptions { /* private fields */ }
Expand description

Per-request options for an RPC call.

Provides per-call configuration such as additional headers and timeouts. Use CallOptions::default() for no additional options.

CallOptions is #[non_exhaustive]: new fields may be added in minor releases. Construct with CallOptions::default() and the with_* builder methods, then read settings back through the accessor methods.

§Example

use connectrpc::client::CallOptions;
use std::time::Duration;

let options = CallOptions::default()
    .with_timeout(Duration::from_secs(5))
    .with_header("x-request-id", "abc123");
assert_eq!(options.timeout(), Some(Duration::from_secs(5)));
assert_eq!(options.headers().get("x-request-id").unwrap(), "abc123");

Implementations§

Source§

impl CallOptions

Source

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

Set the request timeout.

Read via Self::timeout.

Source

pub fn with_header( self, name: impl TryInto<HeaderName>, value: impl TryInto<HeaderValue>, ) -> Self

Add a request header.

If the name or value cannot be converted to valid HTTP header components, the header is silently ignored. Use try_with_header for fallible insertion.

Read via Self::headers.

Source

pub fn try_with_header( self, name: impl TryInto<HeaderName>, value: impl TryInto<HeaderValue>, ) -> Result<Self, ConnectError>

Add a request header, returning an error if the name or value is invalid.

Read via Self::headers.

§Errors

Returns ErrorCode::Internal if the name or value cannot be converted to a valid HTTP header component.

Source

pub fn with_headers( self, headers: impl IntoIterator<Item = (HeaderName, HeaderValue)>, ) -> Self

Add multiple request headers from an iterator.

Read via Self::headers.

Source

pub fn with_max_message_size(self, size: usize) -> Self

Set the maximum decompressed message size in bytes.

Read via Self::max_message_size.

Source

pub fn with_compress(self, enabled: bool) -> Self

Override compression for this call. Some(true) forces compression, Some(false) disables it; not calling this defers to the configured CompressionPolicy.

Read via Self::compress.

Source

pub fn headers(&self) -> &HeaderMap

Additional headers to include in the request.

These are merged into the HTTP request after protocol headers, allowing override of any header for advanced use cases.

Set via Self::with_header / Self::with_headers.

Source

pub fn timeout(&self) -> Option<Duration>

The request timeout, sent as connect-timeout-ms / grpc-timeout.

Set via Self::with_timeout.

Source

pub fn max_message_size(&self) -> Option<usize>

The maximum decompressed message size in bytes.

When set, messages exceeding this size after decompression will result in a ResourceExhausted error. Applies per-message for streaming.

Set via Self::with_max_message_size.

Source

pub fn compress(&self) -> Option<bool>

The per-call compression override. Some(true) forces compression, Some(false) disables it, None defers to the policy.

Set via Self::with_compress.

Trait Implementations§

Source§

impl Clone for CallOptions

Source§

fn clone(&self) -> CallOptions

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CallOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CallOptions

Source§

fn default() -> CallOptions

Returns the “default value” for a type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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<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