chore: fix rustfmt error
This commit is contained in:
@@ -18,8 +18,8 @@ use tokio::net::TcpListener;
|
|||||||
#[derive(Clone, Deserialize, Serialize, Validate, Eq, PartialEq)]
|
#[derive(Clone, Deserialize, Serialize, Validate, Eq, PartialEq)]
|
||||||
#[cfg_attr(feature = "extra_protobuf", derive(prost::Message))]
|
#[cfg_attr(feature = "extra_protobuf", derive(prost::Message))]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "typed_multipart",
|
feature = "typed_multipart",
|
||||||
derive(axum_typed_multipart::TryFromMultipart)
|
derive(axum_typed_multipart::TryFromMultipart)
|
||||||
)]
|
)]
|
||||||
pub struct ParametersGarde {
|
pub struct ParametersGarde {
|
||||||
#[garde(range(min = 5, max = 10))]
|
#[garde(range(min = 5, max = 10))]
|
||||||
@@ -564,7 +564,7 @@ mod typed_header {
|
|||||||
fn decode<'i, I>(values: &mut I) -> Result<Self, Error>
|
fn decode<'i, I>(values: &mut I) -> Result<Self, Error>
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
I: Iterator<Item=&'i HeaderValue>,
|
I: Iterator<Item = &'i HeaderValue>,
|
||||||
{
|
{
|
||||||
let value = values.next().ok_or_else(Error::invalid)?;
|
let value = values.next().ok_or_else(Error::invalid)?;
|
||||||
let src = std::str::from_utf8(value.as_bytes()).map_err(|_| Error::invalid())?;
|
let src = std::str::from_utf8(value.as_bytes()).map_err(|_| Error::invalid())?;
|
||||||
@@ -964,7 +964,9 @@ mod sonic {
|
|||||||
pub const SONIC: &str = "/sonic";
|
pub const SONIC: &str = "/sonic";
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn extract_sonic(Garde(Sonic(parameters)): Garde<Sonic<ParametersGarde>>) -> StatusCode {
|
pub async fn extract_sonic(
|
||||||
|
Garde(Sonic(parameters)): Garde<Sonic<ParametersGarde>>,
|
||||||
|
) -> StatusCode {
|
||||||
validate_again(parameters, ())
|
validate_again(parameters, ())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,13 +23,13 @@ pub mod validify;
|
|||||||
#[cfg(feature = "yaml")]
|
#[cfg(feature = "yaml")]
|
||||||
pub mod yaml;
|
pub mod yaml;
|
||||||
|
|
||||||
|
mod sonic;
|
||||||
#[cfg(feature = "toml")]
|
#[cfg(feature = "toml")]
|
||||||
pub mod toml;
|
pub mod toml;
|
||||||
#[cfg(feature = "typed_multipart")]
|
#[cfg(feature = "typed_multipart")]
|
||||||
pub mod typed_multipart;
|
pub mod typed_multipart;
|
||||||
#[cfg(feature = "xml")]
|
#[cfg(feature = "xml")]
|
||||||
pub mod xml;
|
pub mod xml;
|
||||||
mod sonic;
|
|
||||||
|
|
||||||
use axum::http::StatusCode;
|
use axum::http::StatusCode;
|
||||||
use axum::response::{IntoResponse, Response};
|
use axum::response::{IntoResponse, Response};
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ use validator::{Validate, ValidateArgs, ValidationError};
|
|||||||
#[derive(Clone, Deserialize, Serialize, Validate, Eq, PartialEq)]
|
#[derive(Clone, Deserialize, Serialize, Validate, Eq, PartialEq)]
|
||||||
#[cfg_attr(feature = "extra_protobuf", derive(prost::Message))]
|
#[cfg_attr(feature = "extra_protobuf", derive(prost::Message))]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "typed_multipart",
|
feature = "typed_multipart",
|
||||||
derive(axum_typed_multipart::TryFromMultipart)
|
derive(axum_typed_multipart::TryFromMultipart)
|
||||||
)]
|
)]
|
||||||
pub struct Parameters {
|
pub struct Parameters {
|
||||||
#[validate(range(min = 5, max = 10))]
|
#[validate(range(min = 5, max = 10))]
|
||||||
@@ -34,8 +34,8 @@ pub struct Parameters {
|
|||||||
#[derive(Clone, Deserialize, Serialize, Validate, Eq, PartialEq)]
|
#[derive(Clone, Deserialize, Serialize, Validate, Eq, PartialEq)]
|
||||||
#[cfg_attr(feature = "extra_protobuf", derive(prost::Message))]
|
#[cfg_attr(feature = "extra_protobuf", derive(prost::Message))]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "typed_multipart",
|
feature = "typed_multipart",
|
||||||
derive(axum_typed_multipart::TryFromMultipart)
|
derive(axum_typed_multipart::TryFromMultipart)
|
||||||
)]
|
)]
|
||||||
pub struct ParametersEx {
|
pub struct ParametersEx {
|
||||||
#[validate(custom(function = "validate_v0", arg = "&'v_a RangeInclusive<i32>"))]
|
#[validate(custom(function = "validate_v0", arg = "&'v_a RangeInclusive<i32>"))]
|
||||||
@@ -828,7 +828,7 @@ mod typed_header {
|
|||||||
fn decode<'i, I>(values: &mut I) -> Result<Self, Error>
|
fn decode<'i, I>(values: &mut I) -> Result<Self, Error>
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
I: Iterator<Item=&'i HeaderValue>,
|
I: Iterator<Item = &'i HeaderValue>,
|
||||||
{
|
{
|
||||||
let value = values.next().ok_or_else(Error::invalid)?;
|
let value = values.next().ok_or_else(Error::invalid)?;
|
||||||
let src = std::str::from_utf8(value.as_bytes()).map_err(|_| Error::invalid())?;
|
let src = std::str::from_utf8(value.as_bytes()).map_err(|_| Error::invalid())?;
|
||||||
@@ -861,7 +861,7 @@ mod typed_header {
|
|||||||
fn decode<'i, I>(values: &mut I) -> Result<Self, Error>
|
fn decode<'i, I>(values: &mut I) -> Result<Self, Error>
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
I: Iterator<Item=&'i HeaderValue>,
|
I: Iterator<Item = &'i HeaderValue>,
|
||||||
{
|
{
|
||||||
let value = values.next().ok_or_else(Error::invalid)?;
|
let value = values.next().ok_or_else(Error::invalid)?;
|
||||||
let src = std::str::from_utf8(value.as_bytes()).map_err(|_| Error::invalid())?;
|
let src = std::str::from_utf8(value.as_bytes()).map_err(|_| Error::invalid())?;
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ pub struct ParametersValidify {
|
|||||||
#[derive(Clone, Validify, Eq, PartialEq)]
|
#[derive(Clone, Validify, Eq, PartialEq)]
|
||||||
#[cfg_attr(feature = "extra_protobuf", derive(Message))]
|
#[cfg_attr(feature = "extra_protobuf", derive(Message))]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "typed_multipart",
|
feature = "typed_multipart",
|
||||||
derive(axum_typed_multipart::TryFromMultipart)
|
derive(axum_typed_multipart::TryFromMultipart)
|
||||||
)]
|
)]
|
||||||
pub struct ParametersValidifyWithoutPayload {
|
pub struct ParametersValidifyWithoutPayload {
|
||||||
#[validate(range(min = 5.0, max = 10.0))]
|
#[validate(range(min = 5.0, max = 10.0))]
|
||||||
@@ -1045,7 +1045,10 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
.await?;
|
.await?;
|
||||||
// Modified
|
// Modified
|
||||||
test_executor
|
test_executor
|
||||||
.execute_modified::<Sonic<ParametersValidify>>(Method::POST, sonic::route::SONIC_MODIFIED)
|
.execute_modified::<Sonic<ParametersValidify>>(
|
||||||
|
Method::POST,
|
||||||
|
sonic::route::SONIC_MODIFIED,
|
||||||
|
)
|
||||||
.await?;
|
.await?;
|
||||||
// Validified
|
// Validified
|
||||||
test_executor
|
test_executor
|
||||||
@@ -1056,7 +1059,10 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
.await?;
|
.await?;
|
||||||
// ValidifiedByRef
|
// ValidifiedByRef
|
||||||
test_executor
|
test_executor
|
||||||
.execute::<Sonic<ParametersValidify>>(Method::POST, sonic::route::SONIC_VALIDIFIED_BY_REF)
|
.execute::<Sonic<ParametersValidify>>(
|
||||||
|
Method::POST,
|
||||||
|
sonic::route::SONIC_VALIDIFIED_BY_REF,
|
||||||
|
)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1389,7 +1395,7 @@ mod typed_header {
|
|||||||
fn decode<'i, I>(values: &mut I) -> Result<Self, Error>
|
fn decode<'i, I>(values: &mut I) -> Result<Self, Error>
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
I: Iterator<Item=&'i HeaderValue>,
|
I: Iterator<Item = &'i HeaderValue>,
|
||||||
{
|
{
|
||||||
let value = values.next().ok_or_else(Error::invalid)?;
|
let value = values.next().ok_or_else(Error::invalid)?;
|
||||||
let src = std::str::from_utf8(value.as_bytes()).map_err(|_| Error::invalid())?;
|
let src = std::str::from_utf8(value.as_bytes()).map_err(|_| Error::invalid())?;
|
||||||
|
|||||||
Reference in New Issue
Block a user