You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-11-21 23:00:50 +03:00
Fix minor code style issues
This commit is contained in:
@@ -93,7 +93,8 @@ pub struct ErroredForm<FieldType> {
|
||||
}
|
||||
|
||||
impl<T> ErroredForm<T> {
|
||||
#[must_use] pub fn new() -> Self {
|
||||
#[must_use]
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
form: Vec::new(),
|
||||
fields: Vec::new(),
|
||||
|
||||
@@ -69,7 +69,8 @@ impl EncryptedCookie {
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use] pub fn maybe_encrypted<T>(
|
||||
#[must_use]
|
||||
pub fn maybe_encrypted<T>(
|
||||
options: &CookiesConfig,
|
||||
) -> impl Filter<Extract = (Option<T>,), Error = Infallible> + Clone + Send + Sync + 'static
|
||||
where
|
||||
@@ -83,7 +84,8 @@ where
|
||||
})
|
||||
}
|
||||
|
||||
#[must_use] pub fn encrypted<T>(
|
||||
#[must_use]
|
||||
pub fn encrypted<T>(
|
||||
options: &CookiesConfig,
|
||||
) -> impl Filter<Extract = (T,), Error = Rejection> + 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<Extract = (EncryptedCookieSaver,), Error = Infallible> + Clone + Send + Sync + 'static
|
||||
{
|
||||
|
||||
@@ -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<T> CsrfForm<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use] pub fn csrf_token(
|
||||
#[must_use]
|
||||
pub fn csrf_token(
|
||||
cookies_config: &CookiesConfig,
|
||||
) -> impl Filter<Extract = (CsrfToken,), Error = Rejection> + Clone + Send + Sync + 'static {
|
||||
super::cookies::encrypted(cookies_config).and_then(move |token: CsrfToken| async move {
|
||||
@@ -121,7 +123,8 @@ impl<T> CsrfForm<T> {
|
||||
})
|
||||
}
|
||||
|
||||
#[must_use] pub fn updated_csrf_token(
|
||||
#[must_use]
|
||||
pub fn updated_csrf_token(
|
||||
cookies_config: &CookiesConfig,
|
||||
csrf_config: &CsrfConfig,
|
||||
) -> impl Filter<Extract = (CsrfToken,), Error = Rejection> + Clone + Send + Sync + 'static {
|
||||
@@ -144,7 +147,8 @@ impl<T> CsrfForm<T> {
|
||||
)
|
||||
}
|
||||
|
||||
#[must_use] pub fn protected_form<T>(
|
||||
#[must_use]
|
||||
pub fn protected_form<T>(
|
||||
cookies_config: &CookiesConfig,
|
||||
) -> impl Filter<Extract = (T,), Error = Rejection> + Clone + Send + Sync + 'static
|
||||
where
|
||||
|
||||
@@ -33,14 +33,16 @@ use crate::{
|
||||
templates::Templates,
|
||||
};
|
||||
|
||||
#[must_use] pub fn with_templates(
|
||||
#[must_use]
|
||||
pub fn with_templates(
|
||||
templates: &Templates,
|
||||
) -> impl Filter<Extract = (Templates,), Error = Infallible> + 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<Extract = (KeySet,), Error = Infallible> + Clone + Send + Sync + 'static {
|
||||
let keyset = oauth2_config.keys.clone();
|
||||
|
||||
@@ -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<Extract = (Option<SessionInfo>,), 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<Extract = (SessionInfo,), Error = Rejection> + Clone + Send + Sync + 'static {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -67,7 +67,8 @@ pub struct OAuth2AccessTokenLookup {
|
||||
}
|
||||
|
||||
impl OAuth2AccessTokenLookup {
|
||||
#[must_use] pub fn exp(&self) -> DateTime<Utc> {
|
||||
#[must_use]
|
||||
pub fn exp(&self) -> DateTime<Utc> {
|
||||
self.created_at + Duration::seconds(i64::from(self.expires_after))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,8 @@ impl OAuth2Session {
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use] pub fn max_auth_time(&self) -> Option<DateTime<Utc>> {
|
||||
#[must_use]
|
||||
pub fn max_auth_time(&self) -> Option<DateTime<Utc>> {
|
||||
self.max_age
|
||||
.map(|d| Duration::seconds(i64::from(d)))
|
||||
.map(|d| self.created_at - d)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ impl Task for CleanupExpired {
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use] pub fn cleanup_expired(pool: &Pool<Postgres>) -> impl Task + Clone {
|
||||
#[must_use]
|
||||
pub fn cleanup_expired(pool: &Pool<Postgres>) -> impl Task + Clone {
|
||||
CleanupExpired(pool.clone())
|
||||
}
|
||||
|
||||
@@ -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<LoginFormField>) -> Self {
|
||||
#[must_use]
|
||||
pub fn with_form_error(form: ErroredForm<LoginFormField>) -> 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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user