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
use crypto::random;
const TOK_SIZE: usize = 64;
pub struct Token {
tok: [u8; TOK_SIZE],
}
impl Token {
pub fn new() -> Self {
let v = random::bytes(TOK_SIZE);
let mut tok = [0; TOK_SIZE];
tok.copy_from_slice(v.as_slice());
Self { tok }
}
}
impl PartialEq for Token {
fn eq(&self, other: &Self) -> bool {
let mut ret = true;
for i in 0..TOK_SIZE {
if self.tok[i] != other.tok[i] {
ret = false;
}
}
ret
}
}
impl Eq for Token {}