Skip to main content

ClientBuilder

Struct ClientBuilder 

pub struct ClientBuilder<S, C = Client<S>> {
    raw: RawClientBuilder,
    client: PhantomData<fn() -> (S, C)>,
}
Expand description

Builder for a Client of service S, or for the client C of a service crate.

Returned by Client::builder. A service crate returns it from its own builder function, built with ClientBuilder::new. Its client implements From<Client<S>>. See Service for an example.

Fields§

§raw: RawClientBuilder§client: PhantomData<fn() -> (S, C)>

Implementations§

§

impl<S: Service, C> ClientBuilder<S, C>

pub const fn new() -> Self

Returns a builder for the client of service S.

§

impl<S, C> ClientBuilder<S, C>

pub const fn instance(self, instance_id: u32) -> Self

Connects to the server with this instance ID instead of the first one.

See RawClientBuilder::instance.

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

Sets the default timeout for requests.

A request with Request::TIMEOUT uses that value instead. See RawClientBuilder::timeout.

pub const fn indication_capacity(self, capacity: NonZeroUsize) -> Self

Sets how many indications are buffered for each subscriber.

See RawClientBuilder::indication_capacity.

§

impl<S, C: From<Client<S>>> ClientBuilder<S, C>

pub fn connect(self) -> Result<(C, Connection), Error>

Connects to the first matching server of the service.

Run the returned Connection, otherwise requests time out.

§Errors

Returns the errors of RawClientBuilder::connect.

pub fn connect_to(self, server: Server) -> Result<(C, Connection), Error>

Connects to server without looking it up.

Use this for a server that ServiceWatcher::wait_for_service returned. Run the returned Connection, otherwise requests time out.

§Errors

Returns the errors of RawClientBuilder::connect_to.

fn typed((raw, connection): (RawClient, Connection)) -> (C, Connection)

Trait Implementations§

§

impl<S, C> Clone for ClientBuilder<S, C>

§

fn clone(&self) -> Self

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
§

impl<S, C> Copy for ClientBuilder<S, C>

§

impl<S, C> Debug for ClientBuilder<S, C>

§

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

Formats the value using the given formatter. Read more
§

impl<S: Service, C> Default for ClientBuilder<S, C>

§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<S, C> Freeze for ClientBuilder<S, C>
where PhantomData<fn() -> (S, C)>: Freeze,

§

impl<S, C> RefUnwindSafe for ClientBuilder<S, C>

§

impl<S, C> Send for ClientBuilder<S, C>
where PhantomData<fn() -> (S, C)>: Send,

§

impl<S, C> Sync for ClientBuilder<S, C>
where PhantomData<fn() -> (S, C)>: Sync,

§

impl<S, C> Unpin for ClientBuilder<S, C>
where PhantomData<fn() -> (S, C)>: Unpin,

§

impl<S, C> UnsafeUnpin for ClientBuilder<S, C>

§

impl<S, C> UnwindSafe for ClientBuilder<S, C>

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.

§

impl<T> Instrument for T

§

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

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

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 = !

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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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