Skip to content

Commit

Permalink
Revert "Remove maybe-async for now"
Browse files Browse the repository at this point in the history
This reverts commit 97e96f4.
  • Loading branch information
Byron committed May 12, 2021
1 parent 84d1509 commit ebd5701
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
24 changes: 24 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion git-transport/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ doctest = false

[features]
serde1 = ["serde"]
http-client-curl = ["curl", "base64", "git-features/io-pipe"]
http-client-curl = ["curl", "base64", "git-features/io-pipe", "maybe-async/is_sync"]

[[test]]
name = "blocking-transport"
Expand All @@ -34,6 +34,8 @@ git-packetline = { version = "^0.5.0", path = "../git-packetline" }
serde = { version = "1.0.114", optional = true, default-features = false, features = ["std", "derive"]}
quick-error = "2.0.0"
bstr = { version = "0.2.13", default-features = false, features = ["std"] }
maybe-async = "0.2.4"
async-trait = { version = "0.1.50", optional = true }

# for http-client-curl
# zlib-ng-compat doesn't force zlib-ng
Expand Down
9 changes: 7 additions & 2 deletions git-transport/src/client/blocking/http/traits.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use maybe_async::{maybe_async, sync_impl};
use quick_error::quick_error;
use std::io;

Expand Down Expand Up @@ -48,18 +49,22 @@ impl<A, B, C> From<PostResponse<A, B, C>> for GetResponse<A, B> {

/// A trait to abstract the HTTP operations needed to power all git interactions: read via GET and write via POST.
#[allow(clippy::type_complexity)]
#[maybe_async]
pub trait Http {
#[sync_impl]
/// A type providing headers line by line.
type Headers: io::BufRead;
/// A type providing the response.
#[sync_impl]
type ResponseBody: io::BufRead;
/// A type allowing to write the content to post.
#[sync_impl]
type PostBody: io::Write;

/// Initiate a `GET` request to `url` provided the given `headers`.
///
/// The `headers` are provided verbatim and include both the key as well as the value.
fn get(
async fn get(
&mut self,
url: &str,
headers: impl IntoIterator<Item = impl AsRef<str>>,
Expand All @@ -71,7 +76,7 @@ pub trait Http {
/// Note that the [`PostResponse`] contains the [`post_body`][PostResponse::post_body] field which implements [`std::io::Write`]
/// and is expected to receive the body to post to the server. **It must be dropped** before reading the response
/// to prevent deadlocks.
fn post(
async fn post(
&mut self,
url: &str,
headers: impl IntoIterator<Item = impl AsRef<str>>,
Expand Down

0 comments on commit ebd5701

Please sign in to comment.