Skip to content

Commit

Permalink
chore: short form
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Jan 7, 2024
1 parent 46e3c5e commit 30e4849
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions viz-core/src/response.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use futures_util::Stream;
use http_body_util::Full;

use crate::{header, Body, BoxError, Bytes, Error, Future, Response, Result, StatusCode};
Expand Down Expand Up @@ -86,7 +85,7 @@ pub trait ResponseExt: private::Sealed + Sized {
/// Responds to a stream.
fn stream<S, D, E>(stream: S) -> Response
where
S: Stream<Item = Result<D, E>> + Send + 'static,
S: futures_util::Stream<Item = Result<D, E>> + Send + 'static,
D: Into<Bytes> + 'static,
E: Into<BoxError> + 'static,
{
Expand Down Expand Up @@ -189,8 +188,10 @@ impl ResponseExt for Response {
fn content_length(&self) -> Option<u64> {
self.headers()
.get(header::CONTENT_LENGTH)
.and_then(|v| v.to_str().ok())
.and_then(|v| v.parse().ok())
.map(header::HeaderValue::to_str)
.and_then(Result::ok)
.map(str::parse)
.and_then(Result::ok)
}

fn content_type(&self) -> Option<mime::Mime> {
Expand All @@ -204,8 +205,10 @@ impl ResponseExt for Response {
{
self.headers()
.get(key)
.and_then(|v| v.to_str().ok())
.and_then(|v| v.parse::<T>().ok())
.map(header::HeaderValue::to_str)
.and_then(Result::ok)
.map(str::parse)
.and_then(Result::ok)
}

fn ok(&self) -> bool {
Expand Down

0 comments on commit 30e4849

Please sign in to comment.