Skip to content

Commit

Permalink
rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
sunli829 committed Sep 7, 2024
1 parent 6d08604 commit 388c79e
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 25 deletions.
4 changes: 2 additions & 2 deletions poem-grpc/src/example_generated/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! This module shows an example of code generated by the macro. **IT MUST NOT BE USED OUTSIDE THIS
//! CRATE**.
//! This module shows an example of code generated by the macro. **IT MUST NOT
//! BE USED OUTSIDE THIS CRATE**.

#![allow(missing_docs)]

Expand Down
3 changes: 2 additions & 1 deletion poem-openapi/src/auth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ pub trait ApiKeyAuthorization: Sized {
) -> Result<Self>;
}

/// Facilitates the conversion of `Option` into `Results`, for `SecuritySchema` checker.
/// Facilitates the conversion of `Option` into `Results`, for `SecuritySchema`
/// checker.
#[doc(hidden)]
pub enum CheckerReturn<T> {
Result(Result<T>),
Expand Down
21 changes: 13 additions & 8 deletions poem-openapi/tests/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1021,11 +1021,14 @@ fn object_default_override_by_field() {
);
}

// NOTE(Rennorb): The `serialize_with` and `deserialize_with` attributes don't add any additional validation,
// it's up to the library consumer to use them in ways were they don't violate the OpenAPI specification of the underlying type.
// NOTE(Rennorb): The `serialize_with` and `deserialize_with` attributes don't
// add any additional validation, it's up to the library consumer to use them in
// ways were they don't violate the OpenAPI specification of the underlying
// type.
//
// In practice `serialize_with` only exists for the rounding case below, which could not be implemented in a different way before this
// (only by using a larger type), and `deserialize_with` just exists for parity.
// In practice `serialize_with` only exists for the rounding case below, which
// could not be implemented in a different way before this (only by using a
// larger type), and `deserialize_with` just exists for parity.

#[test]
fn serialize_with() {
Expand All @@ -1036,8 +1039,9 @@ fn serialize_with() {
b: f32,
}

// NOTE(Rennorb): Function signature in complice with `to_json` in the Type system.
// Would prefer the usual way of implementing this with a serializer reference, but this has to do for now.
// NOTE(Rennorb): Function signature in complice with `to_json` in the Type
// system. Would prefer the usual way of implementing this with a serializer
// reference, but this has to do for now.
fn round(v: &f32) -> Option<serde_json::Value> {
Some(serde_json::Value::from((*v as f64 * 1e5).round() / 1e5))
}
Expand All @@ -1055,8 +1059,9 @@ fn deserialize_with() {
a: i32,
}

// NOTE(Rennorb): Function signature in complice with `parse_from_json` in the Type system.
// Would prefer the usual way of implementing this with a serializer reference, but this has to do for now.
// NOTE(Rennorb): Function signature in complice with `parse_from_json` in the
// Type system. Would prefer the usual way of implementing this with a
// serializer reference, but this has to do for now.
fn add(value: Option<serde_json::Value>) -> poem_openapi::types::ParseResult<i32> {
value
.as_ref()
Expand Down
5 changes: 3 additions & 2 deletions poem/src/listener/acme/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ pub struct AcmeClient {
}

impl AcmeClient {
/// Create a new client. `directory_url` is the url for the ACME provider. `contacts` is a list
/// of URLS (ex: `mailto:`) the ACME service can use to reach you if there's issues with your certificates.
/// Create a new client. `directory_url` is the url for the ACME provider.
/// `contacts` is a list of URLS (ex: `mailto:`) the ACME service can
/// use to reach you if there's issues with your certificates.
pub async fn try_new(directory_url: &str, contacts: Vec<String>) -> IoResult<Self> {
let client = Client::new();
let directory = get_directory(&client, directory_url).await?;
Expand Down
4 changes: 2 additions & 2 deletions poem/src/listener/acme/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use crate::{error::NotFoundError, Endpoint, IntoResponse, Request, Response, Res
pub struct Http01TokensMap(Arc<RwLock<HashMap<String, String>>>);

impl Http01TokensMap {
/// Create a new http01 challenge tokens storage for use in challenge endpoint
/// and [`issue_cert`].
/// Create a new http01 challenge tokens storage for use in challenge
/// endpoint and [`issue_cert`].
#[inline]
pub fn new() -> Self {
Self::default()
Expand Down
8 changes: 4 additions & 4 deletions poem/src/listener/acme/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,11 @@ pub struct IssueCertResult {
pub rustls_key: Arc<CertifiedKey>,
}

/// Generate a new certificate via ACME protocol. Returns the pub cert and private
/// key in PEM format, and the private key as a Rustls object.
/// Generate a new certificate via ACME protocol. Returns the pub cert and
/// private key in PEM format, and the private key as a Rustls object.
///
/// It is up to the caller to make use of the returned certificate, this function does
/// nothing outside for the ACME protocol procedure.
/// It is up to the caller to make use of the returned certificate, this
/// function does nothing outside for the ACME protocol procedure.
pub async fn issue_cert<T: AsRef<str>>(
client: &mut AcmeClient,
resolver: &ResolveServerCert,
Expand Down
5 changes: 3 additions & 2 deletions poem/src/middleware/compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ fn parse_accept_encoding(

/// Middleware to decompress the request body and compress the response body.
///
/// The decompression algorithm is selected according to the request `Content-Encoding` header,
/// and the compression algorithm is selected according to the request `Accept-Encoding` header.
/// The decompression algorithm is selected according to the request
/// `Content-Encoding` header, and the compression algorithm is selected
/// according to the request `Accept-Encoding` header.
#[cfg_attr(docsrs, doc(cfg(feature = "compression")))]
#[derive(Default)]
pub struct Compression {
Expand Down
10 changes: 6 additions & 4 deletions poem/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ where
}
}

/// Specify connection idle timeout. Connections will be terminated if there was no activity
/// within this period of time
/// Specify connection idle timeout. Connections will be terminated if there
/// was no activity within this period of time
#[must_use]
pub fn idle_timeout(self, timeout: Duration) -> Self {
Self {
Expand All @@ -110,7 +110,8 @@ where
}
}

/// Configures the maximum number of pending reset streams allowed before a GOAWAY will be sent.
/// Configures the maximum number of pending reset streams allowed before a
/// GOAWAY will be sent.
///
/// This will default to the default value set by the [`h2` crate](https://crates.io/crates/h2).
/// As of v0.4.0, it is 20.
Expand Down Expand Up @@ -452,6 +453,7 @@ async fn serve_connection<Io>(

// Init graceful shutdown for connection
conn.as_mut().graceful_shutdown();
// Continue awaiting after graceful-shutdown is initiated to handle existed requests.
// Continue awaiting after graceful-shutdown is initiated to handle existed
// requests.
let _ = conn.await;
}

0 comments on commit 388c79e

Please sign in to comment.