Coverage Report

Created: 2026-11-12 06:16

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/crypto-bigint-0.7.10/src/int/encoding.rs
Line
Count
Source
1
//! Const-friendly decoding/encoding operations for [`Int`].
2
3
use crate::{EncodedUint, Encoding, Int, Uint};
4
5
impl<const LIMBS: usize> Int<LIMBS> {
6
    /// Create a new [`Int`] from the provided big endian hex string.
7
    ///
8
    /// See [`Uint::from_be_hex`] for more details.
9
    ///
10
    /// # Panics
11
    /// - if the hex is malformed or not zero-padded accordingly for the size.
12
    #[must_use]
13
0
    pub const fn from_be_hex(hex: &str) -> Self {
14
0
        Self(Uint::from_be_hex(hex))
15
0
    }
16
}
17
18
impl<const LIMBS: usize> Encoding for Int<LIMBS> {
19
    type Repr = EncodedUint<LIMBS>;
20
21
    #[inline]
22
0
    fn from_be_bytes(bytes: Self::Repr) -> Self {
23
0
        Self(Uint::from_be_bytes(bytes))
24
0
    }
25
26
    #[inline]
27
0
    fn from_le_bytes(bytes: Self::Repr) -> Self {
28
0
        Self(Uint::from_le_bytes(bytes))
29
0
    }
30
31
    #[inline]
32
0
    fn to_be_bytes(&self) -> Self::Repr {
33
0
        self.0.to_be_bytes()
34
0
    }
35
36
    #[inline]
37
0
    fn to_le_bytes(&self) -> Self::Repr {
38
0
        self.0.to_le_bytes()
39
0
    }
40
}