pub struct Client { /* private fields */ }
Expand description
A client that implements the API by making HTTP calls out to a server.
Implementations§
Source§impl Client
impl Client
Sourcepub fn try_new_http(base_path: &str) -> Result<Client, ClientInitError>
pub fn try_new_http(base_path: &str) -> Result<Client, ClientInitError>
Create an HTTP client.
§Arguments
base_path
- base path of the client API, i.e. “www.my-api-implementation.com”
Sourcepub fn try_new_with_connector<C, S>(
base_path: &str,
protocol: Option<&'static str>,
connector: C,
) -> Result<Client, ClientInitError>
pub fn try_new_with_connector<C, S>( base_path: &str, protocol: Option<&'static str>, connector: C, ) -> Result<Client, ClientInitError>
Create a client with a custom implementation of hyper::net::NetworkConnector.
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
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
- An instance ofC: hyper::net::NetworkConnection
Sourcepub fn try_new_with_hyper_client(
hyper_client: Arc<Client>,
base_path: &str,
) -> Result<Client, ClientInitError>
pub fn try_new_with_hyper_client( hyper_client: Arc<Client>, base_path: &str, ) -> Result<Client, ClientInitError>
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.
This function is deprecated in the upstream openapi-generator which uses newer hyper. However, the suggested replacement does not exist in hyper 0.9.