forest/lotus_json/
bit_field.rs1use super::*;
5
6use fil_actors_shared::fvm_ipld_bitfield::{BitField, json::BitFieldJson};
7
8#[derive(Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
9#[schemars(rename = "BitField")]
10pub struct BitFieldLotusJson(#[schemars(with = "Option<Vec<u8>>")] pub BitFieldJson);
11
12impl Clone for BitFieldLotusJson {
13 fn clone(&self) -> Self {
14 Self(BitFieldJson(self.0.0.clone()))
15 }
16}
17
18impl HasLotusJson for BitField {
19 type LotusJson = BitFieldLotusJson;
20 #[cfg(test)]
21 fn snapshots() -> Vec<(serde_json::Value, Self)> {
22 vec![
23 (json!([0]), Self::new()),
24 (json!([1, 1]), {
25 let mut it = Self::new();
26 it.set(1);
27 it
28 }),
29 ]
30 }
31 fn into_lotus_json(self) -> Self::LotusJson {
32 BitFieldLotusJson(BitFieldJson(self))
33 }
34 fn from_lotus_json(BitFieldLotusJson(BitFieldJson(it)): Self::LotusJson) -> Self {
35 it
36 }
37}
38
39#[test]
40fn snapshots() {
41 assert_all_snapshots::<BitField>();
42}