chore: readmes

chore: doc comments on public
This commit is contained in:
thesimplekid
2024-06-28 10:40:09 +01:00
parent aa65879482
commit b528964fb6
54 changed files with 598 additions and 109 deletions

View File

@@ -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;

View File

@@ -1,5 +1,8 @@
//! SQLite Database Error
use thiserror::Error;
/// SQLite Database Error
#[derive(Debug, Error)]
pub enum Error {
/// SQLX Error

View File

@@ -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)

View File

@@ -1,5 +1,8 @@
//! SQLite Wallet Error
use thiserror::Error;
/// SQLite Wallet Error
#[derive(Debug, Error)]
pub enum Error {
/// SQLX Error

View File

@@ -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(