crypto_bigint/int/
encoding.rs1use crate::{EncodedUint, Encoding, Int, Uint};
4
5impl<const LIMBS: usize> Int<LIMBS> {
6 #[must_use]
13 pub const fn from_be_hex(hex: &str) -> Self {
14 Self(Uint::from_be_hex(hex))
15 }
16}
17
18impl<const LIMBS: usize> Encoding for Int<LIMBS> {
19 type Repr = EncodedUint<LIMBS>;
20
21 #[inline]
22 fn from_be_bytes(bytes: Self::Repr) -> Self {
23 Self(Uint::from_be_bytes(bytes))
24 }
25
26 #[inline]
27 fn from_le_bytes(bytes: Self::Repr) -> Self {
28 Self(Uint::from_le_bytes(bytes))
29 }
30
31 #[inline]
32 fn to_be_bytes(&self) -> Self::Repr {
33 self.0.to_be_bytes()
34 }
35
36 #[inline]
37 fn to_le_bytes(&self) -> Self::Repr {
38 self.0.to_le_bytes()
39 }
40}