bitpanda_csv/
lib.rs

1//! # bitpanda-csv
2//!
3//! bitpanda-csv is a Rust library to parse the Bitpanda trades exported as CSV from your trades history.
4//!
5//! ## Get started
6//!
7//! ### Add bitpanda-csv to your Cargo.toml 🦀
8//!
9//! ```toml
10//! bitpanda-csv = "^0.2"
11//! ```
12//!
13//! Supported features are:
14//!
15//! - `no-log`: disable logging
16//! - `moveable-feasts` (*default*): enable getters for moveable feasts
17//!
18//! ### Parse CSV
19//!
20//! ```rust
21//! use bitpanda_csv::{BitpandaTradeParser, Trade};
22//! use std::fs::File;
23//!
24//! fn main() {
25//!     let reader = File::open("./test/bitpanda.csv").expect("could not open CSV file");
26//!     let trades: Vec<Trade> = BitpandaTradeParser::parse(reader).expect("failed to parse CSV");
27//! }
28//! ```
29//!
30//! ### Parse CSV (async)
31//!
32//! Add to your Cargo.toml the `async` feature.
33//! If you don't need the sync stuff, you can disable the default features then.
34//!
35//! ```rust
36//! use bitpanda_csv::{AsyncBitpandaTradeParser, Trade};
37//! use tokio::fs::File;
38//! use tokio::io::BufReader;
39//!
40//! #[tokio::main]
41//! async fn main() {
42//!     let file = File::open("./test/bitpanda.csv").await.expect("could not open CSV file");
43//!     let trades = AsyncBitpandaTradeParser::parse(BufReader::new(file))
44//!         .await
45//!         .unwrap();
46//! }
47//! ```
48//!
49
50#![doc(html_playground_url = "https://play.rust-lang.org")]
51
52#[macro_use]
53extern crate log;
54#[macro_use]
55extern crate serde;
56
57#[cfg(feature = "async")]
58mod async_parser;
59#[cfg(feature = "mock")]
60pub(crate) mod mock;
61
62#[cfg(feature = "sync")]
63mod parser;
64mod trade;
65
66#[cfg(feature = "mock")]
67pub use mock::TradeGenerator;
68
69#[cfg(feature = "async")]
70pub use async_parser::AsyncBitpandaTradeParser;
71#[cfg(feature = "sync")]
72pub use parser::BitpandaTradeParser;
73pub use trade::{
74    Asset, AssetClass, CryptoCurrency, CsvOption, Currency, Fiat, InOut, Metal, Trade,
75    TransactionType,
76};