asic_rs/miners/backends/bitaxe/
mod.rs

1use semver;
2use std::net::IpAddr;
3
4pub use v2_0_0::Bitaxe200;
5pub use v2_9_0::Bitaxe290;
6
7use crate::data::device::MinerModel;
8use crate::miners::backends::traits::*;
9
10pub mod v2_0_0;
11pub mod v2_9_0;
12
13pub struct Bitaxe;
14
15impl MinerConstructor for Bitaxe {
16    #[allow(clippy::new_ret_no_self)]
17    fn new(ip: IpAddr, model: MinerModel, version: Option<semver::Version>) -> Box<dyn Miner> {
18        if let Some(v) = version {
19            if semver::VersionReq::parse(">=2.0.0, <2.9.0")
20                .unwrap()
21                .matches(&v)
22            {
23                Box::new(Bitaxe200::new(ip, model))
24            } else if semver::VersionReq::parse(">=2.9.0").unwrap().matches(&v) {
25                Box::new(Bitaxe290::new(ip, model))
26            } else {
27                panic!("Unsupported Bitaxe version")
28            }
29        } else {
30            panic!("Unsupported Bitaxe version")
31        }
32    }
33}