crypto_bigint/limb/
encoding.rs1use super::{Inner, Limb};
4use crate::Encoding;
5
6impl Encoding for Limb {
7 const BIT_SIZE: usize = super::BIT_SIZE;
8 const BYTE_SIZE: usize = super::BYTE_SIZE;
9
10 #[cfg(target_pointer_width = "32")]
11 type Repr = [u8; 4];
12 #[cfg(target_pointer_width = "64")]
13 type Repr = [u8; 8];
14
15 #[inline]
16 fn from_be_bytes(bytes: Self::Repr) -> Self {
17 Limb(Inner::from_be_bytes(bytes))
18 }
19
20 #[inline]
21 fn from_le_bytes(bytes: Self::Repr) -> Self {
22 Limb(Inner::from_le_bytes(bytes))
23 }
24
25 #[inline]
26 fn to_be_bytes(&self) -> Self::Repr {
27 self.0.to_be_bytes()
28 }
29
30 #[inline]
31 fn to_le_bytes(&self) -> Self::Repr {
32 self.0.to_le_bytes()
33 }
34}