catbuffer_rust/
embedded_mosaic_global_restriction_transaction_builder.rs1use super::embedded_transaction_builder::*;
23use super::embedded_transaction_helper::*;
24use super::entity_type_dto::*;
25use super::generator_utils::*;
26use super::key_dto::*;
27use super::mosaic_global_restriction_transaction_body_builder::*;
28use super::mosaic_restriction_type_dto::*;
29use super::network_type_dto::*;
30use super::unresolved_mosaic_id_dto::*;
31
32#[derive(Debug, Clone)]
34pub struct EmbeddedMosaicGlobalRestrictionTransactionBuilder {
35 pub super_object: EmbeddedTransactionBuilder,
37 pub body: MosaicGlobalRestrictionTransactionBodyBuilder,
39}
40
41impl EmbeddedMosaicGlobalRestrictionTransactionBuilder {
42 const VERSION: u8 = 1;
43 const ENTITY_TYPE: u16 = 0x4151;
44
45
46 pub fn from_binary(payload: &[u8]) -> Self {
51 let mut _bytes = payload.to_vec();
52 let super_object = EmbeddedTransactionBuilder::from_binary(&_bytes);
53 assert_eq!(Self::VERSION, super_object.version, "Invalid entity version ({})", super_object.version);
54 assert_eq!(Self::ENTITY_TYPE, super_object._type.get_value(), "Invalid entity type ({:?})", super_object._type);
55 let mut _bytes = _bytes[super_object.get_size()..].to_vec();
56 let mosaic_global_restriction_transaction_body = MosaicGlobalRestrictionTransactionBodyBuilder::from_binary(&_bytes); _bytes = _bytes[mosaic_global_restriction_transaction_body.get_size()..].to_vec();
58 EmbeddedMosaicGlobalRestrictionTransactionBuilder { super_object, body: mosaic_global_restriction_transaction_body } }
62
63
64 pub fn get_mosaic_id(&self) -> UnresolvedMosaicIdDto {
65 self.body.mosaic_id.clone()
66 }
67 pub fn set_mosaic_id(&mut self, mosaic_id: UnresolvedMosaicIdDto) {
68 self.body.mosaic_id = mosaic_id; }
70
71
72 pub fn get_reference_mosaic_id(&self) -> UnresolvedMosaicIdDto {
73 self.body.reference_mosaic_id.clone()
74 }
75 pub fn set_reference_mosaic_id(&mut self, reference_mosaic_id: UnresolvedMosaicIdDto) {
76 self.body.reference_mosaic_id = reference_mosaic_id; }
78
79
80 pub fn get_restriction_key(&self) -> u64 {
81 self.body.restriction_key.clone()
82 }
83 pub fn set_restriction_key(&mut self, restriction_key: u64) {
84 self.body.restriction_key = restriction_key; }
86
87
88 pub fn get_previous_restriction_value(&self) -> u64 {
89 self.body.previous_restriction_value.clone()
90 }
91 pub fn set_previous_restriction_value(&mut self, previous_restriction_value: u64) {
92 self.body.previous_restriction_value = previous_restriction_value; }
94
95
96 pub fn get_new_restriction_value(&self) -> u64 {
97 self.body.new_restriction_value.clone()
98 }
99 pub fn set_new_restriction_value(&mut self, new_restriction_value: u64) {
100 self.body.new_restriction_value = new_restriction_value; }
102
103
104 pub fn get_previous_restriction_type(&self) -> MosaicRestrictionTypeDto {
105 self.body.previous_restriction_type.clone()
106 }
107 pub fn set_previous_restriction_type(&mut self, previous_restriction_type: MosaicRestrictionTypeDto) {
108 self.body.previous_restriction_type = previous_restriction_type; }
110
111
112 pub fn get_new_restriction_type(&self) -> MosaicRestrictionTypeDto {
113 self.body.new_restriction_type.clone()
114 }
115 pub fn set_new_restriction_type(&mut self, new_restriction_type: MosaicRestrictionTypeDto) {
116 self.body.new_restriction_type = new_restriction_type; }
118
119 pub fn get_size(&self) -> usize {
124 let mut size = self.super_object.get_size();
125 size += self.body.get_size();
126 size
127 }
128
129 pub fn serializer(&self) -> Vec<u8> {
134 let mut buf: Vec<u8> = vec![];
135 buf.append(&mut (self.get_size() as u32).to_le_bytes().to_vec());
136 buf.append(&mut self.super_object.serializer());
137 buf.append(&mut self.body.serializer()); buf
139 }
140}
141
142impl EmbeddedTransactionHelper for EmbeddedMosaicGlobalRestrictionTransactionBuilder {
143 fn box_clone(&self) -> Box<dyn EmbeddedTransactionHelper> {
144 Box::new((*self).clone())
145 }
146
147 fn get_size(&self) -> usize {
148 self.get_size()
149 }
150
151 fn serializer(&self) -> Vec<u8> {
152 self.serializer()
153 }
154}
155