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>
impl<S: Service, C> ClientBuilder<S, C>
pub const fn new() -> Self
pub const fn new() -> Self
Returns a builder for the client of service S.
§impl<S, C> ClientBuilder<S, C>
impl<S, C> ClientBuilder<S, C>
pub const fn instance(self, instance_id: u32) -> Self
pub const fn instance(self, instance_id: u32) -> Self
Connects to the server with this instance ID instead of the first one.
pub const fn timeout(self, timeout: Duration) -> Self
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
pub const fn indication_capacity(self, capacity: NonZeroUsize) -> Self
Sets how many indications are buffered for each subscriber.
§impl<S, C: From<Client<S>>> ClientBuilder<S, C>
impl<S, C: From<Client<S>>> ClientBuilder<S, C>
pub fn connect(self) -> Result<(C, Connection), Error>
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>
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.