[−][src]Struct mbus_api::client::Client
A client that implements the API by making HTTP calls out to a server.
Methods
impl Client<FutureResponse>
[src]
pub fn try_new_http(
handle: Handle,
base_path: &str
) -> Result<Client<FutureResponse>, ClientInitError>
[src]
handle: Handle,
base_path: &str
) -> Result<Client<FutureResponse>, ClientInitError>
Create an HTTP client.
Arguments
handle
- tokio reactor handle to use for executionbase_path
- base path of the client API, i.e. "www.my-api-implementation.com"
pub fn try_new_https<CA>(
handle: Handle,
base_path: &str,
ca_certificate: CA
) -> Result<Client<FutureResponse>, ClientInitError> where
CA: AsRef<Path>,
[src]
handle: Handle,
base_path: &str,
ca_certificate: CA
) -> Result<Client<FutureResponse>, ClientInitError> where
CA: AsRef<Path>,
Create a client with a TLS connection to the server.
Arguments
handle
- tokio reactor handle to use for executionbase_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
pub fn try_new_https_mutual<CA, K, C>(
handle: Handle,
base_path: &str,
ca_certificate: CA,
client_key: K,
client_certificate: C
) -> Result<Client<FutureResponse>, ClientInitError> where
CA: AsRef<Path>,
K: AsRef<Path>,
C: AsRef<Path>,
[src]
handle: Handle,
base_path: &str,
ca_certificate: CA,
client_key: K,
client_certificate: C
) -> Result<Client<FutureResponse>, ClientInitError> where
CA: AsRef<Path>,
K: AsRef<Path>,
C: AsRef<Path>,
Create a client with a mutually authenticated TLS connection to the server.
Arguments
handle
- tokio reactor handle to use for executionbase_path
- base path of the client API, i.e. "www.my-api-implementation.com"ca_certificate
- Path to CA certificate used to authenticate the serverclient_key
- Path to the client private keyclient_certificate
- Path to the client's public certificate associated with the private key
pub fn try_new_with_connector<C>(
handle: Handle,
base_path: &str,
protocol: Option<&'static str>,
connector_fn: Box<dyn Fn(&Handle) -> C + Send + Sync>
) -> Result<Client<FutureResponse>, ClientInitError> where
C: Connect + Service,
[src]
handle: Handle,
base_path: &str,
protocol: Option<&'static str>,
connector_fn: Box<dyn Fn(&Handle) -> C + Send + Sync>
) -> Result<Client<FutureResponse>, ClientInitError> where
C: Connect + Service,
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::{http_connector, https_connector, https_mutual_connector}
.
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
handle
- tokio reactor handle to use for executionbase_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_fn
- Function which returns an implementation ofhyper::client::Connect
pub fn try_new_with_hyper_client(
hyper_client: Arc<Box<dyn Service<Request = Request<Body>, Response = Response, Error = Error, Future = FutureResponse>>>,
handle: Handle,
base_path: &str
) -> Result<Client<FutureResponse>, ClientInitError>
[src]
hyper_client: Arc<Box<dyn Service<Request = Request<Body>, Response = Response, Error = Error, Future = FutureResponse>>>,
handle: Handle,
base_path: &str
) -> Result<Client<FutureResponse>, ClientInitError>
Use try_new_with_client_service instead
Constructor for creating a Client
by passing in a pre-made hyper
client.
One should avoid relying on this function if possible, since it adds a dependency on the underlying transport implementation, which it would be better to abstract away. Therefore, using this function may lead to a loss of code generality, which may make it harder to move the application to a serverless environment, for example.
The reason for this function's existence is to support legacy test code, which did mocking at the hyper layer. This is not a recommended way to write new tests. If other reasons are found for using this function, they should be mentioned here.
impl<F> Client<F> where
F: Future<Item = Response, Error = Error> + 'static,
[src]
F: Future<Item = Response, Error = Error> + 'static,
pub fn try_new_with_client_service(
client_service: Arc<Box<dyn Service<Request = Request<Body>, Response = Response, Error = Error, Future = F>>>,
handle: Handle,
base_path: &str
) -> Result<Client<F>, ClientInitError>
[src]
client_service: Arc<Box<dyn Service<Request = Request<Body>, Response = Response, Error = Error, Future = F>>>,
handle: Handle,
base_path: &str
) -> Result<Client<F>, ClientInitError>
Constructor for creating a Client
by passing in a pre-made hyper
client Service.
This allows adding custom wrappers around the underlying transport, for example for logging.
Trait Implementations
impl<F, C> Api<C> for Client<F> where
F: Future<Item = Response, Error = Error> + 'static,
C: Has<XSpanIdString>,
[src]
F: Future<Item = Response, Error = Error> + 'static,
C: Has<XSpanIdString>,
fn api(
&self,
context: &C
) -> Box<dyn Future<Item = ApiResponse, Error = ApiError>>
[src]
&self,
context: &C
) -> Box<dyn Future<Item = ApiResponse, Error = ApiError>>
fn get(
&self,
param_device: String,
param_baudrate: Baudrate,
param_address: i32,
context: &C
) -> Box<dyn Future<Item = GetResponse, Error = ApiError>>
[src]
&self,
param_device: String,
param_baudrate: Baudrate,
param_address: i32,
context: &C
) -> Box<dyn Future<Item = GetResponse, Error = ApiError>>
fn hat(
&self,
context: &C
) -> Box<dyn Future<Item = HatResponse, Error = ApiError>>
[src]
&self,
context: &C
) -> Box<dyn Future<Item = HatResponse, Error = ApiError>>
fn hat_off(
&self,
context: &C
) -> Box<dyn Future<Item = HatOffResponse, Error = ApiError>>
[src]
&self,
context: &C
) -> Box<dyn Future<Item = HatOffResponse, Error = ApiError>>
fn hat_on(
&self,
context: &C
) -> Box<dyn Future<Item = HatOnResponse, Error = ApiError>>
[src]
&self,
context: &C
) -> Box<dyn Future<Item = HatOnResponse, Error = ApiError>>
fn scan(
&self,
param_device: String,
param_baudrate: Baudrate,
context: &C
) -> Box<dyn Future<Item = ScanResponse, Error = ApiError>>
[src]
&self,
param_device: String,
param_baudrate: Baudrate,
context: &C
) -> Box<dyn Future<Item = ScanResponse, Error = ApiError>>
impl<F> Clone for Client<F> where
F: Future<Item = Response, Error = Error> + 'static,
[src]
F: Future<Item = Response, Error = Error> + 'static,
fn clone(&self) -> Self
[src]
default fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<F> Debug for Client<F> where
F: Future<Item = Response, Error = Error> + 'static,
[src]
F: Future<Item = Response, Error = Error> + 'static,
Auto Trait Implementations
Blanket Implementations
impl<'a, T, C> ContextWrapperExt for T where
T: Api<C>,
[src]
T: Api<C>,
fn with_context(&'a Self, C) -> ContextWrapper<'a, T, C>
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,