|
1 | 1 | use crate::AnyResult; |
2 | 2 | use compact_str::CompactString; |
3 | 3 | use eyre::bail; |
4 | | -use serde::Serialize; |
| 4 | +use serde::{Deserialize, Serialize}; |
5 | 5 | use std::num::NonZeroI32; |
6 | 6 | use time::OffsetDateTime; |
7 | 7 |
|
8 | | -#[derive(Debug, Serialize)] |
| 8 | +#[derive(Debug, Serialize, Deserialize)] |
9 | 9 | pub struct Transaction { |
10 | 10 | pub valor: NonZeroI32, |
11 | 11 | pub tipo: TransactionKind, |
12 | 12 | pub descricao: TransactionDescription, |
13 | 13 | pub realizada_em: OffsetDateTime, |
14 | 14 | } |
15 | 15 |
|
16 | | -#[derive(Debug, Copy, Clone, Serialize)] |
| 16 | +#[derive(Debug, Copy, Clone, Serialize, Deserialize)] |
17 | 17 | pub enum TransactionKind { |
18 | 18 | Credit, |
19 | 19 | Debit, |
20 | 20 | } |
21 | 21 |
|
22 | | -#[derive(Serialize, Debug, PartialEq, Eq)] |
23 | | -pub struct TransactionDescription(CompactString); |
| 22 | +#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)] |
| 23 | +pub struct TransactionDescription(pub CompactString); |
24 | 24 |
|
25 | 25 | impl TransactionDescription { |
26 | 26 | pub fn new(description: &str) -> AnyResult<Self> { |
|
0 commit comments