add http-client

This commit is contained in:
Sebastian Hugentobler 2022-03-25 19:18:55 +01:00
parent ac2904588c
commit 8bcd555d71
36 changed files with 1978 additions and 49 deletions

8
http-lib/Cargo.toml Normal file
View 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"] }

View 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
View file

@ -0,0 +1 @@
pub mod json_account;