ccxt_exchanges/
exchange.rs

1//! Exchange trait definition (DEPRECATED)
2//!
3//! This module is deprecated. Please use `ccxt_core::Exchange` and
4//! `ccxt_core::ExchangeCapabilities` instead.
5//!
6//! # Migration Guide
7//!
8//! Replace:
9//! ```rust,ignore
10//! use ccxt_exchanges::exchange::{Exchange, ExchangeCapabilities};
11//! ```
12//!
13//! With:
14//! ```rust,ignore
15//! use ccxt_core::{Exchange, ExchangeCapabilities};
16//! ```
17//!
18//! The new unified `Exchange` trait in `ccxt_core` provides:
19//! - A single, canonical trait definition
20//! - Object-safe design for `dyn Exchange` usage
21//! - Comprehensive `ExchangeCapabilities` with all features
22//! - Better documentation and examples
23
24#![allow(deprecated)]
25
26// Re-export the unified Exchange trait and ExchangeCapabilities from ccxt-core
27// for backward compatibility
28#[deprecated(
29    since = "0.2.0",
30    note = "Use `ccxt_core::Exchange` instead. This module will be removed in a future version."
31)]
32pub use ccxt_core::Exchange;
33
34#[deprecated(
35    since = "0.2.0",
36    note = "Use `ccxt_core::ExchangeCapabilities` instead. This module will be removed in a future version."
37)]
38pub use ccxt_core::ExchangeCapabilities;
39
40// Re-export type aliases for convenience
41#[deprecated(
42    since = "0.2.0",
43    note = "Use `ccxt_core::BoxedExchange` instead. This module will be removed in a future version."
44)]
45pub use ccxt_core::BoxedExchange;
46
47#[deprecated(
48    since = "0.2.0",
49    note = "Use `ccxt_core::ArcExchange` instead. This module will be removed in a future version."
50)]
51pub use ccxt_core::ArcExchange;
52
53#[cfg(test)]
54mod tests {
55    #[allow(deprecated)]
56    use super::*;
57
58    #[test]
59    fn test_deprecated_capabilities_reexport() {
60        // Test that the re-exported ExchangeCapabilities works
61        // Note: New API uses method calls instead of field access (bitflags implementation)
62        let caps = ExchangeCapabilities::all();
63        assert!(caps.fetch_ticker());
64        assert!(caps.create_order());
65        assert!(caps.websocket());
66
67        let public_caps = ExchangeCapabilities::public_only();
68        assert!(public_caps.fetch_tickers());
69        assert!(!public_caps.create_order());
70        assert!(!public_caps.websocket());
71    }
72
73    #[test]
74    fn test_deprecated_capabilities_has_method() {
75        let caps = ExchangeCapabilities::all();
76        assert!(caps.has("fetchTicker"));
77        assert!(caps.has("createOrder"));
78        assert!(!caps.has("unknownCapability"));
79    }
80}