diff --git a/proxmox-protocol/src/types.rs b/proxmox-protocol/src/types.rs index 72561920..7bf759af 100644 --- a/proxmox-protocol/src/types.rs +++ b/proxmox-protocol/src/types.rs @@ -9,7 +9,7 @@ pub enum IndexType { Dynamic, } -#[derive(Clone, Debug, Eq, Hash, PartialEq)] +#[derive(Endian, Clone, Debug, Eq, Hash, PartialEq)] #[repr(transparent)] pub struct FixedChunk(pub [u8; 32]); @@ -33,22 +33,7 @@ impl FixedChunk { } } -impl Endian for FixedChunk { - fn to_be(self) -> Self { - self - } - fn to_le(self) -> Self { - self - } - fn from_be(self) -> Self { - self - } - fn from_le(self) -> Self { - self - } -} - -#[derive(Clone, Copy, Debug, Hash)] +#[derive(Endian, Clone, Copy, Debug, Hash)] #[repr(C, packed)] pub struct ChunkEntry { pub hash: [u8; 32], @@ -94,28 +79,6 @@ impl PartialEq for ChunkEntry { impl Eq for ChunkEntry {} -impl Endian for ChunkEntry { - fn to_be(self) -> Self { - self.size.to_be(); - self - } - - fn to_le(self) -> Self { - self.size.to_le(); - self - } - - fn from_be(self) -> Self { - self.size.from_be(); - self - } - - fn from_le(self) -> Self { - self.size.from_le(); - self - } -} - impl Into for ChunkEntry { fn into(self) -> FixedChunk { FixedChunk(self.hash)