]> git.proxmox.com Git - proxmox-backup.git/commitdiff
proxmox-protocol/src/types.rs: use derive Endian
authorDietmar Maurer <dietmar@proxmox.com>
Wed, 24 Apr 2019 04:59:12 +0000 (06:59 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 24 Apr 2019 04:59:12 +0000 (06:59 +0200)
proxmox-protocol/src/types.rs

index 72561920f298f2e386b0aa8aef8b6a1e67ea499b..7bf759af5c31bba68d4e792a8c2a1e47d3ad86d6 100644 (file)
@@ -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<FixedChunk> for ChunkEntry {
     fn into(self) -> FixedChunk {
         FixedChunk(self.hash)