1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use crate::Result;
use async_trait::async_trait;
use serde::{de::DeserializeOwned, Serialize};
use std::fmt::Debug;
pub trait StratumPackets {
type Authorize: Authorize;
type Capabilities: Capabilities;
type Submit: Submit;
type Subscribe: Subscribe;
type SuggestDifficulty: SuggestDifficulty;
type SuggestTarget: SuggestTarget;
type Notify: Notify;
type SetDifficulty: SetDifficulty;
type SetExtraNonce: SetExtraNonce;
type SetGoal: SetGoal;
}
#[async_trait]
pub trait StratumManager: Sync + Send {
type Params: StratumPackets + DeserializeOwned + Serialize;
async fn authorize(&self, auth: &<Self::Params as StratumPackets>::Authorize) -> Result<bool>;
async fn submit(&self, share: &<Self::Params as StratumPackets>::Submit) -> Result<bool>;
async fn subscribe(
&self,
subscribe_info: &<Self::Params as StratumPackets>::Subscribe,
) -> Result<bool>;
}
pub trait Authorize: DeserializeOwned + Serialize + Sync + Send + Clone + Debug {}
pub trait Capabilities: DeserializeOwned + Serialize + Sync + Send + Clone + Debug {}
pub trait Submit: DeserializeOwned + Serialize + Sync + Send + Clone + Debug {}
pub trait Subscribe: DeserializeOwned + Serialize + Sync + Send + Clone + Debug {}
pub trait SuggestDifficulty: DeserializeOwned + Serialize + Sync + Send + Clone + Debug {}
pub trait SuggestTarget: DeserializeOwned + Serialize + Sync + Send + Clone + Debug {}
pub trait Notify: DeserializeOwned + Serialize + Sync + Send + Clone + Debug {}
pub trait SetDifficulty: DeserializeOwned + Serialize + Sync + Send + Clone + Debug {}
pub trait SetExtraNonce: DeserializeOwned + Serialize + Sync + Send + Clone + Debug {}
pub trait SetGoal: DeserializeOwned + Serialize + Sync + Send + Clone + Debug {}