mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-08-06 05:24:42 -04:00
Create Database trait
Use domain types in database API to prevent leaking of database types. This trait will allow us to smoothly introduce the sqlite database.
This commit is contained in:
parent
a94c320021
commit
da9d09aa5e
21 changed files with 351 additions and 253 deletions
|
@ -2,6 +2,7 @@ pub use self::sled::SledDatabase;
|
|||
pub use alice::Alice;
|
||||
pub use bob::Bob;
|
||||
|
||||
use crate::protocol::State;
|
||||
use anyhow::{bail, Result};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt::Display;
|
||||
|
@ -16,6 +17,24 @@ pub enum Swap {
|
|||
Bob(Bob),
|
||||
}
|
||||
|
||||
impl From<State> for Swap {
|
||||
fn from(state: State) -> Self {
|
||||
match state {
|
||||
State::Alice(state) => Swap::Alice(state.into()),
|
||||
State::Bob(state) => Swap::Bob(state.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Swap> for State {
|
||||
fn from(value: Swap) -> Self {
|
||||
match value {
|
||||
Swap::Alice(alice) => State::Alice(alice.into()),
|
||||
Swap::Bob(bob) => State::Bob(bob.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Alice> for Swap {
|
||||
fn from(from: Alice) -> Self {
|
||||
Swap::Alice(from)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue