You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-11-20 12:02:22 +03:00
Enable clippy lints on a workspace level
This enables a lot more lints than before in some crates, so this fixed a lot of warnings as well.
This commit is contained in:
@@ -37,6 +37,14 @@ pub enum UpstreamOAuthAuthorizationSessionState {
|
||||
}
|
||||
|
||||
impl UpstreamOAuthAuthorizationSessionState {
|
||||
/// Mark the upstream OAuth 2.0 authorization session as completed.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Returns an error if the upstream OAuth 2.0 authorization session state
|
||||
/// is not [`Pending`].
|
||||
///
|
||||
/// [`Pending`]: UpstreamOAuthAuthorizationSessionState::Pending
|
||||
pub fn complete(
|
||||
self,
|
||||
completed_at: DateTime<Utc>,
|
||||
@@ -53,6 +61,14 @@ impl UpstreamOAuthAuthorizationSessionState {
|
||||
}
|
||||
}
|
||||
|
||||
/// Mark the upstream OAuth 2.0 authorization session as consumed.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Returns an error if the upstream OAuth 2.0 authorization session state
|
||||
/// is not [`Completed`].
|
||||
///
|
||||
/// [`Completed`]: UpstreamOAuthAuthorizationSessionState::Completed
|
||||
pub fn consume(self, consumed_at: DateTime<Utc>) -> Result<Self, InvalidTransitionError> {
|
||||
match self {
|
||||
Self::Completed {
|
||||
@@ -69,6 +85,12 @@ impl UpstreamOAuthAuthorizationSessionState {
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the link ID for the upstream OAuth 2.0 authorization session.
|
||||
///
|
||||
/// Returns `None` if the upstream OAuth 2.0 authorization session state is
|
||||
/// [`Pending`].
|
||||
///
|
||||
/// [`Pending`]: UpstreamOAuthAuthorizationSessionState::Pending
|
||||
#[must_use]
|
||||
pub fn link_id(&self) -> Option<Ulid> {
|
||||
match self {
|
||||
@@ -77,6 +99,13 @@ impl UpstreamOAuthAuthorizationSessionState {
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the time at which the upstream OAuth 2.0 authorization session was
|
||||
/// completed.
|
||||
///
|
||||
/// Returns `None` if the upstream OAuth 2.0 authorization session state is
|
||||
/// [`Pending`].
|
||||
///
|
||||
/// [`Pending`]: UpstreamOAuthAuthorizationSessionState::Pending
|
||||
#[must_use]
|
||||
pub fn completed_at(&self) -> Option<DateTime<Utc>> {
|
||||
match self {
|
||||
@@ -87,6 +116,12 @@ impl UpstreamOAuthAuthorizationSessionState {
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the ID token for the upstream OAuth 2.0 authorization session.
|
||||
///
|
||||
/// Returns `None` if the upstream OAuth 2.0 authorization session state is
|
||||
/// [`Pending`].
|
||||
///
|
||||
/// [`Pending`]: UpstreamOAuthAuthorizationSessionState::Pending
|
||||
#[must_use]
|
||||
pub fn id_token(&self) -> Option<&str> {
|
||||
match self {
|
||||
@@ -97,6 +132,13 @@ impl UpstreamOAuthAuthorizationSessionState {
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the time at which the upstream OAuth 2.0 authorization session was
|
||||
/// consumed.
|
||||
///
|
||||
/// Returns `None` if the upstream OAuth 2.0 authorization session state is
|
||||
/// not [`Consumed`].
|
||||
///
|
||||
/// [`Consumed`]: UpstreamOAuthAuthorizationSessionState::Consumed
|
||||
#[must_use]
|
||||
pub fn consumed_at(&self) -> Option<DateTime<Utc>> {
|
||||
match self {
|
||||
@@ -105,7 +147,7 @@ impl UpstreamOAuthAuthorizationSessionState {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if the upstream oauth authorization session state is
|
||||
/// Returns `true` if the upstream OAuth 2.0 authorization session state is
|
||||
/// [`Pending`].
|
||||
///
|
||||
/// [`Pending`]: UpstreamOAuthAuthorizationSessionState::Pending
|
||||
@@ -114,7 +156,7 @@ impl UpstreamOAuthAuthorizationSessionState {
|
||||
matches!(self, Self::Pending)
|
||||
}
|
||||
|
||||
/// Returns `true` if the upstream oauth authorization session state is
|
||||
/// Returns `true` if the upstream OAuth 2.0 authorization session state is
|
||||
/// [`Completed`].
|
||||
///
|
||||
/// [`Completed`]: UpstreamOAuthAuthorizationSessionState::Completed
|
||||
@@ -123,7 +165,7 @@ impl UpstreamOAuthAuthorizationSessionState {
|
||||
matches!(self, Self::Completed { .. })
|
||||
}
|
||||
|
||||
/// Returns `true` if the upstream oauth authorization session state is
|
||||
/// Returns `true` if the upstream OAuth 2.0 authorization session state is
|
||||
/// [`Consumed`].
|
||||
///
|
||||
/// [`Consumed`]: UpstreamOAuthAuthorizationSessionState::Consumed
|
||||
@@ -153,6 +195,15 @@ impl std::ops::Deref for UpstreamOAuthAuthorizationSession {
|
||||
}
|
||||
|
||||
impl UpstreamOAuthAuthorizationSession {
|
||||
/// Mark the upstream OAuth 2.0 authorization session as completed. Returns
|
||||
/// the updated session.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Returns an error if the upstream OAuth 2.0 authorization session state
|
||||
/// is not [`Pending`].
|
||||
///
|
||||
/// [`Pending`]: UpstreamOAuthAuthorizationSessionState::Pending
|
||||
pub fn complete(
|
||||
mut self,
|
||||
completed_at: DateTime<Utc>,
|
||||
@@ -163,6 +214,15 @@ impl UpstreamOAuthAuthorizationSession {
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
/// Mark the upstream OAuth 2.0 authorization session as consumed. Returns
|
||||
/// the updated session.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Returns an error if the upstream OAuth 2.0 authorization session state
|
||||
/// is not [`Completed`].
|
||||
///
|
||||
/// [`Completed`]: UpstreamOAuthAuthorizationSessionState::Completed
|
||||
pub fn consume(mut self, consumed_at: DateTime<Utc>) -> Result<Self, InvalidTransitionError> {
|
||||
self.state = self.state.consume(consumed_at)?;
|
||||
Ok(self)
|
||||
|
||||
Reference in New Issue
Block a user