forest/shim/
bigint.rs

1// Copyright 2019-2025 ChainSafe Systems
2// SPDX-License-Identifier: Apache-2.0, MIT
3
4use std::ops::{Deref, DerefMut};
5
6use super::fvm_shared_latest::bigint::bigint_ser;
7use serde::{Deserialize, Serialize};
8
9#[derive(Default, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
10#[serde(transparent)]
11pub struct BigInt(#[serde(with = "bigint_ser")] num_bigint::BigInt);
12
13impl Deref for BigInt {
14    type Target = num_bigint::BigInt;
15    fn deref(&self) -> &Self::Target {
16        &self.0
17    }
18}
19
20impl DerefMut for BigInt {
21    fn deref_mut(&mut self) -> &mut Self::Target {
22        &mut self.0
23    }
24}
25
26impl From<num_bigint::BigInt> for BigInt {
27    fn from(other: num_bigint::BigInt) -> Self {
28        BigInt(other)
29    }
30}