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())
}
}