Skip to main content

ServiceClientExt

Trait ServiceClientExt 

Source
pub trait ServiceClientExt: ServiceClient + Sized {
    // Provided methods
    fn with_outbound_compression(self, encoding: Encoding) -> Self { ... }
    fn set_outbound_compression(&mut self, encoding: Encoding) -> &mut Self { ... }
    fn outbound_compression(&self) -> Encoding { ... }
    fn with_default_timeout(self, duration: Duration) -> Self { ... }
    fn set_default_timeout(&mut self, duration: Duration) -> &mut Self { ... }
    fn default_timeout(&self) -> Option<Duration> { ... }
}
Expand description

Builder-style configuration available on every service client. Implemented for any T: ServiceClient + Sized, so service clients don’t reimplement these — they just impl ServiceClient and inherit the full set.

Provided Methods§

Source

fn with_outbound_compression(self, encoding: Encoding) -> Self

Compress every outgoing request body with this codec. Sent on the wire as grpc-encoding: <codec>.

The server is required by spec to handle whatever the client sends — including failing with Unimplemented — so picking a codec your server is known to support is the caller’s responsibility. The server’s grpc-accept-encoding (visible after the first response) can be inspected by the caller to pick a future-safe codec.

Setting Encoding::Identity clears any previously-set compression.

Source

fn set_outbound_compression(&mut self, encoding: Encoding) -> &mut Self

Source

fn outbound_compression(&self) -> Encoding

The currently-configured outbound compression. Identity if none has been set.

Source

fn with_default_timeout(self, duration: Duration) -> Self

Apply this duration as the default deadline on every call. Sent on the wire as grpc-timeout: <unit> so the server can enforce the same deadline; the client also races its own dispatch future against a local timer so we fail fast even if the server is unable to respond.

Setting Duration::ZERO clears any previously-set deadline.

Source

fn set_default_timeout(&mut self, duration: Duration) -> &mut Self

&mut form of with_default_timeout.

Source

fn default_timeout(&self) -> Option<Duration>

The currently-configured default timeout, if any.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§