rgbstd/containers/
util.rs1use amplify::confinement::SmallOrdSet;
23use bp::Tx;
24
25use super::TerminalSeal;
26use crate::LIB_NAME_RGB_STD;
27
28#[derive(Clone, Eq, PartialEq, Debug)]
29#[derive(StrictType, StrictDumb, StrictEncode, StrictDecode)]
30#[strict_type(lib = LIB_NAME_RGB_STD)]
31#[cfg_attr(
32 feature = "serde",
33 derive(Serialize, Deserialize),
34 serde(crate = "serde_crate", rename_all = "camelCase")
35)]
36pub struct Terminal {
37 pub seals: SmallOrdSet<TerminalSeal>,
38 pub tx: Option<Tx>,
39}
40
41impl Terminal {
42 pub fn new(seal: TerminalSeal) -> Self {
43 Terminal {
44 seals: small_bset![seal],
45 tx: None,
46 }
47 }
48 pub fn with(seal: TerminalSeal, tx: Tx) -> Self {
49 Terminal {
50 seals: small_bset![seal],
51 tx: Some(tx),
52 }
53 }
54}
55
56#[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug, Display, Default)]
57#[derive(StrictType, StrictEncode, StrictDecode)]
58#[strict_type(lib = LIB_NAME_RGB_STD, tags = repr, into_u8, try_from_u8)]
59#[cfg_attr(
60 feature = "serde",
61 derive(Serialize, Deserialize),
62 serde(crate = "serde_crate", rename_all = "camelCase")
63)]
64#[display(lowercase)]
65#[non_exhaustive]
66#[repr(u8)]
67pub enum ContainerVer {
68 #[default]
70 V1 = 1,
71}