Skip to content

Commit 68a6ccf

Browse files
committed
refactor: _
1 parent 4e68e9c commit 68a6ccf

File tree

5 files changed

+57
-71
lines changed

5 files changed

+57
-71
lines changed

Cargo.lock

Lines changed: 44 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ undocumented_unsafe_blocks = "warn"
1515
tabs_in_doc_comments = "allow"
1616

1717
[workspace.dependencies]
18-
v_utils = { version = "^2.0", features = ["trades", "tracing"]}#, path = "../v_utils/v_utils" }
18+
v_utils = { version = "^2.0", features = ["trades", "tracing", "macros"], path = "../v_utils/v_utils" } #ga: rm path
1919

2020
chrono = "^0.4.39"
2121
color-eyre = "^0.6.3"

v_exchanges/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ serde.workspace = true
3232
serde_json.workspace = true
3333
serde_plain.workspace = true
3434
serde_with.workspace = true
35-
v_utils.workspace = true
35+
v_utils = { workspace = true }
3636
color-eyre.workspace = true
3737

3838
# #dbg
@@ -42,6 +42,7 @@ derive-new.workspace = true
4242
chrono = "0.4.39"
4343

4444
insta.workspace = true #dbg (for some reason is not loading in dev-dependencies rn
45+
derive_more = { version = "1.0.0", features = ["deref", "deref_mut"] }
4546

4647
[dev-dependencies]
4748
insta.workspace = true

v_exchanges/src/binance/mod.rs

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,16 @@
11
pub mod futures;
22
use color_eyre::eyre::Result;
3+
use derive_more::{Deref, DerefMut};
34
use v_exchanges_adapters::{Client, binance};
4-
use v_utils::trades::{Asset, Pair, Timeframe};
5+
use v_utils::{
6+
macros::WrapNew,
7+
trades::{Asset, Pair, Timeframe},
8+
};
59

610
use crate::core::{AssetBalance, Exchange, Klines};
711

8-
#[derive(Clone, Debug, Default)]
12+
#[derive(Clone, Debug, Default, Deref, DerefMut, WrapNew)]
913
pub struct Binance(pub Client);
10-
impl Binance {
11-
pub fn new() -> Self {
12-
Self(Client::new())
13-
}
14-
}
15-
impl std::ops::Deref for Binance {
16-
type Target = Client;
17-
18-
fn deref(&self) -> &Self::Target {
19-
&self.0
20-
}
21-
}
22-
impl std::ops::DerefMut for Binance {
23-
fn deref_mut(&mut self) -> &mut Self::Target {
24-
&mut self.0
25-
}
26-
}
2714

2815
//? currently client ends up importing this from crate::binance, but could it be possible to lift the [Client] reexport up, and still have the ability to call all exchange methods right on it?
2916
impl Exchange for Binance {

v_exchanges/src/bybit/mod.rs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,17 @@
11
pub mod account;
22

33
use color_eyre::eyre::Result;
4+
use derive_more::derive::Deref;
5+
use derive_more::derive::DerefMut;
46
use v_exchanges_adapters::Client;
57
use v_exchanges_adapters::bybit;
8+
use v_utils::macros::WrapNew;
69
use v_utils::trades::{Asset, Pair, Timeframe};
710

811
use crate::core::{AssetBalance, Exchange, Klines};
912

13+
#[derive(Clone, Debug, Default, Deref, DerefMut, WrapNew)]
1014
pub struct Bybit(pub Client);
11-
impl Bybit {
12-
pub fn new() -> Self {
13-
Self(Client::new())
14-
}
15-
}
16-
impl std::ops::Deref for Bybit {
17-
type Target = Client;
18-
19-
fn deref(&self) -> &Self::Target {
20-
&self.0
21-
}
22-
}
23-
impl std::ops::DerefMut for Bybit {
24-
fn deref_mut(&mut self) -> &mut Self::Target {
25-
&mut self.0
26-
}
27-
}
2815

2916

3017
//? currently client ends up importing this from crate::binance, but could it be possible to lift the [Client] reexport up, and still have the ability to call all exchange methods right on it?

0 commit comments

Comments
 (0)