mirror of
https://github.com/aljazceru/cdk.git
synced 2025-12-20 06:05:09 +01:00
chore: readmes
chore: doc comments on public
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
//! SQLite storage backend for cdk
|
||||
|
||||
#![warn(missing_docs)]
|
||||
#![warn(rustdoc::bare_urls)]
|
||||
|
||||
#[cfg(feature = "mint")]
|
||||
pub mod mint;
|
||||
#[cfg(feature = "wallet")]
|
||||
@@ -6,4 +11,4 @@ pub mod wallet;
|
||||
#[cfg(feature = "mint")]
|
||||
pub use mint::MintSqliteDatabase;
|
||||
#[cfg(feature = "wallet")]
|
||||
pub use wallet::WalletSQLiteDatabase;
|
||||
pub use wallet::WalletSqliteDatabase;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
//! SQLite Database Error
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
/// SQLite Database Error
|
||||
#[derive(Debug, Error)]
|
||||
pub enum Error {
|
||||
/// SQLX Error
|
||||
|
||||
@@ -21,12 +21,14 @@ use sqlx::{ConnectOptions, Row};
|
||||
|
||||
pub mod error;
|
||||
|
||||
/// Mint SQLite Database
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct MintSqliteDatabase {
|
||||
pool: SqlitePool,
|
||||
}
|
||||
|
||||
impl MintSqliteDatabase {
|
||||
/// Create new [`MintSqliteDatabase`]
|
||||
pub async fn new(path: &Path) -> Result<Self, Error> {
|
||||
let path = path.to_str().ok_or(Error::InvalidDbPath)?;
|
||||
let _conn = SqliteConnectOptions::from_str(path)?
|
||||
@@ -42,6 +44,7 @@ impl MintSqliteDatabase {
|
||||
Ok(Self { pool })
|
||||
}
|
||||
|
||||
/// Migrate [`MintSqliteDatabase`]
|
||||
pub async fn migrate(&self) {
|
||||
sqlx::migrate!("./src/mint/migrations")
|
||||
.run(&self.pool)
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
//! SQLite Wallet Error
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
/// SQLite Wallet Error
|
||||
#[derive(Debug, Error)]
|
||||
pub enum Error {
|
||||
/// SQLX Error
|
||||
|
||||
@@ -20,12 +20,14 @@ use sqlx::{ConnectOptions, Row};
|
||||
|
||||
pub mod error;
|
||||
|
||||
/// Wallet SQLite Database
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct WalletSQLiteDatabase {
|
||||
pub struct WalletSqliteDatabase {
|
||||
pool: SqlitePool,
|
||||
}
|
||||
|
||||
impl WalletSQLiteDatabase {
|
||||
impl WalletSqliteDatabase {
|
||||
/// Create new [`WalletSqliteDatabase`]
|
||||
pub async fn new(path: &Path) -> Result<Self, Error> {
|
||||
let path = path.to_str().ok_or(Error::InvalidDbPath)?;
|
||||
let _conn = SqliteConnectOptions::from_str(path)?
|
||||
@@ -41,6 +43,7 @@ impl WalletSQLiteDatabase {
|
||||
Ok(Self { pool })
|
||||
}
|
||||
|
||||
/// Migrate [`WalletSqliteDatabase`]
|
||||
pub async fn migrate(&self) {
|
||||
sqlx::migrate!("./src/wallet/migrations")
|
||||
.run(&self.pool)
|
||||
@@ -50,7 +53,7 @@ impl WalletSQLiteDatabase {
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl WalletDatabase for WalletSQLiteDatabase {
|
||||
impl WalletDatabase for WalletSqliteDatabase {
|
||||
type Err = cdk_database::Error;
|
||||
|
||||
async fn add_mint(
|
||||
|
||||
Reference in New Issue
Block a user