http_request_derive_client/client.rs
1// SPDX-FileCopyrightText: OpenTalk GmbH <mail@opentalk.eu>
2//
3// SPDX-License-Identifier: MIT OR Apache-2.0
4
5use http_request_derive::HttpRequest;
6
7/// A client that can execute [`http_request_derive::HttpRequest`]s.
8#[async_trait::async_trait]
9pub trait Client {
10 /// An error that can be returned during request execution by the [`Client`].
11 type ClientError: std::error::Error;
12
13 /// Execute a [`http_request_derive::HttpRequest`], and read the typed response.
14 async fn execute<R: HttpRequest + Send>(
15 &self,
16 request: R,
17 ) -> Result<R::Response, Self::ClientError>;
18}