Skip to main content

f1r3fly_models/rust/
bundle_ops.rs

1// See models/src/main/scala/coop/rchain/models/BundleOps.scala
2
3use crate::rhoapi::Bundle;
4
5pub struct BundleOps;
6
7impl BundleOps {
8    pub fn merge(b: &Bundle, other: &Bundle) -> Bundle {
9        let mut other_mut = other.clone();
10        other_mut.read_flag = b.read_flag && other.read_flag;
11        other_mut.write_flag = b.write_flag && other.write_flag;
12        other_mut
13    }
14
15    pub fn show(bundle: &Bundle) -> String {
16        let sign = if bundle.read_flag && bundle.write_flag {
17            String::from("")
18        } else if bundle.read_flag && !bundle.write_flag {
19            String::from("-")
20        } else if !bundle.read_flag && bundle.write_flag {
21            String::from("+")
22        } else if !bundle.read_flag && !bundle.write_flag {
23            String::from("0")
24        } else {
25            String::from("")
26        };
27
28        format!("{:<8}", format!("bundle{}", sign))
29    }
30}