clippy pedantic clean + wired into flake checks

This commit is contained in:
müde 2026-05-14 22:57:47 +02:00
parent f12837fe32
commit fef2dee92a
12 changed files with 55 additions and 25 deletions

View file

@ -8,7 +8,7 @@ use anyhow::{Context, Result};
use hive_sh4re::Message;
use rusqlite::{Connection, OptionalExtension, params};
const SCHEMA: &str = r#"
const SCHEMA: &str = r"
CREATE TABLE IF NOT EXISTS messages (
id INTEGER PRIMARY KEY AUTOINCREMENT,
sender TEXT NOT NULL,
@ -19,7 +19,7 @@ CREATE TABLE IF NOT EXISTS messages (
);
CREATE INDEX IF NOT EXISTS idx_messages_undelivered
ON messages (recipient, id) WHERE delivered_at IS NULL;
"#;
";
pub struct Broker {
conn: Mutex<Connection>,
@ -39,7 +39,7 @@ impl Broker {
})
}
pub fn send(&self, message: Message) -> Result<()> {
pub fn send(&self, message: &Message) -> Result<()> {
let conn = self.conn.lock().unwrap();
conn.execute(
"INSERT INTO messages (sender, recipient, body, sent_at) VALUES (?1, ?2, ?3, ?4)",
@ -75,6 +75,7 @@ impl Broker {
fn now_unix() -> i64 {
SystemTime::now()
.duration_since(UNIX_EPOCH)
.map(|d| d.as_secs() as i64)
.ok()
.and_then(|d| i64::try_from(d.as_secs()).ok())
.unwrap_or(0)
}