rustfmt config + format stable files
This commit is contained in:
parent
1742f768bf
commit
78c23531ab
6
rustfmt.toml
Normal file
6
rustfmt.toml
Normal file
|
@ -0,0 +1,6 @@
|
|||
edition = "2021"
|
||||
newline_style = "Unix"
|
||||
match_block_trailing_comma = true
|
||||
fn_params_layout = "Compressed"
|
||||
use_field_init_shorthand = true
|
||||
use_small_heuristics = "Max"
|
|
@ -1,7 +1,7 @@
|
|||
use rusqlite::{Connection, Result, params};
|
||||
use std::ops::Index;
|
||||
use rusqlite::{params, Connection, Result};
|
||||
use std::cell::Cell;
|
||||
use std::collections::HashSet;
|
||||
use std::ops::Index;
|
||||
|
||||
/// Simple SQLite-backed key/value store.
|
||||
///
|
||||
|
@ -27,7 +27,7 @@ impl KeyValueStore {
|
|||
)",
|
||||
[],
|
||||
)?;
|
||||
Ok(Self { conn, has_write_errors: Cell::new(false), })
|
||||
Ok(Self { conn, has_write_errors: Cell::new(false) })
|
||||
}
|
||||
|
||||
/// Report if any write errors occurred.
|
||||
|
@ -53,11 +53,13 @@ impl KeyValueStore {
|
|||
/// Will panic on error. (The idea is to call this a bunch of times at boot,
|
||||
/// to populate the DB if missing / newly created, and not use it after.)
|
||||
pub fn default(&self, key: &str, value: &str) {
|
||||
self.conn.execute(
|
||||
self.conn
|
||||
.execute(
|
||||
"INSERT INTO kv_store (key, value) VALUES (?1, ?2)
|
||||
ON CONFLICT(key) DO NOTHING",
|
||||
params![key, value],
|
||||
).expect(&format!("Failed to write default at key: {}", key));
|
||||
)
|
||||
.expect(&format!("Failed to write default at key: {}", key));
|
||||
}
|
||||
|
||||
/// Write a `key`/`value` pair to the DB.
|
||||
|
@ -74,7 +76,7 @@ impl KeyValueStore {
|
|||
eprintln!("Failed DB write: ({}, {})", key, value);
|
||||
self.has_write_errors.set(true);
|
||||
Err(e)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +90,7 @@ impl KeyValueStore {
|
|||
eprintln!("Failed DB write: ({}, NULL)", key);
|
||||
self.has_write_errors.set(true);
|
||||
Err(e)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue