diff --git a/crates/core/src/errors.rs b/crates/core/src/errors.rs index 007a029e..49dc15ae 100644 --- a/crates/core/src/errors.rs +++ b/crates/core/src/errors.rs @@ -93,7 +93,8 @@ pub struct ErroredForm { } impl ErroredForm { - #[must_use] pub fn new() -> Self { + #[must_use] + pub fn new() -> Self { Self { form: Vec::new(), fields: Vec::new(), diff --git a/crates/core/src/filters/cookies.rs b/crates/core/src/filters/cookies.rs index c877fc95..134dbc21 100644 --- a/crates/core/src/filters/cookies.rs +++ b/crates/core/src/filters/cookies.rs @@ -69,7 +69,8 @@ impl EncryptedCookie { } } -#[must_use] pub fn maybe_encrypted( +#[must_use] +pub fn maybe_encrypted( options: &CookiesConfig, ) -> impl Filter,), Error = Infallible> + Clone + Send + Sync + 'static where @@ -83,7 +84,8 @@ where }) } -#[must_use] pub fn encrypted( +#[must_use] +pub fn encrypted( options: &CookiesConfig, ) -> impl Filter + Clone + Send + Sync + 'static where @@ -97,7 +99,8 @@ where }) } -#[must_use] pub fn with_cookie_saver( +#[must_use] +pub fn with_cookie_saver( options: &CookiesConfig, ) -> impl Filter + Clone + Send + Sync + 'static { diff --git a/crates/core/src/filters/csrf.rs b/crates/core/src/filters/csrf.rs index 6d2b8153..b1fbe1f6 100644 --- a/crates/core/src/filters/csrf.rs +++ b/crates/core/src/filters/csrf.rs @@ -66,7 +66,8 @@ impl CsrfToken { } /// Get the value to include in HTML forms - #[must_use] pub fn form_value(&self) -> String { + #[must_use] + pub fn form_value(&self) -> String { BASE64URL_NOPAD.encode(&self.token[..]) } @@ -112,7 +113,8 @@ impl CsrfForm { } } -#[must_use] pub fn csrf_token( +#[must_use] +pub fn csrf_token( cookies_config: &CookiesConfig, ) -> impl Filter + Clone + Send + Sync + 'static { super::cookies::encrypted(cookies_config).and_then(move |token: CsrfToken| async move { @@ -121,7 +123,8 @@ impl CsrfForm { }) } -#[must_use] pub fn updated_csrf_token( +#[must_use] +pub fn updated_csrf_token( cookies_config: &CookiesConfig, csrf_config: &CsrfConfig, ) -> impl Filter + Clone + Send + Sync + 'static { @@ -144,7 +147,8 @@ impl CsrfForm { ) } -#[must_use] pub fn protected_form( +#[must_use] +pub fn protected_form( cookies_config: &CookiesConfig, ) -> impl Filter + Clone + Send + Sync + 'static where diff --git a/crates/core/src/filters/mod.rs b/crates/core/src/filters/mod.rs index ac51d00a..eceb18d6 100644 --- a/crates/core/src/filters/mod.rs +++ b/crates/core/src/filters/mod.rs @@ -33,14 +33,16 @@ use crate::{ templates::Templates, }; -#[must_use] pub fn with_templates( +#[must_use] +pub fn with_templates( templates: &Templates, ) -> impl Filter + Clone + Send + Sync + 'static { let templates = templates.clone(); warp::any().map(move || templates.clone()) } -#[must_use] pub fn with_keys( +#[must_use] +pub fn with_keys( oauth2_config: &OAuth2Config, ) -> impl Filter + Clone + Send + Sync + 'static { let keyset = oauth2_config.keys.clone(); diff --git a/crates/core/src/filters/session.rs b/crates/core/src/filters/session.rs index 9f58425a..2c02333f 100644 --- a/crates/core/src/filters/session.rs +++ b/crates/core/src/filters/session.rs @@ -32,7 +32,8 @@ pub struct SessionCookie { } impl SessionCookie { - #[must_use] pub fn from_session_info(info: &SessionInfo) -> Self { + #[must_use] + pub fn from_session_info(info: &SessionInfo) -> Self { Self { current: info.key(), } @@ -52,7 +53,8 @@ impl EncryptableCookieValue for SessionCookie { } } -#[must_use] pub fn with_optional_session( +#[must_use] +pub fn with_optional_session( pool: &PgPool, cookies_config: &CookiesConfig, ) -> impl Filter,), Error = Rejection> + Clone + Send + Sync + 'static @@ -71,7 +73,8 @@ impl EncryptableCookieValue for SessionCookie { ) } -#[must_use] pub fn with_session( +#[must_use] +pub fn with_session( pool: &PgPool, cookies_config: &CookiesConfig, ) -> impl Filter + Clone + Send + Sync + 'static { diff --git a/crates/core/src/handlers/mod.rs b/crates/core/src/handlers/mod.rs index edbb0bb5..fcc625c9 100644 --- a/crates/core/src/handlers/mod.rs +++ b/crates/core/src/handlers/mod.rs @@ -25,7 +25,8 @@ mod views; use self::{health::filter as health, oauth2::filter as oauth2, views::filter as views}; -#[must_use] pub fn root( +#[must_use] +pub fn root( pool: &PgPool, templates: &Templates, config: &RootConfig, diff --git a/crates/core/src/storage/oauth2/access_token.rs b/crates/core/src/storage/oauth2/access_token.rs index 29ed1137..fd0d737d 100644 --- a/crates/core/src/storage/oauth2/access_token.rs +++ b/crates/core/src/storage/oauth2/access_token.rs @@ -67,7 +67,8 @@ pub struct OAuth2AccessTokenLookup { } impl OAuth2AccessTokenLookup { - #[must_use] pub fn exp(&self) -> DateTime { + #[must_use] + pub fn exp(&self) -> DateTime { self.created_at + Duration::seconds(i64::from(self.expires_after)) } } diff --git a/crates/core/src/storage/oauth2/session.rs b/crates/core/src/storage/oauth2/session.rs index eea672ea..6ca6b905 100644 --- a/crates/core/src/storage/oauth2/session.rs +++ b/crates/core/src/storage/oauth2/session.rs @@ -103,7 +103,8 @@ impl OAuth2Session { } } - #[must_use] pub fn max_auth_time(&self) -> Option> { + #[must_use] + pub fn max_auth_time(&self) -> Option> { self.max_age .map(|d| Duration::seconds(i64::from(d))) .map(|d| self.created_at - d) diff --git a/crates/core/src/storage/user.rs b/crates/core/src/storage/user.rs index b5c71d19..f96482a6 100644 --- a/crates/core/src/storage/user.rs +++ b/crates/core/src/storage/user.rs @@ -44,7 +44,8 @@ pub struct SessionInfo { } impl SessionInfo { - #[must_use] pub fn key(&self) -> i64 { + #[must_use] + pub fn key(&self) -> i64 { self.id } diff --git a/crates/core/src/tasks/database.rs b/crates/core/src/tasks/database.rs index 4d3751c2..a1ff265e 100644 --- a/crates/core/src/tasks/database.rs +++ b/crates/core/src/tasks/database.rs @@ -38,6 +38,7 @@ impl Task for CleanupExpired { } } -#[must_use] pub fn cleanup_expired(pool: &Pool) -> impl Task + Clone { +#[must_use] +pub fn cleanup_expired(pool: &Pool) -> impl Task + Clone { CleanupExpired(pool.clone()) } diff --git a/crates/core/src/templates.rs b/crates/core/src/templates.rs index 49b00178..ff439ae9 100644 --- a/crates/core/src/templates.rs +++ b/crates/core/src/templates.rs @@ -212,7 +212,8 @@ pub struct IndexContext { } impl IndexContext { - #[must_use] pub fn new(discovery_url: Url) -> Self { + #[must_use] + pub fn new(discovery_url: Url) -> Self { Self { discovery_url } } } @@ -230,7 +231,8 @@ pub struct LoginContext { } impl LoginContext { - #[must_use] pub fn with_form_error(form: ErroredForm) -> Self { + #[must_use] + pub fn with_form_error(form: ErroredForm) -> Self { Self { form } } } @@ -267,22 +269,26 @@ pub struct ErrorContext { } impl ErrorContext { - #[must_use] pub fn new() -> Self { + #[must_use] + pub fn new() -> Self { Self::default() } - #[must_use] pub fn with_code(mut self, code: &'static str) -> Self { + #[must_use] + pub fn with_code(mut self, code: &'static str) -> Self { self.code = Some(code); self } - #[must_use] pub fn with_description(mut self, description: String) -> Self { + #[must_use] + pub fn with_description(mut self, description: String) -> Self { self.description = Some(description); self } #[allow(dead_code)] - #[must_use] pub fn with_details(mut self, details: String) -> Self { + #[must_use] + pub fn with_details(mut self, details: String) -> Self { self.details = Some(details); self }