Skip to content

conduit::RequestExt: Remove redundant accessor methods #5834

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions conduit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,60 +28,26 @@ pub fn box_error<E: Error + Send + 'static>(error: E) -> BoxError {
}

pub trait RequestExt {
/// The request method, such as GET, POST, PUT, DELETE or PATCH
fn method(&self) -> &Method;

/// The request URI
fn uri(&self) -> &Uri;

/// The byte-size of the body, if any
fn content_length(&self) -> Option<u64>;

/// The request's headers, as conduit::Headers.
fn headers(&self) -> &HeaderMap;

/// A Reader for the body of the request
///
/// # Blocking
///
/// The returned value implements the blocking `Read` API and should only
/// be read from while in a blocking context.
fn body(&mut self) -> &mut dyn Read;

/// A readable map of extensions
fn extensions(&self) -> &Extensions;

/// A mutable map of extensions
fn extensions_mut(&mut self) -> &mut Extensions;
}

impl RequestExt for ConduitRequest {
fn method(&self) -> &Method {
self.method()
}

fn uri(&self) -> &Uri {
self.uri()
}

fn content_length(&self) -> Option<u64> {
Some(self.body().get_ref().len() as u64)
}

fn headers(&self) -> &HeaderMap {
self.headers()
}

fn body(&mut self) -> &mut dyn Read {
self.body_mut()
}

fn extensions(&self) -> &Extensions {
self.extensions()
}
fn extensions_mut(&mut self) -> &mut Extensions {
self.extensions_mut()
}
}

/// A Handler takes a request and returns a response or an error.
Expand Down