Skip to content

Commit 42b7610

Browse files
committed
Refer to hyperium's http crate as hyperium
Signed-off-by: Ryan Levick <[email protected]>
1 parent a3e7ca2 commit 42b7610

File tree

3 files changed

+28
-30
lines changed

3 files changed

+28
-30
lines changed

sdk/rust/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ once_cell = "1.18.0"
2222
futures = "0.3.28"
2323
serde_json = { version = "1.0.96", optional = true }
2424
serde = { version = "1.0.163", optional = true }
25-
http_types = { package = "http", version = "0.2", optional = true }
25+
hyperium = { package = "http", version = "0.2", optional = true }
2626
bytes = { version = "1", optional = true }
2727

2828
[features]
2929
default = ["export-sdk-language", "http", "json"]
30-
http = ["dep:http_types", "dep:bytes"]
30+
http = ["dep:hyperium", "dep:bytes"]
3131
export-sdk-language = []
3232
json = ["dep:serde", "dep:serde_json"]
3333
experimental = []

sdk/rust/src/http.rs

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,21 @@ pub enum SendError {
3939
}
4040

4141
#[cfg(feature = "http")]
42-
impl<B> TryFrom<http_types::Request<B>> for Request
42+
impl<B> TryFrom<hyperium::Request<B>> for Request
4343
where
4444
B: TryIntoBody,
4545
B::Error: std::error::Error + Send + Sync + 'static,
4646
{
4747
type Error = anyhow::Error;
48-
fn try_from(req: http_types::Request<B>) -> Result<Self, Self::Error> {
48+
fn try_from(req: hyperium::Request<B>) -> Result<Self, Self::Error> {
4949
let method = match req.method() {
50-
&http_types::Method::GET => Method::Get,
51-
&http_types::Method::POST => Method::Post,
52-
&http_types::Method::PUT => Method::Put,
53-
&http_types::Method::DELETE => Method::Delete,
54-
&http_types::Method::PATCH => Method::Patch,
55-
&http_types::Method::HEAD => Method::Head,
56-
&http_types::Method::OPTIONS => Method::Options,
50+
&hyperium::Method::GET => Method::Get,
51+
&hyperium::Method::POST => Method::Post,
52+
&hyperium::Method::PUT => Method::Put,
53+
&hyperium::Method::DELETE => Method::Delete,
54+
&hyperium::Method::PATCH => Method::Patch,
55+
&hyperium::Method::HEAD => Method::Head,
56+
&hyperium::Method::OPTIONS => Method::Options,
5757
m => anyhow::bail!("Unsupported method: {m}"),
5858
};
5959
let headers = req
@@ -197,12 +197,10 @@ impl Display for NonUtf8BodyError {
197197
}
198198

199199
#[cfg(feature = "http")]
200-
impl<B: TryFromBody> TryNonRequestFromRequest for http_types::Request<B> {
200+
impl<B: TryFromBody> TryNonRequestFromRequest for hyperium::Request<B> {
201201
type Error = B::Error;
202202
fn try_from_request(req: Request) -> Result<Self, Self::Error> {
203-
let mut builder = http_types::Request::builder()
204-
.uri(req.uri)
205-
.method(req.method);
203+
let mut builder = hyperium::Request::builder().uri(req.uri).method(req.method);
206204
for (n, v) in req.headers {
207205
builder = builder.header(n, v);
208206
}
@@ -211,25 +209,25 @@ impl<B: TryFromBody> TryNonRequestFromRequest for http_types::Request<B> {
211209
}
212210

213211
#[cfg(feature = "http")]
214-
impl From<Method> for http_types::Method {
212+
impl From<Method> for hyperium::Method {
215213
fn from(method: Method) -> Self {
216214
match method {
217-
Method::Get => http_types::Method::GET,
218-
Method::Post => http_types::Method::POST,
219-
Method::Put => http_types::Method::PUT,
220-
Method::Delete => http_types::Method::DELETE,
221-
Method::Patch => http_types::Method::PATCH,
222-
Method::Head => http_types::Method::HEAD,
223-
Method::Options => http_types::Method::OPTIONS,
215+
Method::Get => hyperium::Method::GET,
216+
Method::Post => hyperium::Method::POST,
217+
Method::Put => hyperium::Method::PUT,
218+
Method::Delete => hyperium::Method::DELETE,
219+
Method::Patch => hyperium::Method::PATCH,
220+
Method::Head => hyperium::Method::HEAD,
221+
Method::Options => hyperium::Method::OPTIONS,
224222
}
225223
}
226224
}
227225

228226
#[cfg(feature = "http")]
229-
impl<B: TryFromBody> TryFrom<Response> for http_types::Response<B> {
227+
impl<B: TryFromBody> TryFrom<Response> for hyperium::Response<B> {
230228
type Error = B::Error;
231229
fn try_from(resp: Response) -> Result<Self, Self::Error> {
232-
let mut builder = http_types::Response::builder().status(resp.status);
230+
let mut builder = hyperium::Response::builder().status(resp.status);
233231
for (n, v) in resp.headers.unwrap_or_default() {
234232
builder = builder.header(n, v);
235233
}
@@ -254,7 +252,7 @@ impl<R: Into<Response>> IntoResponse for R {
254252
}
255253

256254
#[cfg(feature = "http")]
257-
impl<B> IntoResponse for http_types::Response<B>
255+
impl<B> IntoResponse for hyperium::Response<B>
258256
where
259257
B: IntoBody,
260258
{
@@ -352,7 +350,7 @@ impl IntoStatusCode for u16 {
352350
}
353351

354352
#[cfg(feature = "http")]
355-
impl IntoStatusCode for http_types::StatusCode {
353+
impl IntoStatusCode for hyperium::StatusCode {
356354
fn into_status_code(self) -> u16 {
357355
self.as_u16()
358356
}

sdk/rust/src/http/router.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ mod tests {
307307

308308
let req = make_request(Method::Post, "/foobar");
309309
let res = router.handle(req);
310-
assert_eq!(res.status, http_types::StatusCode::METHOD_NOT_ALLOWED);
310+
assert_eq!(res.status, hyperium::StatusCode::METHOD_NOT_ALLOWED);
311311
}
312312

313313
#[test]
@@ -321,7 +321,7 @@ mod tests {
321321

322322
let req = make_request(Method::Get, "/h1/");
323323
let res = router.handle(req);
324-
assert_eq!(res.status, http_types::StatusCode::NOT_FOUND);
324+
assert_eq!(res.status, hyperium::StatusCode::NOT_FOUND);
325325
}
326326

327327
#[test]
@@ -366,7 +366,7 @@ mod tests {
366366

367367
let req = make_request(Method::Get, "/foo/bar");
368368
let res = router.handle(req);
369-
assert_eq!(res.status, http_types::StatusCode::OK);
369+
assert_eq!(res.status, hyperium::StatusCode::OK);
370370
assert_eq!(res.body.unwrap(), "foo/bar".to_owned().into_bytes());
371371
}
372372

0 commit comments

Comments
 (0)