add http-client
This commit is contained in:
parent
ac2904588c
commit
8bcd555d71
36 changed files with 1978 additions and 49 deletions
8
http-lib/Cargo.toml
Normal file
8
http-lib/Cargo.toml
Normal file
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "http-lib"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
bank = { path = "../bank" }
|
||||
serde = { version = "1.0.136", features = ["derive"] }
|
32
http-lib/src/json_account.rs
Normal file
32
http-lib/src/json_account.rs
Normal file
|
@ -0,0 +1,32 @@
|
|||
use bank::account::Account;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug, Clone)]
|
||||
pub struct JsonAccount {
|
||||
pub number: String,
|
||||
pub owner: String,
|
||||
pub balance: f64,
|
||||
pub is_active: bool,
|
||||
}
|
||||
|
||||
impl From<&Account> for JsonAccount {
|
||||
fn from(a: &Account) -> Self {
|
||||
JsonAccount {
|
||||
number: a.number.clone(),
|
||||
owner: a.owner.clone(),
|
||||
balance: a.balance,
|
||||
is_active: a.is_active,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<JsonAccount> for Account {
|
||||
fn from(a: JsonAccount) -> Self {
|
||||
Account {
|
||||
number: a.number.clone(),
|
||||
owner: a.owner.clone(),
|
||||
balance: a.balance,
|
||||
is_active: a.is_active,
|
||||
}
|
||||
}
|
||||
}
|
1
http-lib/src/lib.rs
Normal file
1
http-lib/src/lib.rs
Normal file
|
@ -0,0 +1 @@
|
|||
pub mod json_account;
|
Loading…
Add table
Add a link
Reference in a new issue