Skip to content

Commit c4624f5

Browse files
committed
Use http_types::Result
1 parent 300c7b6 commit c4624f5

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use async_std::io::{self, BufReader, Read, Write};
44
use async_std::prelude::*;
55
use async_std::task::{Context, Poll};
66
use futures_core::ready;
7-
use http_types::{ensure, ensure_eq, format_err, Error};
7+
use http_types::{ensure, ensure_eq, format_err};
88
use http_types::{
99
headers::{HeaderName, HeaderValue, CONTENT_LENGTH, DATE, TRANSFER_ENCODING},
1010
Body, Request, Response, StatusCode,
@@ -131,7 +131,7 @@ async fn encode(req: Request) -> http_types::Result<Encoder> {
131131

132132
/// Decode an HTTP response on the client.
133133
#[doc(hidden)]
134-
pub async fn decode<R>(reader: R) -> Result<Response, Error>
134+
pub async fn decode<R>(reader: R) -> http_types::Result<Response>
135135
where
136136
R: Read + Unpin + Send + Sync + 'static,
137137
{

src/date.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::fmt::{self, Display, Formatter};
22
use std::str::{from_utf8, FromStr};
33
use std::time::{Duration, SystemTime, UNIX_EPOCH};
44

5-
use http_types::{bail, ensure, format_err, Error};
5+
use http_types::{bail, ensure, format_err};
66

77
const IMF_FIXDATE_LENGTH: usize = 29;
88
const RFC850_MAX_LENGTH: usize = 23;
@@ -39,7 +39,7 @@ pub struct HttpDate {
3939
/// ascdate formats. Two digit years are mapped to dates between
4040
/// 1970 and 2069.
4141
#[allow(dead_code)]
42-
pub(crate) fn parse_http_date(s: &str) -> Result<SystemTime, Error> {
42+
pub(crate) fn parse_http_date(s: &str) -> http_types::Result<SystemTime> {
4343
s.parse::<HttpDate>().map(|d| d.into())
4444
}
4545

@@ -66,7 +66,7 @@ impl HttpDate {
6666
}
6767
}
6868

69-
fn parse_imf_fixdate(s: &[u8]) -> Result<HttpDate, Error> {
69+
fn parse_imf_fixdate(s: &[u8]) -> http_types::Result<HttpDate> {
7070
// Example: `Sun, 06 Nov 1994 08:49:37 GMT`
7171
if s.len() != IMF_FIXDATE_LENGTH
7272
|| &s[25..] != b" GMT"
@@ -110,7 +110,7 @@ fn parse_imf_fixdate(s: &[u8]) -> Result<HttpDate, Error> {
110110
})
111111
}
112112

113-
fn parse_rfc850_date(s: &[u8]) -> Result<HttpDate, Error> {
113+
fn parse_rfc850_date(s: &[u8]) -> http_types::Result<HttpDate> {
114114
// Example: `Sunday, 06-Nov-94 08:49:37 GMT`
115115
ensure!(
116116
s.len() >= RFC850_MAX_LENGTH,
@@ -165,7 +165,7 @@ fn parse_rfc850_date(s: &[u8]) -> Result<HttpDate, Error> {
165165
})
166166
}
167167

168-
fn parse_asctime(s: &[u8]) -> Result<HttpDate, Error> {
168+
fn parse_asctime(s: &[u8]) -> http_types::Result<HttpDate> {
169169
// Example: `Sun Nov 6 08:49:37 1994`
170170
if s.len() != ASCTIME_LENGTH || s[10] != b' ' || s[13] != b':' || s[16] != b':' || s[19] != b' '
171171
{
@@ -326,7 +326,7 @@ impl From<HttpDate> for SystemTime {
326326
}
327327

328328
impl FromStr for HttpDate {
329-
type Err = Error;
329+
type Err = http_types::Error;
330330

331331
fn from_str(s: &str) -> Result<Self, Self::Err> {
332332
ensure!(s.is_ascii(), "String slice is not valid ASCII");

src/server.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use async_std::task::{Context, Poll};
1212
use futures_core::ready;
1313
use http_types::headers::{HeaderName, HeaderValue, CONTENT_LENGTH, TRANSFER_ENCODING};
1414
use http_types::{ensure, ensure_eq, format_err};
15-
use http_types::{Body, Error, Method, Request, Response};
15+
use http_types::{Body, Method, Request, Response};
1616

1717
use crate::chunked::ChunkedDecoder;
1818
use crate::date::fmt_http_date;
@@ -28,7 +28,7 @@ pub async fn accept<RW, F, Fut>(addr: &str, mut io: RW, endpoint: F) -> http_typ
2828
where
2929
RW: Read + Write + Clone + Send + Sync + Unpin + 'static,
3030
F: Fn(Request) -> Fut,
31-
Fut: Future<Output = Result<Response, Error>>,
31+
Fut: Future<Output = http_types::Result<Response>>,
3232
{
3333
// TODO: make configurable
3434
let timeout_duration = Duration::from_secs(10);
@@ -336,7 +336,7 @@ impl Read for Encoder {
336336
const HTTP_1_1_VERSION: u8 = 1;
337337

338338
/// Decode an HTTP request on the server.
339-
async fn decode<R>(addr: &str, reader: R) -> Result<Option<Request>, Error>
339+
async fn decode<R>(addr: &str, reader: R) -> http_types::Result<Option<Request>>
340340
where
341341
R: Read + Unpin + Send + Sync + 'static,
342342
{

0 commit comments

Comments
 (0)