chore: remove unused traits

This commit is contained in:
kaichaosun 2026-01-30 12:24:34 +08:00
parent c6013809cc
commit 9513b24f20
No known key found for this signature in database
GPG Key ID: 223E0F992F4F03BF
3 changed files with 3 additions and 35 deletions

View File

@ -2,7 +2,7 @@
use std::collections::HashSet;
use storage::{SqliteDb, StorageBackend, StorageError, params};
use storage::{SqliteDb, StorageError, params};
use super::types::RatchetStateRecord;
use crate::{
@ -62,7 +62,7 @@ impl RatchetStorage {
/// Creates a new ratchet storage with the given database.
fn run_migration(db: SqliteDb) -> Result<Self, StorageError> {
// Initialize schema
db.execute_batch(RATCHET_SCHEMA)?;
db.connection().execute_batch(RATCHET_SCHEMA)?;
Ok(Self { db })
}

View File

@ -13,23 +13,3 @@ pub use sqlite::{SqliteDb, StorageConfig};
// Re-export rusqlite types that domain crates will need
pub use rusqlite::{Error as RusqliteError, Transaction, params};
/// Trait for types that can be stored and retrieved.
///
/// Implement this trait for domain-specific storage operations.
pub trait Storable: Sized {
/// The key type used to identify records.
type Key;
/// The error type returned by storage operations.
type Error: From<StorageError>;
}
/// Trait for storage backends.
pub trait StorageBackend {
/// Initialize the storage (e.g., create tables).
fn init(&self) -> Result<(), StorageError>;
/// Execute a batch of SQL statements (for schema migrations).
fn execute_batch(&self, sql: &str) -> Result<(), StorageError>;
}

View File

@ -3,7 +3,7 @@
use rusqlite::Connection;
use std::path::Path;
use crate::{StorageBackend, StorageError};
use crate::StorageError;
/// Configuration for SQLite storage.
#[derive(Debug, Clone)]
@ -81,15 +81,3 @@ impl SqliteDb {
Ok(self.conn.transaction()?)
}
}
impl StorageBackend for SqliteDb {
fn init(&self) -> Result<(), StorageError> {
// Base initialization is done in new()
Ok(())
}
fn execute_batch(&self, sql: &str) -> Result<(), StorageError> {
self.conn.execute_batch(sql)?;
Ok(())
}
}