mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Comments and rustfmt
This commit is contained in:
parent
a3c9a76f1d
commit
ff894f6ff6
1 changed files with 6 additions and 10 deletions
|
@ -34,6 +34,7 @@ impl ToSql for StoredUuid {
|
|||
/// Wraps [`TaskMap`] (type alias for HashMap) so we can implement rusqlite conversion traits for it
|
||||
struct StoredTaskMap(TaskMap);
|
||||
|
||||
/// Parses TaskMap stored as JSON in string column
|
||||
impl FromSql for StoredTaskMap {
|
||||
fn column_result(value: rusqlite::types::ValueRef<'_>) -> rusqlite::types::FromSqlResult<Self> {
|
||||
let o: TaskMap = serde_json::from_str(value.as_str()?)
|
||||
|
@ -42,6 +43,7 @@ impl FromSql for StoredTaskMap {
|
|||
}
|
||||
}
|
||||
|
||||
/// Stores TaskMap in string column
|
||||
impl ToSql for StoredTaskMap {
|
||||
fn to_sql(&self) -> rusqlite::Result<rusqlite::types::ToSqlOutput<'_>> {
|
||||
let s = serde_json::to_string(&self.0)
|
||||
|
@ -50,7 +52,6 @@ impl ToSql for StoredTaskMap {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// Stores [`Operation`] in SQLite
|
||||
impl FromSql for Operation {
|
||||
fn column_result(value: rusqlite::types::ValueRef<'_>) -> rusqlite::types::FromSqlResult<Self> {
|
||||
|
@ -60,6 +61,7 @@ impl FromSql for Operation {
|
|||
}
|
||||
}
|
||||
|
||||
/// Parsers Operation stored as JSON in string column
|
||||
impl ToSql for Operation {
|
||||
fn to_sql(&self) -> rusqlite::Result<rusqlite::types::ToSqlOutput<'_>> {
|
||||
let s = serde_json::to_string(&self)
|
||||
|
@ -68,7 +70,6 @@ impl ToSql for Operation {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// SqliteStorage is an on-disk storage backed by SQLite3.
|
||||
pub struct SqliteStorage {
|
||||
con: Connection,
|
||||
|
@ -220,9 +221,7 @@ impl<'t> StorageTxn for Txn<'t> {
|
|||
|r| r.get("value"),
|
||||
)
|
||||
.optional()?;
|
||||
Ok(version
|
||||
.map(|u| u.0)
|
||||
.unwrap_or(DEFAULT_BASE_VERSION))
|
||||
Ok(version.map(|u| u.0).unwrap_or(DEFAULT_BASE_VERSION))
|
||||
}
|
||||
|
||||
fn set_base_version(&mut self, version: VersionId) -> anyhow::Result<()> {
|
||||
|
@ -254,11 +253,8 @@ impl<'t> StorageTxn for Txn<'t> {
|
|||
fn add_operation(&mut self, op: Operation) -> anyhow::Result<()> {
|
||||
let t = self.get_txn()?;
|
||||
|
||||
t.execute(
|
||||
"INSERT INTO operations (data) VALUES (?)",
|
||||
params![&op],
|
||||
)
|
||||
.context("Add operation query")?;
|
||||
t.execute("INSERT INTO operations (data) VALUES (?)", params![&op])
|
||||
.context("Add operation query")?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue