Struct Client

Source
pub struct Client<S, C>
where S: Service<(Request<Body>, C), Response = Response<Body>> + Clone + Sync + Send + 'static, S::Future: Send + 'static, S::Error: Into<Box<dyn Error + Send + Sync + 'static>> + Display, C: Clone + Send + Sync + 'static,
{ /* private fields */ }
Expand description

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

Implementations§

Source§

impl<Connector, C> Client<DropContextService<Client<Connector, Body>, C>, C>
where Connector: Connect + Clone + Send + Sync + 'static, C: Clone + Send + Sync + 'static,

Source

pub fn try_new_with_connector( base_path: &str, protocol: Option<&'static str>, connector: Connector, ) -> Result<Self, ClientInitError>

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. “http://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§

impl<C> Client<DropContextService<HyperClient, C>, C>
where C: Clone + Send + Sync + 'static,

Source

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

Create an HTTP client.

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

impl<C> Client<DropContextService<Client<HttpConnector, Body>, C>, C>
where C: Clone + Send + Sync + 'static,

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. “http://www.my-api-implementation.com”
Source§

impl<C> Client<DropContextService<Client<HttpsConnector<HttpConnector>, Body>, C>, C>
where C: Clone + Send + Sync + 'static,

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. “https://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. “https://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. “https://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<S, C> Client<S, C>
where S: Service<(Request<Body>, C), Response = Response<Body>> + Clone + Sync + Send + 'static, S::Future: Send + 'static, S::Error: Into<Box<dyn Error + Send + Sync + 'static>> + Display, C: Clone + Send + Sync + 'static,

Source

pub fn try_new_with_client_service( client_service: S, base_path: &str, ) -> Result<Self, ClientInitError>

Constructor for creating a Client by passing in a pre-made hyper::service::Service / tower::Service

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

Trait Implementations§

Source§

impl<S, C> Api<C> for Client<S, C>
where S: Service<(Request<Body>, C), Response = Response<Body>> + Clone + Sync + Send + 'static, S::Future: Send + 'static, S::Error: Into<Box<dyn Error + Send + Sync + 'static>> + Display, C: Has<XSpanIdString> + Clone + Send + Sync + 'static,

Source§

fn poll_ready( &self, cx: &mut Context<'_>, ) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>>

Source§

fn get_task_list<'life0, 'life1, 'async_trait>( &'life0 self, context: &'life1 C, ) -> Pin<Box<dyn Future<Output = Result<GetTaskListResponse, ApiError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get list of running tasks
Source§

fn get_task_log_by_id<'life0, 'life1, 'async_trait>( &'life0 self, param_get_task_log_request: GetTaskLogRequest, context: &'life1 C, ) -> Pin<Box<dyn Future<Output = Result<GetTaskLogByIdResponse, ApiError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

get log
Source§

fn pause_task_by_id<'life0, 'life1, 'async_trait>( &'life0 self, param_simple_id_request: SimpleIdRequest, context: &'life1 C, ) -> Pin<Box<dyn Future<Output = Result<PauseTaskByIdResponse, ApiError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Pause a task by id
Source§

fn resume_task_by_id<'life0, 'life1, 'async_trait>( &'life0 self, param_simple_id_request: SimpleIdRequest, context: &'life1 C, ) -> Pin<Box<dyn Future<Output = Result<ResumeTaskByIdResponse, ApiError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Resume a task by id
Source§

fn start_task<'life0, 'life1, 'async_trait>( &'life0 self, param_start_task_request: StartTaskRequest, context: &'life1 C, ) -> Pin<Box<dyn Future<Output = Result<StartTaskResponse, ApiError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Start a new task
Source§

fn stop_task_by_id<'life0, 'life1, 'async_trait>( &'life0 self, param_simple_id_request: SimpleIdRequest, context: &'life1 C, ) -> Pin<Box<dyn Future<Output = Result<StopTaskByIdResponse, ApiError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Stop a task by id
Source§

impl<S, C> Clone for Client<S, C>
where S: Service<(Request<Body>, C), Response = Response<Body>> + Clone + Sync + Send + 'static, S::Future: Send + 'static, S::Error: Into<Box<dyn Error + Send + Sync + 'static>> + Display, C: Clone + Send + Sync + 'static,

Source§

fn clone(&self) -> Self

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

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

Performs copy-assignment from source. Read more
Source§

impl<S, C> Debug for Client<S, C>
where S: Service<(Request<Body>, C), Response = Response<Body>> + Clone + Sync + Send + 'static, S::Future: Send + 'static, S::Error: Into<Box<dyn Error + Send + Sync + 'static>> + Display, C: Clone + Send + Sync + 'static,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S, C> Freeze for Client<S, C>
where <S as Service<(Request<Body>, C)>>::Error: Sized, S: Freeze,

§

impl<S, C> RefUnwindSafe for Client<S, C>
where <S as Service<(Request<Body>, C)>>::Error: Sized, S: RefUnwindSafe,

§

impl<S, C> Send for Client<S, C>
where <S as Service<(Request<Body>, C)>>::Error: Sized,

§

impl<S, C> Sync for Client<S, C>
where <S as Service<(Request<Body>, C)>>::Error: Sized,

§

impl<S, C> Unpin for Client<S, C>
where <S as Service<(Request<Body>, C)>>::Error: Sized, S: Unpin,

§

impl<S, C> UnwindSafe for Client<S, C>
where <S as Service<(Request<Body>, C)>>::Error: Sized, S: UnwindSafe,

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, C> ContextWrapperExt<C> for T
where T: Api<C> + Send + Sync, C: Clone + Send + Sync,

Source§

fn with_context(self, context: C) -> ContextWrapper<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> Instrument for T

Source§

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

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

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

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> ErasedDestructor for T
where T: 'static,