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
use crate::PetError;
#[derive(Debug, PartialEq)]
#[cfg_attr(test, derive(Clone))]
pub struct Certificate(Vec<u8>);
#[allow(clippy::len_without_is_empty)]
impl Certificate {
#[allow(clippy::new_without_default)]
pub fn new() -> Self {
Self(vec![0_u8; 32])
}
pub fn len(&self) -> usize {
self.as_ref().len()
}
pub fn validate(&self) -> Result<(), PetError> {
Ok(())
}
}
impl AsRef<[u8]> for Certificate {
fn as_ref(&self) -> &[u8] {
self.0.as_slice()
}
}
impl From<Vec<u8>> for Certificate {
fn from(bytes: Vec<u8>) -> Self {
Self(bytes)
}
}
impl From<&[u8]> for Certificate {
fn from(slice: &[u8]) -> Self {
Self(slice.to_vec())
}
}