Skip to content

Commit

Permalink
chore(viz): clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Sep 14, 2023
1 parent 11dfc67 commit 1be29cd
Showing 1 changed file with 32 additions and 11 deletions.
43 changes: 32 additions & 11 deletions viz-core/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ pub trait RequestExt: Sized {
fn query_string(&self) -> Option<&str>;

/// Get query data by type.
///
/// # Errors
///
/// Will return [`PayloadError::UrlDecode`] if decoding the query string fails.
#[cfg(feature = "query")]
fn query<T>(&self) -> Result<T, PayloadError>
where
Expand Down Expand Up @@ -78,46 +82,51 @@ pub trait RequestExt: Sized {
fn incoming_body(&mut self) -> IncomingBody;

/// Get Incoming.
///
/// # Errors
///
/// Will return [`PayloadError::Empty`] or [`PayloadError::Used`] if the incoming does not
/// exist or be used.
fn incoming(&mut self) -> Result<Incoming, PayloadError>;

/// Return with a [Bytes][mdn] representation of the request body.
///
/// [mdn]: <https://developer.mozilla.org/en-US/docs/Web/API/Response/arrayBuffer>
async fn bytes(&mut self) -> Result<Bytes, PayloadError>;

#[cfg(feature = "limits")]
/// Return with a [Bytes][mdn] by a limit representation of the request body.
///
/// [mdn]: <https://developer.mozilla.org/en-US/docs/Web/API/Response/arrayBuffer>
#[cfg(feature = "limits")]
async fn bytes_with(&mut self, limit: Option<u64>, max: u64) -> Result<Bytes, PayloadError>;

/// Return with a [Text][mdn] representation of the request body.
///
/// [mdn]: <https://developer.mozilla.org/en-US/docs/Web/API/Response/text>
async fn text(&mut self) -> Result<String, PayloadError>;

#[cfg(feature = "form")]
/// Return with a `application/x-www-form-urlencoded` [FormData][mdn] by the specified type
/// representation of the request body.
///
/// [mdn]: <https://developer.mozilla.org/en-US/docs/Web/API/FormData>
#[cfg(feature = "form")]
async fn form<T>(&mut self) -> Result<T, PayloadError>
where
T: serde::de::DeserializeOwned;

#[cfg(feature = "json")]
/// Return with a [JSON][mdn] by the specified type representation of the request body.
///
/// [mdn]: <https://developer.mozilla.org/en-US/docs/Web/API/Response/json>
#[cfg(feature = "json")]
async fn json<T>(&mut self) -> Result<T, PayloadError>
where
T: serde::de::DeserializeOwned;

#[cfg(feature = "multipart")]
/// Return with a `multipart/form-data` [FormData][mdn] by the specified type
/// representation of the request body.
///
/// [mdn]: <https://developer.mozilla.org/en-US/docs/Web/API/FormData>
#[cfg(feature = "multipart")]
async fn multipart(&mut self) -> Result<Multipart, PayloadError>;

#[cfg(feature = "state")]
Expand All @@ -126,38 +135,50 @@ pub trait RequestExt: Sized {
where
T: Clone + Send + Sync + 'static;

#[cfg(feature = "state")]
/// Store a shared state.
#[cfg(feature = "state")]
fn set_state<T>(&mut self, t: T) -> Option<T>
where
T: Clone + Send + Sync + 'static;

#[cfg(feature = "cookie")]
/// Get a wrapper of `cookie-jar` for managing cookies.
///
/// # Errors
///
/// Will return [`CookiesError`] if getting cookies fails.
#[cfg(feature = "cookie")]
fn cookies(&self) -> Result<Cookies, CookiesError>;

#[cfg(feature = "cookie")]
/// Get a cookie by the specified name.
#[cfg(feature = "cookie")]
fn cookie<S>(&self, name: S) -> Option<Cookie<'_>>
where
S: AsRef<str>;

#[cfg(feature = "limits")]
/// Get limits settings.
#[cfg(feature = "limits")]
fn limits(&self) -> &Limits;

#[cfg(feature = "session")]
/// Get current session.
#[cfg(feature = "session")]
fn session(&self) -> &Session;

#[cfg(feature = "params")]
/// Get all parameters.
///
/// # Errors
///
/// Will return [`ParamsError`] if deserializer the parameters fails.
#[cfg(feature = "params")]
fn params<T>(&self) -> Result<T, ParamsError>
where
T: serde::de::DeserializeOwned;

#[cfg(feature = "params")]
/// Get single parameter by name.
///
/// # Errors
///
/// Will return [`ParamsError`] if deserializer the single parameter fails.
#[cfg(feature = "params")]
fn param<T>(&self, name: &str) -> Result<T, ParamsError>
where
T: std::str::FromStr,
Expand Down

0 comments on commit 1be29cd

Please sign in to comment.