mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-08-14 17:35:57 -04:00
Replace .unwrap() with ? operator
This commit is contained in:
parent
c2c607efac
commit
ac8bbe9a83
4 changed files with 88 additions and 96 deletions
|
@ -63,11 +63,11 @@ impl VeilidTableDB {
|
|||
/// Read a key from a column in the TableDB immediately.
|
||||
pub async fn load(&mut self, columnId: u32, key: String) -> APIResult<Option<String>> {
|
||||
self.ensureOpen().await;
|
||||
let key = unmarshall(key);
|
||||
let key = unmarshall(key)?;
|
||||
let table_db = self.getTableDB()?;
|
||||
|
||||
let out = table_db.load(columnId, &key).await?.unwrap();
|
||||
let out = Some(marshall(&out));
|
||||
let out = table_db.load(columnId, &key).await?;
|
||||
let out = out.map(|out| marshall(&out));
|
||||
APIResult::Ok(out)
|
||||
}
|
||||
|
||||
|
@ -75,8 +75,8 @@ impl VeilidTableDB {
|
|||
/// Performs a single transaction immediately.
|
||||
pub async fn store(&mut self, columnId: u32, key: String, value: String) -> APIResult<()> {
|
||||
self.ensureOpen().await;
|
||||
let key = unmarshall(key);
|
||||
let value = unmarshall(value);
|
||||
let key = unmarshall(key)?;
|
||||
let value = unmarshall(value)?;
|
||||
let table_db = self.getTableDB()?;
|
||||
|
||||
table_db.store(columnId, &key, &value).await?;
|
||||
|
@ -86,11 +86,11 @@ impl VeilidTableDB {
|
|||
/// Delete key with from a column in the TableDB.
|
||||
pub async fn delete(&mut self, columnId: u32, key: String) -> APIResult<Option<String>> {
|
||||
self.ensureOpen().await;
|
||||
let key = unmarshall(key);
|
||||
let key = unmarshall(key)?;
|
||||
let table_db = self.getTableDB()?;
|
||||
|
||||
let out = table_db.delete(columnId, &key).await?.unwrap();
|
||||
let out = Some(marshall(&out));
|
||||
let out = table_db.delete(columnId, &key).await?;
|
||||
let out = out.map(|out| marshall(&out));
|
||||
APIResult::Ok(out)
|
||||
}
|
||||
|
||||
|
@ -161,15 +161,15 @@ impl VeilidTableDBTransaction {
|
|||
/// Store a key with a value in a column in the TableDB.
|
||||
/// Does not modify TableDB until `.commit()` is called.
|
||||
pub fn store(&self, col: u32, key: String, value: String) -> APIResult<()> {
|
||||
let key = unmarshall(key);
|
||||
let value = unmarshall(value);
|
||||
let key = unmarshall(key)?;
|
||||
let value = unmarshall(value)?;
|
||||
let transaction = self.getTransaction()?;
|
||||
transaction.store(col, &key, &value)
|
||||
}
|
||||
|
||||
/// Delete key with from a column in the TableDB
|
||||
pub fn deleteKey(&self, col: u32, key: String) -> APIResult<()> {
|
||||
let key = unmarshall(key);
|
||||
let key = unmarshall(key)?;
|
||||
let transaction = self.getTransaction()?;
|
||||
transaction.delete(col, &key)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue