mirror of
https://github.com/logos-messaging/libchat.git
synced 2026-02-10 00:43:09 +00:00
chore: remove unused traits
This commit is contained in:
parent
c6013809cc
commit
9513b24f20
@ -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 })
|
||||
}
|
||||
|
||||
|
||||
@ -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>;
|
||||
}
|
||||
|
||||
@ -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(())
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user