pub mod action_traits;
pub mod action_types;
pub mod beef;
pub mod find_args;
pub mod manager;
pub mod methods;
pub mod remoting;
pub mod sqlx_impl;
pub mod sync;
pub mod traits;
pub use find_args::*;
pub use manager::WalletStorageManager;
pub use remoting::StorageClient;
pub use sqlx_impl::trx_token::TrxToken;
pub use traits::{StorageProvider, StorageReader, StorageReaderWriter, WalletStorageProvider};
use crate::error::{WalletError, WalletResult};
use std::time::Duration;
#[derive(Debug, Clone)]
pub struct StorageConfig {
pub url: String,
pub sqlite_read_connections: u32,
pub min_connections: u32,
pub max_connections: u32,
pub idle_timeout: Duration,
pub connect_timeout: Duration,
}
impl Default for StorageConfig {
fn default() -> Self {
Self {
url: String::from("sqlite::memory:"),
sqlite_read_connections: 4,
min_connections: 2,
max_connections: 50,
idle_timeout: Duration::from_secs(600), connect_timeout: Duration::from_secs(5),
}
}
}
pub fn verify_one_or_none<T>(mut results: Vec<T>) -> WalletResult<Option<T>> {
if results.len() > 1 {
return Err(WalletError::Internal(format!(
"Expected at most one result, got {}",
results.len()
)));
}
Ok(results.pop())
}
pub fn verify_one<T>(mut results: Vec<T>) -> WalletResult<T> {
if results.len() != 1 {
return Err(WalletError::Internal(format!(
"Expected exactly one result, got {}",
results.len()
)));
}
Ok(results.pop().unwrap())
}