Skip to content

Commit 89c8f99

Browse files
committed
clippy fixes
1 parent 5af3365 commit 89c8f99

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

src/catalog/postgres_manager.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use chrono::{DateTime, Utc};
88
use sqlx::postgres::PgPoolOptions;
99
use sqlx::{PgPool, Postgres};
1010
use std::fmt::{self, Debug, Formatter};
11+
use std::str::FromStr;
1112

1213
pub struct PostgresCatalogManager {
1314
backend: CatalogBackend<Postgres>,

src/catalog/sqlite_manager.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use async_trait::async_trait;
77
use chrono::Utc;
88
use sqlx::{Sqlite, SqlitePool};
99
use std::fmt::{self, Debug, Formatter};
10+
use std::str::FromStr;
1011

1112
pub struct SqliteCatalogManager {
1213
backend: CatalogBackend<Sqlite>,

src/secrets/mod.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,17 @@ impl SecretStatus {
3636
SecretStatus::PendingDelete => "pending_delete",
3737
}
3838
}
39+
}
40+
41+
impl std::str::FromStr for SecretStatus {
42+
type Err = ();
3943

40-
pub fn from_str(s: &str) -> Option<Self> {
44+
fn from_str(s: &str) -> Result<Self, Self::Err> {
4145
match s {
42-
"creating" => Some(SecretStatus::Creating),
43-
"active" => Some(SecretStatus::Active),
44-
"pending_delete" => Some(SecretStatus::PendingDelete),
45-
_ => None,
46+
"creating" => Ok(SecretStatus::Creating),
47+
"active" => Ok(SecretStatus::Active),
48+
"pending_delete" => Ok(SecretStatus::PendingDelete),
49+
_ => Err(()),
4650
}
4751
}
4852
}
@@ -162,7 +166,7 @@ impl SecretManager {
162166
.backend
163167
.get(&record)
164168
.await?
165-
.ok_or_else(|| SecretError::NotFound(normalized))?;
169+
.ok_or(SecretError::NotFound(normalized))?;
166170

167171
Ok(read.value)
168172
}
@@ -181,7 +185,7 @@ impl SecretManager {
181185
.get_secret_metadata(&normalized)
182186
.await
183187
.map_err(|e| SecretError::Database(e.to_string()))?
184-
.ok_or_else(|| SecretError::NotFound(normalized))
188+
.ok_or(SecretError::NotFound(normalized))
185189
}
186190

187191
/// Create a new secret.

0 commit comments

Comments
 (0)