File tree Expand file tree Collapse file tree 3 files changed +13
-7
lines changed
Expand file tree Collapse file tree 3 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ use chrono::{DateTime, Utc};
88use sqlx:: postgres:: PgPoolOptions ;
99use sqlx:: { PgPool , Postgres } ;
1010use std:: fmt:: { self , Debug , Formatter } ;
11+ use std:: str:: FromStr ;
1112
1213pub struct PostgresCatalogManager {
1314 backend : CatalogBackend < Postgres > ,
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ use async_trait::async_trait;
77use chrono:: Utc ;
88use sqlx:: { Sqlite , SqlitePool } ;
99use std:: fmt:: { self , Debug , Formatter } ;
10+ use std:: str:: FromStr ;
1011
1112pub struct SqliteCatalogManager {
1213 backend : CatalogBackend < Sqlite > ,
Original file line number Diff line number Diff 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.
You can’t perform that action at this time.
0 commit comments