Struct Client

Source
pub struct Client<F> { /* private fields */ }
Expand description

A client that implements the API by making HTTP calls out to a server.

Implementations§

Source§

impl Client<ResponseFuture>

Source

pub fn try_new_with_connector<C>( base_path: &str, protocol: Option<&'static str>, connector: C, ) -> Result<Self, ClientInitError>
where C: Connect + 'static, C::Transport: 'static, C::Future: 'static,

Create a client with a custom implementation of hyper::client::Connect.

Intended for use with custom implementations of connect for e.g. protocol logging or similar functionality which requires wrapping the transport layer. When wrapping a TCP connection, this function should be used in conjunction with swagger::Connector::builder().

For ordinary tcp connections, prefer the use of try_new_http, try_new_https and try_new_https_mutual, to avoid introducing a dependency on the underlying transport layer.

§Arguments
  • base_path - base path of the client API, i.e. “www.my-api-implementation.com”
  • protocol - Which protocol to use when constructing the request url, e.g. Some("http")
  • connector - Implementation of hyper::client::Connect to use for the client
Source

pub fn try_new_http(base_path: &str) -> Result<Self, ClientInitError>

Create an HTTP client.

§Arguments
  • base_path - base path of the client API, i.e. “www.my-api-implementation.com”
Source

pub fn try_new_https(base_path: &str) -> Result<Self, ClientInitError>

Create a client with a TLS connection to the server

§Arguments
  • base_path - base path of the client API, i.e. “www.my-api-implementation.com”
Source

pub fn try_new_https_pinned<CA>( base_path: &str, ca_certificate: CA, ) -> Result<Self, ClientInitError>
where CA: AsRef<Path>,

Create a client with a TLS connection to the server using a pinned certificate

§Arguments
  • base_path - base path of the client API, i.e. “www.my-api-implementation.com”
  • ca_certificate - Path to CA certificate used to authenticate the server
Source

pub fn try_new_https_mutual<CA, K, D>( base_path: &str, ca_certificate: CA, client_key: K, client_certificate: D, ) -> Result<Self, ClientInitError>
where CA: AsRef<Path>, K: AsRef<Path>, D: AsRef<Path>,

Create a client with a mutually authenticated TLS connection to the server.

§Arguments
  • base_path - base path of the client API, i.e. “www.my-api-implementation.com”
  • ca_certificate - Path to CA certificate used to authenticate the server
  • client_key - Path to the client private key
  • client_certificate - Path to the client’s public certificate associated with the private key
Source§

impl<F> Client<F>

Source

pub fn try_new_with_client_service( client_service: Arc<Box<dyn Service<ReqBody = Body, Future = F> + Send + Sync>>, base_path: &str, ) -> Result<Self, ClientInitError>

Constructor for creating a Client by passing in a pre-made swagger::Service

This allows adding custom wrappers around the underlying transport, for example for logging.

Trait Implementations§

Source§

impl<C, F> Api<C> for Client<F>
where C: Has<XSpanIdString>, F: Future<Item = Response<Body>, Error = Error> + Send + 'static,

Source§

fn i2c_bus_api( &self, context: &C, ) -> Box<dyn Future<Item = I2cBusApiResponse, Error = ApiError> + Send>

Source§

fn i2c_bus_list( &self, context: &C, ) -> Box<dyn Future<Item = I2cBusListResponse, Error = ApiError> + Send>

Source§

fn i2c_bus_read_byte( &self, param_bus_id: i32, param_addr: i32, context: &C, ) -> Box<dyn Future<Item = I2cBusReadByteResponse, Error = ApiError> + Send>

Source§

fn i2c_bus_read_bytes( &self, param_bus_id: i32, param_addr: i32, param_num_bytes: i32, context: &C, ) -> Box<dyn Future<Item = I2cBusReadBytesResponse, Error = ApiError> + Send>

Source§

fn i2c_bus_read_reg( &self, param_bus_id: i32, param_addr: i32, param_reg: i32, param_num_bytes: i32, context: &C, ) -> Box<dyn Future<Item = I2cBusReadRegResponse, Error = ApiError> + Send>

Source§

fn i2c_bus_write_byte( &self, param_bus_id: i32, param_addr: i32, param_value: i32, context: &C, ) -> Box<dyn Future<Item = I2cBusWriteByteResponse, Error = ApiError> + Send>

Source§

fn i2c_bus_write_byte_reg( &self, param_bus_id: i32, param_addr: i32, param_reg: i32, param_value: i32, context: &C, ) -> Box<dyn Future<Item = I2cBusWriteByteRegResponse, Error = ApiError> + Send>

Source§

fn i2c_bus_write_bytes( &self, param_bus_id: i32, param_addr: i32, param_values: Values, context: &C, ) -> Box<dyn Future<Item = I2cBusWriteBytesResponse, Error = ApiError> + Send>

Source§

fn i2c_bus_write_bytes_reg( &self, param_bus_id: i32, param_addr: i32, param_reg: i32, param_values: Values, context: &C, ) -> Box<dyn Future<Item = I2cBusWriteBytesRegResponse, Error = ApiError> + Send>

Source§

impl<F> Clone for Client<F>

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<F> Debug for Client<F>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<F> Freeze for Client<F>

§

impl<F> !RefUnwindSafe for Client<F>

§

impl<F> Send for Client<F>

§

impl<F> Sync for Client<F>

§

impl<F> Unpin for Client<F>

§

impl<F> !UnwindSafe for Client<F>

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<'a, T, C> ContextWrapperExt<'a, C> for T
where T: Api<C>,

Source§

fn with_context(&'a self, context: C) -> ContextWrapper<'a, T, C>

Binds this API to a context.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
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.