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
use crate::algorithm;
use anomaly::fail;
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[repr(u8)]
pub enum Algorithm {
Data = 0x1e,
X509Certificate = 0x1f,
}
impl Algorithm {
pub fn from_u8(tag: u8) -> Result<Self, algorithm::Error> {
Ok(match tag {
0x1e => Algorithm::Data,
0x1f => Algorithm::X509Certificate,
_ => fail!(
algorithm::ErrorKind::TagInvalid,
"unknown opaque data ID: 0x{:02x}",
tag
),
})
}
pub fn to_u8(self) -> u8 {
self as u8
}
}
impl_algorithm_serializers!(Algorithm);