Skip to content

Commit

Permalink
Rebase and fix conflicts.
Browse files Browse the repository at this point in the history
  • Loading branch information
MathiasPius committed Mar 5, 2024
1 parent 24cd88c commit 2cdadab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
18 changes: 12 additions & 6 deletions src/crates/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@ pub mod sparse;
use std::collections::HashMap;

use async_trait::async_trait;
use hyper::client::HttpConnector;
use hyper::{Body, Request};
use http_body_util::{BodyExt, Empty};
use hyper::body::Bytes;
use hyper::Request;
use hyper_rustls::HttpsConnector;
use hyper_util::client::legacy::{connect::HttpConnector, Client};
use semver::Version;
use serde::Deserialize;
use time::OffsetDateTime;
use tokio::sync::mpsc;

use self::cache::{CachedVersion, CrateCache};

type HyperClient = hyper::Client<HttpsConnector<HttpConnector>>;
type HyperClient = Client<HttpsConnector<HttpConnector>, Empty<Bytes>>;

#[derive(Debug)]
pub enum CrateError {
Expand Down Expand Up @@ -58,14 +60,18 @@ pub trait CrateLookup: Clone + Send + 'static {
"crates-lsp (github.com/MathiasPius/crates-lsp)",
)
.header("Accept", "application/json")
.body(Body::empty())
.body(Empty::default())
.map_err(CrateError::transport)?,
)
.await
.map_err(CrateError::transport)?;
let body = hyper::body::to_bytes(response.into_body())

let body = response
.into_body()
.collect()
.await
.map_err(CrateError::transport)?;
.map_err(CrateError::transport)?
.to_bytes();

let stringified = String::from_utf8_lossy(&body);
let details: Crates =
Expand Down
12 changes: 4 additions & 8 deletions src/crates/sparse.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
use async_trait::async_trait;
use http_body_util::{BodyExt, Empty};
use hyper::{body::Bytes, Request};
use hyper_rustls::HttpsConnector;
use hyper_util::{
client::legacy::{connect::HttpConnector, Client},
rt::TokioExecutor,
};
use hyper::Request;
use hyper_util::{client::legacy::Client, rt::TokioExecutor};
use semver::Version;
use serde::Deserialize;

use super::{CrateError, CrateLookup};
use super::{CrateError, CrateLookup, HyperClient};

#[derive(Debug, Clone)]
pub struct CrateIndex {
client: Client<HttpsConnector<HttpConnector>, Empty<Bytes>>,
client: HyperClient,
}

#[async_trait]
Expand Down

0 comments on commit 2cdadab

Please sign in to comment.