refactor: resultify token::exists

This commit is contained in:
link2xt
2024-02-09 03:45:38 +00:00
parent 26ae686687
commit 0fcdee8857
4 changed files with 15 additions and 15 deletions

View File

@@ -103,15 +103,15 @@ pub async fn lookup_or_new(
token
}
pub async fn exists(context: &Context, namespace: Namespace, token: &str) -> bool {
context
pub async fn exists(context: &Context, namespace: Namespace, token: &str) -> Result<bool> {
let exists = context
.sql
.exists(
"SELECT COUNT(*) FROM tokens WHERE namespc=? AND token=?;",
(namespace, token),
)
.await
.unwrap_or_default()
.await?;
Ok(exists)
}
pub async fn delete(context: &Context, namespace: Namespace, token: &str) -> Result<()> {