Skip to content

Commit

Permalink
chore(docs): fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Sep 21, 2023
1 parent 7d7134a commit a5c26fe
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions viz-core/src/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use hyper::body::{Body, Frame, Incoming, SizeHint};

use crate::{Bytes, Error, Result};

#[derive(Debug)]
/// Incoming Body from request.
#[derive(Debug)]
pub enum IncomingBody {
/// A empty body.
Empty,
Expand Down Expand Up @@ -107,8 +107,8 @@ impl Stream for IncomingBody {
}
}

#[derive(Debug)]
/// Outgoing Body to response.
#[derive(Debug)]
pub enum OutgoingBody<D = Bytes> {
/// A empty body.
Empty,
Expand Down
2 changes: 1 addition & 1 deletion viz-core/src/middleware/cookie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ pub struct Config {
}

impl Config {
#[cfg(any(feature = "cookie-signed", feature = "cookie-private"))]
/// Creates a new config with the [`Key`][types::CookieKey].
#[cfg(any(feature = "cookie-signed", feature = "cookie-private"))]
#[must_use]
pub fn with_key(key: types::CookieKey) -> Self {
Self {
Expand Down
4 changes: 2 additions & 2 deletions viz-core/src/middleware/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ impl Default for CookieOptions {
}
}

#[cfg(not(feature = "cookie-private"))]
/// An interface for managing the cookies.
#[cfg(not(feature = "cookie-private"))]
pub trait Cookieable {
/// Gets the options of the cookie.
fn options(&self) -> &CookieOptions;
Expand All @@ -145,8 +145,8 @@ pub trait Cookieable {
}
}

#[cfg(feature = "cookie-private")]
/// An interface for managing the `private` cookies.
#[cfg(feature = "cookie-private")]
pub trait Cookieable {
/// Gets the options of the cookie.
fn options(&self) -> &CookieOptions;
Expand Down
2 changes: 1 addition & 1 deletion viz-core/src/middleware/limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ impl Config {
self
}

#[cfg(feature = "multipart")]
/// Sets a limits for the Multipart Form.
#[cfg(feature = "multipart")]
#[must_use]
pub fn multipart(mut self, limits: types::MultipartLimits) -> Self {
*Arc::make_mut(&mut self.multipart) = limits;
Expand Down
2 changes: 1 addition & 1 deletion viz-core/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ pub trait RequestExt: Sized {
#[cfg(feature = "multipart")]
async fn multipart(&mut self) -> Result<Multipart, PayloadError>;

#[cfg(feature = "state")]
/// Return a shared state by the specified type.
#[cfg(feature = "state")]
fn state<T>(&self) -> Option<T>
where
T: Clone + Send + Sync + 'static;
Expand Down
9 changes: 5 additions & 4 deletions viz-core/src/response.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#[cfg(feature = "json")]
use bytes::{BufMut, BytesMut};
use http_body_util::Full;

use crate::{header, Bytes, Error, OutgoingBody, Response, Result, StatusCode};
Expand Down Expand Up @@ -40,17 +38,20 @@ pub trait ResponseExt: Sized {
Self::with(body.into(), mime::TEXT_HTML_UTF_8.as_ref())
}

#[cfg(feature = "json")]
/// The response with `application/javascript; charset=utf-8` media type.
///
/// # Errors
///
/// Throws an error if serialization fails.
#[cfg(feature = "json")]
fn json<T>(body: T) -> Result<Response, crate::types::PayloadError>
where
T: serde::Serialize,
{
let mut buf = BytesMut::new().writer();
use bytes::{BufMut, BytesMut};

// See <https://docs.rs/serde_json/latest/src/serde_json/ser.rs.html#2179>
let mut buf = BytesMut::with_capacity(128).writer();
serde_json::to_writer(&mut buf, &body)
.map(|()| {
Self::with(
Expand Down

0 comments on commit a5c26fe

Please sign in to comment.