Skip to main content

bsv_wallet_toolbox/
types.rs

1//! Shared types used across wallet toolbox subsystems.
2//!
3//! Contains small enum and struct types that are referenced by multiple modules.
4//! Kept minimal -- only types needed by status.rs and table structs.
5
6use serde::{Deserialize, Serialize};
7use strum::{Display, EnumString};
8
9/// The BSV network chain type.
10#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Display, EnumString)]
11#[serde(rename_all = "camelCase")]
12#[strum(serialize_all = "camelCase")]
13pub enum Chain {
14    /// BSV mainnet
15    Main,
16    /// BSV testnet
17    Test,
18}
19
20/// Indicates who provides the storage backend.
21#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Display, EnumString)]
22#[serde(rename_all = "camelCase")]
23#[strum(serialize_all = "camelCase")]
24pub enum StorageProvidedBy {
25    /// Storage is provided by the service
26    Storage,
27    /// Storage is provided by the caller
28    You,
29    /// Both the caller and storage contributed (e.g., user specifies inputs, storage allocates change)
30    #[serde(rename = "you-and-storage")]
31    #[strum(serialize = "you-and-storage")]
32    YouAndStorage,
33}
34
35#[cfg(any(feature = "sqlite", feature = "mysql", feature = "postgres"))]
36impl_sqlx_string_enum!(Chain);
37#[cfg(any(feature = "sqlite", feature = "mysql", feature = "postgres"))]
38impl_sqlx_string_enum!(StorageProvidedBy);