diff --git a/crates/core/src/generated/mod.rs b/crates/core/src/generated/mod.rs index cd9c8eb2a..43a557b05 100644 --- a/crates/core/src/generated/mod.rs +++ b/crates/core/src/generated/mod.rs @@ -23,6 +23,8 @@ pub enum ContractChange<'a> { PutFailure(topology::PutFailure<'a>), BroadcastEmitted(topology::BroadcastEmitted<'a>), BroadcastReceived(topology::BroadcastReceived<'a>), + GetContract(topology::GetContract<'a>), + SubscribedToContract(topology::SubscribedToContract<'a>), } // TODO: Change this to EventWrapper @@ -109,7 +111,7 @@ impl ContractChange<'_> { contract: impl AsRef, requester: impl AsRef, target: impl AsRef, - _timestamp: u64, + timestamp: u64, ) -> Vec { let mut buf = flatbuffers::FlatBufferBuilder::new(); let transaction = buf.create_string(transaction.as_ref()); @@ -123,6 +125,7 @@ impl ContractChange<'_> { key: Some(contract), requester: Some(requester), target: Some(target), + timestamp, }, ); let msg = topology::ContractChange::create( @@ -221,6 +224,82 @@ impl ContractChange<'_> { buf.finish_minimal(msg); buf.finished_data().to_vec() } + + pub fn get_contract_msg( + requester: impl AsRef, + target: impl AsRef, + transaction: impl AsRef, + contract_key: impl AsRef, + contract_location: f64, + timestamp: u64, + ) -> Vec { + let mut buf = flatbuffers::FlatBufferBuilder::new(); + let requester = buf.create_string(requester.as_ref()); + let target = buf.create_string(target.as_ref()); + let transaction = buf.create_string(transaction.as_ref()); + let contract_key = buf.create_string(contract_key.as_ref()); + let get_contract = topology::GetContract::create( + &mut buf, + &topology::GetContractArgs { + requester: Some(requester), + target: Some(target), + transaction: Some(transaction), + key: Some(contract_key), + contract_location, + timestamp, + }, + ); + + let msg = topology::ContractChange::create( + &mut buf, + &topology::ContractChangeArgs { + contract_id: Some(contract_key), + change_type: topology::ContractChangeType::GetContract, + change: Some(get_contract.as_union_value()), + }, + ); + buf.finish_minimal(msg); + buf.finished_data().to_vec() + } + + pub fn subscribed_msg( + requester: impl AsRef, + transaction: impl AsRef, + contract_key: impl AsRef, + contract_location: f64, + at_peer: impl AsRef, + at_peer_location: f64, + timestamp: u64, + ) -> Vec { + let mut buf = flatbuffers::FlatBufferBuilder::new(); + let requester = buf.create_string(requester.as_ref()); + let transaction = buf.create_string(transaction.as_ref()); + let contract_key = buf.create_string(contract_key.as_ref()); + let at_peer = buf.create_string(at_peer.as_ref()); + let subscribed = topology::SubscribedToContract::create( + &mut buf, + &topology::SubscribedToContractArgs { + requester: Some(requester), + transaction: Some(transaction), + key: Some(contract_key), + contract_location, + at_peer: Some(at_peer), + at_peer_location, + timestamp, + }, + ); + + let msg = topology::ContractChange::create( + &mut buf, + &topology::ContractChangeArgs { + contract_id: Some(contract_key), + change_type: topology::ContractChangeType::SubscribedToContract, + change: Some(subscribed.as_union_value()), + }, + ); + buf.finish_minimal(msg); + buf.finished_data().to_vec() + } } impl PeerChange<'_> { @@ -435,6 +514,26 @@ impl<'a> TryFromFbs<'a> for ContractChange<'a> { })?; Ok(Self::BroadcastReceived(req)) } + topology::ContractChangeType::GetContract => { + let req = req.change_as_get_contract().ok_or_else(|| { + flatbuffers::InvalidFlatbuffer::InconsistentUnion { + field: "change_type", + field_type: "ContractChangeType", + error_trace: Default::default(), + } + })?; + Ok(Self::GetContract(req)) + } + topology::ContractChangeType::SubscribedToContract => { + let req = req.change_as_subscribed_to_contract().ok_or_else(|| { + flatbuffers::InvalidFlatbuffer::InconsistentUnion { + field: "change_type", + field_type: "ContractChangeType", + error_trace: Default::default(), + } + })?; + Ok(Self::SubscribedToContract(req)) + } _ => unreachable!("Invalid contract change type"), } } diff --git a/crates/core/src/generated/topology_generated.rs b/crates/core/src/generated/topology_generated.rs index b24f893af..5ff457bb8 100644 --- a/crates/core/src/generated/topology_generated.rs +++ b/crates/core/src/generated/topology_generated.rs @@ -224,13 +224,13 @@ pub mod topology { since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021." )] - pub const ENUM_MAX_CONTRACT_CHANGE_TYPE: u8 = 8; + pub const ENUM_MAX_CONTRACT_CHANGE_TYPE: u8 = 10; #[deprecated( since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021." )] #[allow(non_camel_case_types)] - pub const ENUM_VALUES_CONTRACT_CHANGE_TYPE: [ContractChangeType; 9] = [ + pub const ENUM_VALUES_CONTRACT_CHANGE_TYPE: [ContractChangeType; 11] = [ ContractChangeType::NONE, ContractChangeType::PutRequest, ContractChangeType::PutSuccess, @@ -240,6 +240,8 @@ pub mod topology { ContractChangeType::UpdateRequest, ContractChangeType::UpdateSuccess, ContractChangeType::UpdateFailure, + ContractChangeType::GetContract, + ContractChangeType::SubscribedToContract, ]; #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] @@ -256,9 +258,11 @@ pub mod topology { pub const UpdateRequest: Self = Self(6); pub const UpdateSuccess: Self = Self(7); pub const UpdateFailure: Self = Self(8); + pub const GetContract: Self = Self(9); + pub const SubscribedToContract: Self = Self(10); pub const ENUM_MIN: u8 = 0; - pub const ENUM_MAX: u8 = 8; + pub const ENUM_MAX: u8 = 10; pub const ENUM_VALUES: &'static [Self] = &[ Self::NONE, Self::PutRequest, @@ -269,6 +273,8 @@ pub mod topology { Self::UpdateRequest, Self::UpdateSuccess, Self::UpdateFailure, + Self::GetContract, + Self::SubscribedToContract, ]; /// Returns the variant's name or "" if unknown. pub fn variant_name(self) -> Option<&'static str> { @@ -282,6 +288,8 @@ pub mod topology { Self::UpdateRequest => Some("UpdateRequest"), Self::UpdateSuccess => Some("UpdateSuccess"), Self::UpdateFailure => Some("UpdateFailure"), + Self::GetContract => Some("GetContract"), + Self::SubscribedToContract => Some("SubscribedToContract"), _ => None, } } @@ -2091,6 +2099,7 @@ pub mod topology { pub const VT_REQUESTER: flatbuffers::VOffsetT = 6; pub const VT_TARGET: flatbuffers::VOffsetT = 8; pub const VT_KEY: flatbuffers::VOffsetT = 10; + pub const VT_TIMESTAMP: flatbuffers::VOffsetT = 12; #[inline] pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { @@ -2102,6 +2111,7 @@ pub mod topology { args: &'args PutFailureArgs<'args>, ) -> flatbuffers::WIPOffset> { let mut builder = PutFailureBuilder::new(_fbb); + builder.add_timestamp(args.timestamp); if let Some(x) = args.key { builder.add_key(x); } @@ -2161,6 +2171,17 @@ pub mod topology { .unwrap() } } + #[inline] + pub fn timestamp(&self) -> u64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(PutFailure::VT_TIMESTAMP, Some(0)) + .unwrap() + } + } } impl flatbuffers::Verifiable for PutFailure<'_> { @@ -2183,6 +2204,7 @@ pub mod topology { )? .visit_field::>("target", Self::VT_TARGET, true)? .visit_field::>("key", Self::VT_KEY, true)? + .visit_field::("timestamp", Self::VT_TIMESTAMP, false)? .finish(); Ok(()) } @@ -2192,6 +2214,7 @@ pub mod topology { pub requester: Option>, pub target: Option>, pub key: Option>, + pub timestamp: u64, } impl<'a> Default for PutFailureArgs<'a> { #[inline] @@ -2201,6 +2224,7 @@ pub mod topology { requester: None, // required field target: None, // required field key: None, // required field + timestamp: 0, } } } @@ -2233,6 +2257,11 @@ pub mod topology { .push_slot_always::>(PutFailure::VT_KEY, key); } #[inline] + pub fn add_timestamp(&mut self, timestamp: u64) { + self.fbb_ + .push_slot::(PutFailure::VT_TIMESTAMP, timestamp, 0); + } + #[inline] pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> PutFailureBuilder<'a, 'b> { let start = _fbb.start_table(); PutFailureBuilder { @@ -2259,6 +2288,7 @@ pub mod topology { ds.field("requester", &self.requester()); ds.field("target", &self.target()); ds.field("key", &self.key()); + ds.field("timestamp", &self.timestamp()); ds.finish() } } @@ -2284,6 +2314,7 @@ pub mod topology { pub const VT_REQUESTER: flatbuffers::VOffsetT = 6; pub const VT_TARGET: flatbuffers::VOffsetT = 8; pub const VT_KEY: flatbuffers::VOffsetT = 10; + pub const VT_TIMESTAMP: flatbuffers::VOffsetT = 12; #[inline] pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { @@ -2295,6 +2326,7 @@ pub mod topology { args: &'args UpdateSuccessArgs<'args>, ) -> flatbuffers::WIPOffset> { let mut builder = UpdateSuccessBuilder::new(_fbb); + builder.add_timestamp(args.timestamp); if let Some(x) = args.key { builder.add_key(x); } @@ -2354,6 +2386,17 @@ pub mod topology { .unwrap() } } + #[inline] + pub fn timestamp(&self) -> u64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(UpdateSuccess::VT_TIMESTAMP, Some(0)) + .unwrap() + } + } } impl flatbuffers::Verifiable for UpdateSuccess<'_> { @@ -2376,6 +2419,7 @@ pub mod topology { )? .visit_field::>("target", Self::VT_TARGET, true)? .visit_field::>("key", Self::VT_KEY, true)? + .visit_field::("timestamp", Self::VT_TIMESTAMP, false)? .finish(); Ok(()) } @@ -2385,6 +2429,7 @@ pub mod topology { pub requester: Option>, pub target: Option>, pub key: Option>, + pub timestamp: u64, } impl<'a> Default for UpdateSuccessArgs<'a> { #[inline] @@ -2394,6 +2439,7 @@ pub mod topology { requester: None, // required field target: None, // required field key: None, // required field + timestamp: 0, } } } @@ -2428,6 +2474,11 @@ pub mod topology { .push_slot_always::>(UpdateSuccess::VT_KEY, key); } #[inline] + pub fn add_timestamp(&mut self, timestamp: u64) { + self.fbb_ + .push_slot::(UpdateSuccess::VT_TIMESTAMP, timestamp, 0); + } + #[inline] pub fn new( _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, ) -> UpdateSuccessBuilder<'a, 'b> { @@ -2457,6 +2508,7 @@ pub mod topology { ds.field("requester", &self.requester()); ds.field("target", &self.target()); ds.field("key", &self.key()); + ds.field("timestamp", &self.timestamp()); ds.finish() } } @@ -2482,6 +2534,7 @@ pub mod topology { pub const VT_REQUESTER: flatbuffers::VOffsetT = 6; pub const VT_TARGET: flatbuffers::VOffsetT = 8; pub const VT_KEY: flatbuffers::VOffsetT = 10; + pub const VT_TIMESTAMP: flatbuffers::VOffsetT = 12; #[inline] pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { @@ -2493,6 +2546,7 @@ pub mod topology { args: &'args UpdateFailureArgs<'args>, ) -> flatbuffers::WIPOffset> { let mut builder = UpdateFailureBuilder::new(_fbb); + builder.add_timestamp(args.timestamp); if let Some(x) = args.key { builder.add_key(x); } @@ -2552,6 +2606,17 @@ pub mod topology { .unwrap() } } + #[inline] + pub fn timestamp(&self) -> u64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(UpdateFailure::VT_TIMESTAMP, Some(0)) + .unwrap() + } + } } impl flatbuffers::Verifiable for UpdateFailure<'_> { @@ -2574,6 +2639,7 @@ pub mod topology { )? .visit_field::>("target", Self::VT_TARGET, true)? .visit_field::>("key", Self::VT_KEY, true)? + .visit_field::("timestamp", Self::VT_TIMESTAMP, false)? .finish(); Ok(()) } @@ -2583,6 +2649,7 @@ pub mod topology { pub requester: Option>, pub target: Option>, pub key: Option>, + pub timestamp: u64, } impl<'a> Default for UpdateFailureArgs<'a> { #[inline] @@ -2592,6 +2659,7 @@ pub mod topology { requester: None, // required field target: None, // required field key: None, // required field + timestamp: 0, } } } @@ -2626,6 +2694,11 @@ pub mod topology { .push_slot_always::>(UpdateFailure::VT_KEY, key); } #[inline] + pub fn add_timestamp(&mut self, timestamp: u64) { + self.fbb_ + .push_slot::(UpdateFailure::VT_TIMESTAMP, timestamp, 0); + } + #[inline] pub fn new( _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, ) -> UpdateFailureBuilder<'a, 'b> { @@ -2655,6 +2728,7 @@ pub mod topology { ds.field("requester", &self.requester()); ds.field("target", &self.target()); ds.field("key", &self.key()); + ds.field("timestamp", &self.timestamp()); ds.finish() } } @@ -3219,15 +3293,15 @@ pub mod topology { ds.finish() } } - pub enum ContractChangeOffset {} + pub enum GetContractOffset {} #[derive(Copy, Clone, PartialEq)] - pub struct ContractChange<'a> { + pub struct GetContract<'a> { pub _tab: flatbuffers::Table<'a>, } - impl<'a> flatbuffers::Follow<'a> for ContractChange<'a> { - type Inner = ContractChange<'a>; + impl<'a> flatbuffers::Follow<'a> for GetContract<'a> { + type Inner = GetContract<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { Self { @@ -3236,170 +3310,696 @@ pub mod topology { } } - impl<'a> ContractChange<'a> { - pub const VT_CONTRACT_ID: flatbuffers::VOffsetT = 4; - pub const VT_CHANGE_TYPE: flatbuffers::VOffsetT = 6; - pub const VT_CHANGE: flatbuffers::VOffsetT = 8; + impl<'a> GetContract<'a> { + pub const VT_REQUESTER: flatbuffers::VOffsetT = 4; + pub const VT_TARGET: flatbuffers::VOffsetT = 6; + pub const VT_TRANSACTION: flatbuffers::VOffsetT = 8; + pub const VT_KEY: flatbuffers::VOffsetT = 10; + pub const VT_CONTRACT_LOCATION: flatbuffers::VOffsetT = 12; + pub const VT_TIMESTAMP: flatbuffers::VOffsetT = 14; #[inline] pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - ContractChange { _tab: table } + GetContract { _tab: table } } #[allow(unused_mut)] pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args ContractChangeArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = ContractChangeBuilder::new(_fbb); - if let Some(x) = args.change { - builder.add_change(x); + args: &'args GetContractArgs<'args>, + ) -> flatbuffers::WIPOffset> { + let mut builder = GetContractBuilder::new(_fbb); + builder.add_timestamp(args.timestamp); + builder.add_contract_location(args.contract_location); + if let Some(x) = args.key { + builder.add_key(x); } - if let Some(x) = args.contract_id { - builder.add_contract_id(x); + if let Some(x) = args.transaction { + builder.add_transaction(x); + } + if let Some(x) = args.target { + builder.add_target(x); + } + if let Some(x) = args.requester { + builder.add_requester(x); } - builder.add_change_type(args.change_type); builder.finish() } #[inline] - pub fn contract_id(&self) -> &'a str { + pub fn requester(&self) -> &'a str { // Safety: // Created from valid Table for this object // which contains a valid value in this slot unsafe { self._tab - .get::>(ContractChange::VT_CONTRACT_ID, None) + .get::>(GetContract::VT_REQUESTER, None) .unwrap() } } #[inline] - pub fn change_type(&self) -> ContractChangeType { + pub fn target(&self) -> &'a str { // Safety: // Created from valid Table for this object // which contains a valid value in this slot unsafe { self._tab - .get::( - ContractChange::VT_CHANGE_TYPE, - Some(ContractChangeType::NONE), - ) + .get::>(GetContract::VT_TARGET, None) .unwrap() } } #[inline] - pub fn change(&self) -> Option> { + pub fn transaction(&self) -> &'a str { // Safety: // Created from valid Table for this object // which contains a valid value in this slot unsafe { self._tab - .get::>>( - ContractChange::VT_CHANGE, - None, - ) + .get::>(GetContract::VT_TRANSACTION, None) + .unwrap() } } #[inline] - #[allow(non_snake_case)] - pub fn change_as_put_request(&self) -> Option> { - if self.change_type() == ContractChangeType::PutRequest { - self.change().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { PutRequest::init_from_table(t) } - }) - } else { - None + pub fn key(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::>(GetContract::VT_KEY, None) + .unwrap() } } - #[inline] - #[allow(non_snake_case)] - pub fn change_as_put_success(&self) -> Option> { - if self.change_type() == ContractChangeType::PutSuccess { - self.change().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { PutSuccess::init_from_table(t) } - }) - } else { - None + pub fn contract_location(&self) -> f64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(GetContract::VT_CONTRACT_LOCATION, Some(0.0)) + .unwrap() } } - #[inline] - #[allow(non_snake_case)] - pub fn change_as_put_failure(&self) -> Option> { - if self.change_type() == ContractChangeType::PutFailure { - self.change().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { PutFailure::init_from_table(t) } - }) - } else { - None + pub fn timestamp(&self) -> u64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(GetContract::VT_TIMESTAMP, Some(0)) + .unwrap() } } + } + impl flatbuffers::Verifiable for GetContract<'_> { #[inline] - #[allow(non_snake_case)] - pub fn change_as_broadcast_emitted(&self) -> Option> { - if self.change_type() == ContractChangeType::BroadcastEmitted { - self.change().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { BroadcastEmitted::init_from_table(t) } - }) - } else { - None - } + fn run_verifier( + v: &mut flatbuffers::Verifier, + pos: usize, + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>( + "requester", + Self::VT_REQUESTER, + true, + )? + .visit_field::>("target", Self::VT_TARGET, true)? + .visit_field::>( + "transaction", + Self::VT_TRANSACTION, + true, + )? + .visit_field::>("key", Self::VT_KEY, true)? + .visit_field::("contract_location", Self::VT_CONTRACT_LOCATION, false)? + .visit_field::("timestamp", Self::VT_TIMESTAMP, false)? + .finish(); + Ok(()) } - + } + pub struct GetContractArgs<'a> { + pub requester: Option>, + pub target: Option>, + pub transaction: Option>, + pub key: Option>, + pub contract_location: f64, + pub timestamp: u64, + } + impl<'a> Default for GetContractArgs<'a> { #[inline] - #[allow(non_snake_case)] - pub fn change_as_broadcast_received(&self) -> Option> { - if self.change_type() == ContractChangeType::BroadcastReceived { - self.change().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { BroadcastReceived::init_from_table(t) } - }) - } else { - None + fn default() -> Self { + GetContractArgs { + requester: None, // required field + target: None, // required field + transaction: None, // required field + key: None, // required field + contract_location: 0.0, + timestamp: 0, } } + } + pub struct GetContractBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, + } + impl<'a: 'b, 'b> GetContractBuilder<'a, 'b> { #[inline] - #[allow(non_snake_case)] - pub fn change_as_update_request(&self) -> Option> { - if self.change_type() == ContractChangeType::UpdateRequest { - self.change().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { UpdateRequest::init_from_table(t) } - }) - } else { - None - } + pub fn add_requester(&mut self, requester: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>( + GetContract::VT_REQUESTER, + requester, + ); } - #[inline] - #[allow(non_snake_case)] - pub fn change_as_update_success(&self) -> Option> { - if self.change_type() == ContractChangeType::UpdateSuccess { - self.change().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { UpdateSuccess::init_from_table(t) } - }) - } else { + pub fn add_target(&mut self, target: flatbuffers::WIPOffset<&'b str>) { + self.fbb_ + .push_slot_always::>(GetContract::VT_TARGET, target); + } + #[inline] + pub fn add_transaction(&mut self, transaction: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>( + GetContract::VT_TRANSACTION, + transaction, + ); + } + #[inline] + pub fn add_key(&mut self, key: flatbuffers::WIPOffset<&'b str>) { + self.fbb_ + .push_slot_always::>(GetContract::VT_KEY, key); + } + #[inline] + pub fn add_contract_location(&mut self, contract_location: f64) { + self.fbb_ + .push_slot::(GetContract::VT_CONTRACT_LOCATION, contract_location, 0.0); + } + #[inline] + pub fn add_timestamp(&mut self, timestamp: u64) { + self.fbb_ + .push_slot::(GetContract::VT_TIMESTAMP, timestamp, 0); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> GetContractBuilder<'a, 'b> { + let start = _fbb.start_table(); + GetContractBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + self.fbb_ + .required(o, GetContract::VT_REQUESTER, "requester"); + self.fbb_.required(o, GetContract::VT_TARGET, "target"); + self.fbb_ + .required(o, GetContract::VT_TRANSACTION, "transaction"); + self.fbb_.required(o, GetContract::VT_KEY, "key"); + flatbuffers::WIPOffset::new(o.value()) + } + } + + impl core::fmt::Debug for GetContract<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("GetContract"); + ds.field("requester", &self.requester()); + ds.field("target", &self.target()); + ds.field("transaction", &self.transaction()); + ds.field("key", &self.key()); + ds.field("contract_location", &self.contract_location()); + ds.field("timestamp", &self.timestamp()); + ds.finish() + } + } + pub enum SubscribedToContractOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct SubscribedToContract<'a> { + pub _tab: flatbuffers::Table<'a>, + } + + impl<'a> flatbuffers::Follow<'a> for SubscribedToContract<'a> { + type Inner = SubscribedToContract<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } + } + } + + impl<'a> SubscribedToContract<'a> { + pub const VT_REQUESTER: flatbuffers::VOffsetT = 4; + pub const VT_TRANSACTION: flatbuffers::VOffsetT = 6; + pub const VT_KEY: flatbuffers::VOffsetT = 8; + pub const VT_CONTRACT_LOCATION: flatbuffers::VOffsetT = 10; + pub const VT_AT_PEER: flatbuffers::VOffsetT = 12; + pub const VT_AT_PEER_LOCATION: flatbuffers::VOffsetT = 14; + pub const VT_TIMESTAMP: flatbuffers::VOffsetT = 16; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + SubscribedToContract { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args SubscribedToContractArgs<'args>, + ) -> flatbuffers::WIPOffset> { + let mut builder = SubscribedToContractBuilder::new(_fbb); + builder.add_timestamp(args.timestamp); + builder.add_at_peer_location(args.at_peer_location); + builder.add_contract_location(args.contract_location); + if let Some(x) = args.at_peer { + builder.add_at_peer(x); + } + if let Some(x) = args.key { + builder.add_key(x); + } + if let Some(x) = args.transaction { + builder.add_transaction(x); + } + if let Some(x) = args.requester { + builder.add_requester(x); + } + builder.finish() + } + + #[inline] + pub fn requester(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::>( + SubscribedToContract::VT_REQUESTER, + None, + ) + .unwrap() + } + } + #[inline] + pub fn transaction(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::>( + SubscribedToContract::VT_TRANSACTION, + None, + ) + .unwrap() + } + } + #[inline] + pub fn key(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::>(SubscribedToContract::VT_KEY, None) + .unwrap() + } + } + #[inline] + pub fn contract_location(&self) -> f64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(SubscribedToContract::VT_CONTRACT_LOCATION, Some(0.0)) + .unwrap() + } + } + #[inline] + pub fn at_peer(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::>( + SubscribedToContract::VT_AT_PEER, + None, + ) + .unwrap() + } + } + #[inline] + pub fn at_peer_location(&self) -> f64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(SubscribedToContract::VT_AT_PEER_LOCATION, Some(0.0)) + .unwrap() + } + } + #[inline] + pub fn timestamp(&self) -> u64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(SubscribedToContract::VT_TIMESTAMP, Some(0)) + .unwrap() + } + } + } + + impl flatbuffers::Verifiable for SubscribedToContract<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, + pos: usize, + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>( + "requester", + Self::VT_REQUESTER, + true, + )? + .visit_field::>( + "transaction", + Self::VT_TRANSACTION, + true, + )? + .visit_field::>("key", Self::VT_KEY, true)? + .visit_field::("contract_location", Self::VT_CONTRACT_LOCATION, false)? + .visit_field::>( + "at_peer", + Self::VT_AT_PEER, + true, + )? + .visit_field::("at_peer_location", Self::VT_AT_PEER_LOCATION, false)? + .visit_field::("timestamp", Self::VT_TIMESTAMP, false)? + .finish(); + Ok(()) + } + } + pub struct SubscribedToContractArgs<'a> { + pub requester: Option>, + pub transaction: Option>, + pub key: Option>, + pub contract_location: f64, + pub at_peer: Option>, + pub at_peer_location: f64, + pub timestamp: u64, + } + impl<'a> Default for SubscribedToContractArgs<'a> { + #[inline] + fn default() -> Self { + SubscribedToContractArgs { + requester: None, // required field + transaction: None, // required field + key: None, // required field + contract_location: 0.0, + at_peer: None, // required field + at_peer_location: 0.0, + timestamp: 0, + } + } + } + + pub struct SubscribedToContractBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, + } + impl<'a: 'b, 'b> SubscribedToContractBuilder<'a, 'b> { + #[inline] + pub fn add_requester(&mut self, requester: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>( + SubscribedToContract::VT_REQUESTER, + requester, + ); + } + #[inline] + pub fn add_transaction(&mut self, transaction: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>( + SubscribedToContract::VT_TRANSACTION, + transaction, + ); + } + #[inline] + pub fn add_key(&mut self, key: flatbuffers::WIPOffset<&'b str>) { + self.fbb_ + .push_slot_always::>(SubscribedToContract::VT_KEY, key); + } + #[inline] + pub fn add_contract_location(&mut self, contract_location: f64) { + self.fbb_.push_slot::( + SubscribedToContract::VT_CONTRACT_LOCATION, + contract_location, + 0.0, + ); + } + #[inline] + pub fn add_at_peer(&mut self, at_peer: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>( + SubscribedToContract::VT_AT_PEER, + at_peer, + ); + } + #[inline] + pub fn add_at_peer_location(&mut self, at_peer_location: f64) { + self.fbb_.push_slot::( + SubscribedToContract::VT_AT_PEER_LOCATION, + at_peer_location, + 0.0, + ); + } + #[inline] + pub fn add_timestamp(&mut self, timestamp: u64) { + self.fbb_ + .push_slot::(SubscribedToContract::VT_TIMESTAMP, timestamp, 0); + } + #[inline] + pub fn new( + _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, + ) -> SubscribedToContractBuilder<'a, 'b> { + let start = _fbb.start_table(); + SubscribedToContractBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + self.fbb_ + .required(o, SubscribedToContract::VT_REQUESTER, "requester"); + self.fbb_ + .required(o, SubscribedToContract::VT_TRANSACTION, "transaction"); + self.fbb_.required(o, SubscribedToContract::VT_KEY, "key"); + self.fbb_ + .required(o, SubscribedToContract::VT_AT_PEER, "at_peer"); + flatbuffers::WIPOffset::new(o.value()) + } + } + + impl core::fmt::Debug for SubscribedToContract<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("SubscribedToContract"); + ds.field("requester", &self.requester()); + ds.field("transaction", &self.transaction()); + ds.field("key", &self.key()); + ds.field("contract_location", &self.contract_location()); + ds.field("at_peer", &self.at_peer()); + ds.field("at_peer_location", &self.at_peer_location()); + ds.field("timestamp", &self.timestamp()); + ds.finish() + } + } + pub enum ContractChangeOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct ContractChange<'a> { + pub _tab: flatbuffers::Table<'a>, + } + + impl<'a> flatbuffers::Follow<'a> for ContractChange<'a> { + type Inner = ContractChange<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } + } + } + + impl<'a> ContractChange<'a> { + pub const VT_CONTRACT_ID: flatbuffers::VOffsetT = 4; + pub const VT_CHANGE_TYPE: flatbuffers::VOffsetT = 6; + pub const VT_CHANGE: flatbuffers::VOffsetT = 8; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + ContractChange { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args ContractChangeArgs<'args>, + ) -> flatbuffers::WIPOffset> { + let mut builder = ContractChangeBuilder::new(_fbb); + if let Some(x) = args.change { + builder.add_change(x); + } + if let Some(x) = args.contract_id { + builder.add_contract_id(x); + } + builder.add_change_type(args.change_type); + builder.finish() + } + + #[inline] + pub fn contract_id(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::>(ContractChange::VT_CONTRACT_ID, None) + .unwrap() + } + } + #[inline] + pub fn change_type(&self) -> ContractChangeType { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::( + ContractChange::VT_CHANGE_TYPE, + Some(ContractChangeType::NONE), + ) + .unwrap() + } + } + #[inline] + pub fn change(&self) -> Option> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::>>( + ContractChange::VT_CHANGE, + None, + ) + } + } + #[inline] + #[allow(non_snake_case)] + pub fn change_as_put_request(&self) -> Option> { + if self.change_type() == ContractChangeType::PutRequest { + self.change().map(|t| { + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + unsafe { PutRequest::init_from_table(t) } + }) + } else { + None + } + } + + #[inline] + #[allow(non_snake_case)] + pub fn change_as_put_success(&self) -> Option> { + if self.change_type() == ContractChangeType::PutSuccess { + self.change().map(|t| { + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + unsafe { PutSuccess::init_from_table(t) } + }) + } else { + None + } + } + + #[inline] + #[allow(non_snake_case)] + pub fn change_as_put_failure(&self) -> Option> { + if self.change_type() == ContractChangeType::PutFailure { + self.change().map(|t| { + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + unsafe { PutFailure::init_from_table(t) } + }) + } else { + None + } + } + + #[inline] + #[allow(non_snake_case)] + pub fn change_as_broadcast_emitted(&self) -> Option> { + if self.change_type() == ContractChangeType::BroadcastEmitted { + self.change().map(|t| { + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + unsafe { BroadcastEmitted::init_from_table(t) } + }) + } else { + None + } + } + + #[inline] + #[allow(non_snake_case)] + pub fn change_as_broadcast_received(&self) -> Option> { + if self.change_type() == ContractChangeType::BroadcastReceived { + self.change().map(|t| { + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + unsafe { BroadcastReceived::init_from_table(t) } + }) + } else { + None + } + } + + #[inline] + #[allow(non_snake_case)] + pub fn change_as_update_request(&self) -> Option> { + if self.change_type() == ContractChangeType::UpdateRequest { + self.change().map(|t| { + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + unsafe { UpdateRequest::init_from_table(t) } + }) + } else { + None + } + } + + #[inline] + #[allow(non_snake_case)] + pub fn change_as_update_success(&self) -> Option> { + if self.change_type() == ContractChangeType::UpdateSuccess { + self.change().map(|t| { + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + unsafe { UpdateSuccess::init_from_table(t) } + }) + } else { None } } @@ -3418,6 +4018,36 @@ pub mod topology { None } } + + #[inline] + #[allow(non_snake_case)] + pub fn change_as_get_contract(&self) -> Option> { + if self.change_type() == ContractChangeType::GetContract { + self.change().map(|t| { + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + unsafe { GetContract::init_from_table(t) } + }) + } else { + None + } + } + + #[inline] + #[allow(non_snake_case)] + pub fn change_as_subscribed_to_contract(&self) -> Option> { + if self.change_type() == ContractChangeType::SubscribedToContract { + self.change().map(|t| { + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + unsafe { SubscribedToContract::init_from_table(t) } + }) + } else { + None + } + } } impl flatbuffers::Verifiable for ContractChange<'_> { @@ -3439,6 +4069,8 @@ pub mod topology { ContractChangeType::UpdateRequest => v.verify_union_variant::>("ContractChangeType::UpdateRequest", pos), ContractChangeType::UpdateSuccess => v.verify_union_variant::>("ContractChangeType::UpdateSuccess", pos), ContractChangeType::UpdateFailure => v.verify_union_variant::>("ContractChangeType::UpdateFailure", pos), + ContractChangeType::GetContract => v.verify_union_variant::>("ContractChangeType::GetContract", pos), + ContractChangeType::SubscribedToContract => v.verify_union_variant::>("ContractChangeType::SubscribedToContract", pos), _ => Ok(()), } })? @@ -3592,6 +4224,26 @@ pub mod topology { ) } } + ContractChangeType::GetContract => { + if let Some(x) = self.change_as_get_contract() { + ds.field("change", &x) + } else { + ds.field( + "change", + &"InvalidFlatbuffer: Union discriminant does not match value.", + ) + } + } + ContractChangeType::SubscribedToContract => { + if let Some(x) = self.change_as_subscribed_to_contract() { + ds.field("change", &x) + } else { + ds.field( + "change", + &"InvalidFlatbuffer: Union discriminant does not match value.", + ) + } + } _ => { let x: Option<()> = None; ds.field("change", &x) diff --git a/crates/core/src/tracing.rs b/crates/core/src/tracing.rs index 2f621fc1c..ddf7c02c2 100644 --- a/crates/core/src/tracing.rs +++ b/crates/core/src/tracing.rs @@ -274,18 +274,31 @@ impl<'a> NetEventLog<'a> { timestamp: chrono::Utc::now().timestamp() as u64, }), NetMessageV1::Get(GetMsg::ReturnGet { + id, key, value: StoreResponse { state: Some(_), .. }, + sender, + target, .. - }) => EventKind::Get { key: *key }, + }) => EventKind::Get { + id: *id, + key: *key, + timestamp: chrono::Utc::now().timestamp() as u64, + requester: target.clone(), + target: sender.clone(), + }, NetMessageV1::Subscribe(SubscribeMsg::ReturnSub { + id, subscribed: true, key, sender, - .. + target, }) => EventKind::Subscribed { + id: *id, key: *key, at: sender.clone(), + timestamp: chrono::Utc::now().timestamp() as u64, + requester: target.clone(), }, _ => EventKind::Ignored, }; @@ -554,6 +567,7 @@ async fn send_to_metrics_server( *timestamp, contract_location.as_f64(), ); + ws_stream.send(Message::Binary(msg.into())).await } EventKind::Put(PutEvent::PutSuccess { @@ -609,12 +623,51 @@ async fn send_to_metrics_server( let contract_location = Location::from_contract_key(key.as_bytes()); let msg = ContractChange::broadcast_received_msg( id.to_string(), + requester.to_string(), target.to_string(), + key.to_string(), + *timestamp, + contract_location.as_f64(), + ); + ws_stream.send(Message::Binary(msg.into())).await + } + EventKind::Get { + id, + key, + timestamp, + requester, + target, + } => { + let contract_location = Location::from_contract_key(key.as_bytes()); + let msg = ContractChange::get_contract_msg( requester.to_string(), + target.to_string(), + id.to_string(), key.to_string(), + contract_location.as_f64(), *timestamp, + ); + + ws_stream.send(Message::Binary(msg.into())).await + } + EventKind::Subscribed { + id, + key, + at, + timestamp, + requester, + } => { + let contract_location = Location::from_contract_key(key.as_bytes()); + let msg = ContractChange::subscribed_msg( + requester.to_string(), + id.to_string(), + key.to_string(), contract_location.as_f64(), + at.peer.to_string(), + at.location.unwrap().as_f64(), + *timestamp, ); + ws_stream.send(Message::Binary(msg.into())).await } _ => Ok(()), @@ -921,13 +974,20 @@ enum EventKind { Put(PutEvent), // todo: make this a sequence like Put Get { + id: Transaction, key: ContractKey, + timestamp: u64, + requester: PeerKeyLocation, + target: PeerKeyLocation, }, Route(RouteEvent), // todo: add update sequences too Subscribed { + id: Transaction, key: ContractKey, at: PeerKeyLocation, + timestamp: u64, + requester: PeerKeyLocation, }, Ignored, Disconnected { diff --git a/crates/fdev/src/network_metrics_server.rs b/crates/fdev/src/network_metrics_server.rs index b1c916b7f..e88067587 100644 --- a/crates/fdev/src/network_metrics_server.rs +++ b/crates/fdev/src/network_metrics_server.rs @@ -255,6 +255,44 @@ async fn pull_interface(ws: WebSocket, state: Arc) -> anyhow::Resul *contract_location, ) } + Change::GetContract { + requester, + transaction, + key, + contract_location, + timestamp, + target, + } => { + tracing::info!("sending get contract"); + ContractChange::get_contract_msg( + requester, + target, + transaction, + key, + *contract_location, + *timestamp, + ) + } + Change::SubscribedToContract { + requester, + transaction, + key, + contract_location, + at_peer, + at_peer_location, + timestamp, + } => { + tracing::info!("sending subscribed to contract"); + ContractChange::subscribed_msg( + requester, + transaction, + key, + *contract_location, + at_peer, + *at_peer_location, + *timestamp, + ) + } _ => continue, }; @@ -359,6 +397,44 @@ async fn pull_interface(ws: WebSocket, state: Arc) -> anyhow::Resul ); tx.send(Message::Binary(msg)).await?; } + Change::GetContract { + requester, + transaction, + key, + contract_location, + timestamp, + target, + } => { + let msg = ContractChange::get_contract_msg( + requester, + target, + transaction, + key, + contract_location, + timestamp, + ); + tx.send(Message::Binary(msg)).await?; + } + Change::SubscribedToContract { + requester, + transaction, + key, + contract_location, + at_peer, + at_peer_location, + timestamp, + } => { + let msg = ContractChange::subscribed_msg( + requester, + transaction, + key, + contract_location, + at_peer, + at_peer_location, + timestamp, + ); + tx.send(Message::Binary(msg)).await?; + } } } Ok(()) @@ -430,6 +506,23 @@ pub(crate) enum Change { timestamp: u64, contract_location: f64, }, + GetContract { + requester: String, + transaction: String, + key: String, + contract_location: f64, + timestamp: u64, + target: String, + }, + SubscribedToContract { + requester: String, + transaction: String, + key: String, + contract_location: f64, + at_peer: String, + at_peer_location: f64, + timestamp: u64, + }, } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)] @@ -670,9 +763,6 @@ impl ServerState { match self.transactions_data.entry(tx_id.clone()) { dashmap::mapref::entry::Entry::Occupied(mut occ) => { - tracing::info!( - "found transaction data, adding BroadcastEmitted to history" - ); let changes = occ.get_mut(); changes.push(Change::BroadcastEmitted { tx_id: tx_id.clone(), @@ -690,8 +780,7 @@ impl ServerState { } dashmap::mapref::entry::Entry::Vacant(_vac) => { // this should not happen - tracing::error!("this tx should be included on transactions_data. It should exists a PutRequest before BroadcastEmitted."); - unreachable!(); + unreachable!("this tx should be included on transactions_data. It should exists a PutRequest before BroadcastEmitted."); } } @@ -731,9 +820,6 @@ impl ServerState { match self.transactions_data.entry(tx_id.clone()) { dashmap::mapref::entry::Entry::Occupied(mut occ) => { - tracing::info!( - "found transaction data, adding BroadcastReceived to history" - ); let changes = occ.get_mut(); changes.push(Change::BroadcastReceived { tx_id: tx_id.clone(), @@ -748,9 +834,17 @@ impl ServerState { //connections.dedup(); } dashmap::mapref::entry::Entry::Vacant(_vac) => { - // this should not happen - tracing::error!("this tx should be included on transactions_data. It should exists a PutRequest before BroadcastReceived."); - unreachable!(); + self.transactions_data.insert( + tx_id.clone(), + vec![Change::BroadcastReceived { + tx_id: tx_id.clone(), + key: key.clone(), + requester: requester.clone(), + target: target.clone(), + timestamp, + contract_location, + }], + ); } } @@ -765,6 +859,144 @@ impl ServerState { contract_location, }); } + ChangesWrapper::ContractChange(ContractChange::GetContract(get_contract_data)) => { + let requester = get_contract_data.requester().to_string(); + let transaction = get_contract_data.transaction().to_string(); + let key = get_contract_data.key().to_string(); + let contract_location = get_contract_data.contract_location(); + let timestamp = get_contract_data.timestamp(); + let target = get_contract_data.target().to_string(); + + if requester.is_empty() { + return Err(anyhow::anyhow!("requester is empty")); + } + + if transaction.is_empty() { + return Err(anyhow::anyhow!("transaction is empty")); + } + + if key.is_empty() { + return Err(anyhow::anyhow!("key is empty")); + } + + if contract_location.is_nan() { + return Err(anyhow::anyhow!("contract_location is not a number")); + } + + if timestamp == 0 { + return Err(anyhow::anyhow!("timestamp is invalid")); + } + + if target.is_empty() { + return Err(anyhow::anyhow!("target is empty")); + } + + if let Some(mut transactions) = self.transactions_data.get_mut(&transaction) { + transactions.push(Change::GetContract { + requester: requester.clone(), + transaction: transaction.clone(), + key: key.clone(), + contract_location, + timestamp, + target: target.clone(), + }); + } else { + self.transactions_data.insert( + transaction.clone(), + vec![Change::GetContract { + requester: requester.clone(), + transaction: transaction.clone(), + key: key.clone(), + contract_location, + timestamp, + target: target.clone(), + }], + ); + } + + tracing::debug!(%key, %contract_location, "checking values from save_record -- get_contract"); + + let _ = self.changes.send(Change::GetContract { + requester, + transaction, + key, + contract_location, + timestamp, + target, + }); + } + ChangesWrapper::ContractChange(ContractChange::SubscribedToContract( + subscribe_data, + )) => { + let requester = subscribe_data.requester().to_string(); + let transaction = subscribe_data.transaction().to_string(); + let key = subscribe_data.key().to_string(); + let contract_location = subscribe_data.contract_location(); + let at_peer = subscribe_data.at_peer().to_string(); + let at_peer_location = subscribe_data.at_peer_location(); + let timestamp = subscribe_data.timestamp(); + + if requester.is_empty() { + return Err(anyhow::anyhow!("requester is empty")); + } + + if transaction.is_empty() { + return Err(anyhow::anyhow!("transaction is empty")); + } + + if key.is_empty() { + return Err(anyhow::anyhow!("key is empty")); + } + + if at_peer.is_empty() { + return Err(anyhow::anyhow!("at_peer is empty")); + } + + if contract_location.is_nan() { + return Err(anyhow::anyhow!("contract_location is not a number")); + } + + if timestamp == 0 { + return Err(anyhow::anyhow!("timestamp is invalid")); + } + + if let Some(mut transactions_list) = self.transactions_data.get_mut(&transaction) { + transactions_list.push(Change::SubscribedToContract { + requester: requester.clone(), + transaction: transaction.clone(), + key: key.clone(), + contract_location, + at_peer: at_peer.clone(), + at_peer_location, + timestamp, + }); + } else { + self.transactions_data.insert( + transaction.clone(), + vec![Change::SubscribedToContract { + requester: requester.clone(), + transaction: transaction.clone(), + key: key.clone(), + contract_location, + at_peer: at_peer.clone(), + at_peer_location, + timestamp, + }], + ); + } + + tracing::debug!(%key, %contract_location, "checking values from save_record -- subscribed_to msg"); + + let _ = self.changes.send(Change::SubscribedToContract { + requester, + transaction, + key, + contract_location, + at_peer, + at_peer_location, + timestamp, + }); + } _ => unreachable!(), } diff --git a/network-monitor/src/app.ts b/network-monitor/src/app.ts index db1f4ed4e..70f098e0c 100644 --- a/network-monitor/src/app.ts +++ b/network-monitor/src/app.ts @@ -4,15 +4,19 @@ import { handleChange } from "./topology"; import { handleBroadcastEmitted, handleBroadcastReceived, + handleGetContract, handlePutRequest, handlePutSuccess, + handleSubscribedToContract, } from "./transactions-data"; import { get_change_type, parse_broadcast_emitted_msg, parse_broadcast_received_msg, + parse_get_contract_msg_data, parse_put_request_msg_data, parse_put_success_msg_data, + parse_subscribed_to_contract_msg_data, } from "./utils"; import { ChangeType } from "./type_definitions"; import { unionToContractChangeType } from "./generated/topology/contract-change-type"; @@ -61,6 +65,62 @@ function handleChanges(event: MessageEvent) { contractChange.changeType() ); + if (now_change_type == ChangeType.GET_CONTRACT) { + let { + transaction, + requester, + key, + contract_location, + change_type, + timestamp, + target, + } = parse_get_contract_msg_data( + contractChange, + contractChange.changeType() + ); + + handleGetContract( + transaction, + requester, + key, + contract_location, + change_type, + timestamp, + target + ); + + return; + } + + if (now_change_type == ChangeType.SUBSCRIBED_TO_CONTRACT) { + let { + transaction, + requester, + key, + contract_location, + change_type, + at_peer, + at_peer_location, + timestamp, + } = parse_subscribed_to_contract_msg_data( + contractChange, + contractChange.changeType() + ); + + handleSubscribedToContract( + transaction, + requester, + key, + contract_location, + change_type, + at_peer, + at_peer_location, + timestamp + ); + + return; + } + if (now_change_type == ChangeType.BROADCAST_EMITTED) { let { transaction, diff --git a/network-monitor/src/generated/topology.ts b/network-monitor/src/generated/topology.ts index a72d72306..efc7923e0 100644 --- a/network-monitor/src/generated/topology.ts +++ b/network-monitor/src/generated/topology.ts @@ -7,6 +7,7 @@ export { ContractChange } from "./topology/contract-change"; export { ContractChangeType } from "./topology/contract-change-type"; export { ControllerResponse } from "./topology/controller-response"; export { Error, ErrorT } from "./topology/error"; +export { GetContract } from "./topology/get-contract"; export { Ok, OkT } from "./topology/ok"; export { PeerChange, PeerChangeT } from "./topology/peer-change"; export { PeerChangeType } from "./topology/peer-change-type"; @@ -18,6 +19,7 @@ export { RemovedConnectionT, } from "./topology/removed-connection"; export { Response } from "./topology/response"; +export { SubscribedToContract } from "./topology/subscribed-to-contract"; export { UpdateFailure } from "./topology/update-failure"; export { UpdateRequest } from "./topology/update-request"; export { UpdateSuccess } from "./topology/update-success"; diff --git a/network-monitor/src/generated/topology/contract-change-type.ts b/network-monitor/src/generated/topology/contract-change-type.ts index 5f314c265..a1d2ed697 100644 --- a/network-monitor/src/generated/topology/contract-change-type.ts +++ b/network-monitor/src/generated/topology/contract-change-type.ts @@ -2,9 +2,11 @@ import { BroadcastEmitted } from "../topology/broadcast-emitted"; import { BroadcastReceived } from "../topology/broadcast-received"; +import { GetContract } from "../topology/get-contract"; import { PutFailure } from "../topology/put-failure"; import { PutRequest } from "../topology/put-request"; import { PutSuccess } from "../topology/put-success"; +import { SubscribedToContract } from "../topology/subscribed-to-contract"; import { UpdateFailure } from "../topology/update-failure"; import { UpdateRequest } from "../topology/update-request"; import { UpdateSuccess } from "../topology/update-success"; @@ -19,6 +21,8 @@ export enum ContractChangeType { UpdateRequest = 6, UpdateSuccess = 7, UpdateFailure = 8, + GetContract = 9, + SubscribedToContract = 10, } export function unionToContractChangeType( @@ -27,18 +31,22 @@ export function unionToContractChangeType( obj: | BroadcastEmitted | BroadcastReceived + | GetContract | PutFailure | PutRequest | PutSuccess + | SubscribedToContract | UpdateFailure | UpdateRequest | UpdateSuccess ) => | BroadcastEmitted | BroadcastReceived + | GetContract | PutFailure | PutRequest | PutSuccess + | SubscribedToContract | UpdateFailure | UpdateRequest | UpdateSuccess @@ -46,9 +54,11 @@ export function unionToContractChangeType( ): | BroadcastEmitted | BroadcastReceived + | GetContract | PutFailure | PutRequest | PutSuccess + | SubscribedToContract | UpdateFailure | UpdateRequest | UpdateSuccess @@ -72,6 +82,12 @@ export function unionToContractChangeType( return accessor(new UpdateSuccess())! as UpdateSuccess; case "UpdateFailure": return accessor(new UpdateFailure())! as UpdateFailure; + case "GetContract": + return accessor(new GetContract())! as GetContract; + case "SubscribedToContract": + return accessor( + new SubscribedToContract() + )! as SubscribedToContract; default: return null; } @@ -84,18 +100,22 @@ export function unionListToContractChangeType( obj: | BroadcastEmitted | BroadcastReceived + | GetContract | PutFailure | PutRequest | PutSuccess + | SubscribedToContract | UpdateFailure | UpdateRequest | UpdateSuccess ) => | BroadcastEmitted | BroadcastReceived + | GetContract | PutFailure | PutRequest | PutSuccess + | SubscribedToContract | UpdateFailure | UpdateRequest | UpdateSuccess @@ -104,9 +124,11 @@ export function unionListToContractChangeType( ): | BroadcastEmitted | BroadcastReceived + | GetContract | PutFailure | PutRequest | PutSuccess + | SubscribedToContract | UpdateFailure | UpdateRequest | UpdateSuccess @@ -133,6 +155,13 @@ export function unionListToContractChangeType( return accessor(index, new UpdateSuccess())! as UpdateSuccess; case "UpdateFailure": return accessor(index, new UpdateFailure())! as UpdateFailure; + case "GetContract": + return accessor(index, new GetContract())! as GetContract; + case "SubscribedToContract": + return accessor( + index, + new SubscribedToContract() + )! as SubscribedToContract; default: return null; } diff --git a/schemas/flatbuffers/topology/broadcast-received.ts b/network-monitor/src/generated/topology/get-contract.ts similarity index 60% rename from schemas/flatbuffers/topology/broadcast-received.ts rename to network-monitor/src/generated/topology/get-contract.ts index 865c42fb1..c5adf1f7b 100644 --- a/schemas/flatbuffers/topology/broadcast-received.ts +++ b/network-monitor/src/generated/topology/get-contract.ts @@ -2,27 +2,27 @@ import * as flatbuffers from 'flatbuffers'; -export class BroadcastReceived { +export class GetContract { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):BroadcastReceived { + __init(i:number, bb:flatbuffers.ByteBuffer):GetContract { this.bb_pos = i; this.bb = bb; return this; } -static getRootAsBroadcastReceived(bb:flatbuffers.ByteBuffer, obj?:BroadcastReceived):BroadcastReceived { - return (obj || new BroadcastReceived()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +static getRootAsGetContract(bb:flatbuffers.ByteBuffer, obj?:GetContract):GetContract { + return (obj || new GetContract()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } -static getSizePrefixedRootAsBroadcastReceived(bb:flatbuffers.ByteBuffer, obj?:BroadcastReceived):BroadcastReceived { +static getSizePrefixedRootAsGetContract(bb:flatbuffers.ByteBuffer, obj?:GetContract):GetContract { bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new BroadcastReceived()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + return (obj || new GetContract()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } -transaction():string|null -transaction(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -transaction(optionalEncoding?:any):string|Uint8Array|null { +requester():string|null +requester(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +requester(optionalEncoding?:any):string|Uint8Array|null { const offset = this.bb!.__offset(this.bb_pos, 4); return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; } @@ -34,9 +34,9 @@ target(optionalEncoding?:any):string|Uint8Array|null { return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; } -requester():string|null -requester(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -requester(optionalEncoding?:any):string|Uint8Array|null { +transaction():string|null +transaction(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +transaction(optionalEncoding?:any):string|Uint8Array|null { const offset = this.bb!.__offset(this.bb_pos, 8); return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; } @@ -48,61 +48,61 @@ key(optionalEncoding?:any):string|Uint8Array|null { return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; } -timestamp():bigint { +contractLocation():number { const offset = this.bb!.__offset(this.bb_pos, 12); - return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0'); + return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0; } -contractLocation():number { +timestamp():bigint { const offset = this.bb!.__offset(this.bb_pos, 14); - return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0; + return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0'); } -static startBroadcastReceived(builder:flatbuffers.Builder) { +static startGetContract(builder:flatbuffers.Builder) { builder.startObject(6); } -static addTransaction(builder:flatbuffers.Builder, transactionOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, transactionOffset, 0); +static addRequester(builder:flatbuffers.Builder, requesterOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, requesterOffset, 0); } static addTarget(builder:flatbuffers.Builder, targetOffset:flatbuffers.Offset) { builder.addFieldOffset(1, targetOffset, 0); } -static addRequester(builder:flatbuffers.Builder, requesterOffset:flatbuffers.Offset) { - builder.addFieldOffset(2, requesterOffset, 0); +static addTransaction(builder:flatbuffers.Builder, transactionOffset:flatbuffers.Offset) { + builder.addFieldOffset(2, transactionOffset, 0); } static addKey(builder:flatbuffers.Builder, keyOffset:flatbuffers.Offset) { builder.addFieldOffset(3, keyOffset, 0); } -static addTimestamp(builder:flatbuffers.Builder, timestamp:bigint) { - builder.addFieldInt64(4, timestamp, BigInt('0')); +static addContractLocation(builder:flatbuffers.Builder, contractLocation:number) { + builder.addFieldFloat64(4, contractLocation, 0.0); } -static addContractLocation(builder:flatbuffers.Builder, contractLocation:number) { - builder.addFieldFloat64(5, contractLocation, 0.0); +static addTimestamp(builder:flatbuffers.Builder, timestamp:bigint) { + builder.addFieldInt64(5, timestamp, BigInt('0')); } -static endBroadcastReceived(builder:flatbuffers.Builder):flatbuffers.Offset { +static endGetContract(builder:flatbuffers.Builder):flatbuffers.Offset { const offset = builder.endObject(); - builder.requiredField(offset, 4) // transaction + builder.requiredField(offset, 4) // requester builder.requiredField(offset, 6) // target - builder.requiredField(offset, 8) // requester + builder.requiredField(offset, 8) // transaction builder.requiredField(offset, 10) // key return offset; } -static createBroadcastReceived(builder:flatbuffers.Builder, transactionOffset:flatbuffers.Offset, targetOffset:flatbuffers.Offset, requesterOffset:flatbuffers.Offset, keyOffset:flatbuffers.Offset, timestamp:bigint, contractLocation:number):flatbuffers.Offset { - BroadcastReceived.startBroadcastReceived(builder); - BroadcastReceived.addTransaction(builder, transactionOffset); - BroadcastReceived.addTarget(builder, targetOffset); - BroadcastReceived.addRequester(builder, requesterOffset); - BroadcastReceived.addKey(builder, keyOffset); - BroadcastReceived.addTimestamp(builder, timestamp); - BroadcastReceived.addContractLocation(builder, contractLocation); - return BroadcastReceived.endBroadcastReceived(builder); +static createGetContract(builder:flatbuffers.Builder, requesterOffset:flatbuffers.Offset, targetOffset:flatbuffers.Offset, transactionOffset:flatbuffers.Offset, keyOffset:flatbuffers.Offset, contractLocation:number, timestamp:bigint):flatbuffers.Offset { + GetContract.startGetContract(builder); + GetContract.addRequester(builder, requesterOffset); + GetContract.addTarget(builder, targetOffset); + GetContract.addTransaction(builder, transactionOffset); + GetContract.addKey(builder, keyOffset); + GetContract.addContractLocation(builder, contractLocation); + GetContract.addTimestamp(builder, timestamp); + return GetContract.endGetContract(builder); } } diff --git a/network-monitor/src/generated/topology/put-failure.ts b/network-monitor/src/generated/topology/put-failure.ts index dfacd429c..745cb8a60 100644 --- a/network-monitor/src/generated/topology/put-failure.ts +++ b/network-monitor/src/generated/topology/put-failure.ts @@ -48,8 +48,13 @@ key(optionalEncoding?:any):string|Uint8Array|null { return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; } +timestamp():bigint { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0'); +} + static startPutFailure(builder:flatbuffers.Builder) { - builder.startObject(4); + builder.startObject(5); } static addTransaction(builder:flatbuffers.Builder, transactionOffset:flatbuffers.Offset) { @@ -68,6 +73,10 @@ static addKey(builder:flatbuffers.Builder, keyOffset:flatbuffers.Offset) { builder.addFieldOffset(3, keyOffset, 0); } +static addTimestamp(builder:flatbuffers.Builder, timestamp:bigint) { + builder.addFieldInt64(4, timestamp, BigInt('0')); +} + static endPutFailure(builder:flatbuffers.Builder):flatbuffers.Offset { const offset = builder.endObject(); builder.requiredField(offset, 4) // transaction @@ -77,12 +86,13 @@ static endPutFailure(builder:flatbuffers.Builder):flatbuffers.Offset { return offset; } -static createPutFailure(builder:flatbuffers.Builder, transactionOffset:flatbuffers.Offset, requesterOffset:flatbuffers.Offset, targetOffset:flatbuffers.Offset, keyOffset:flatbuffers.Offset):flatbuffers.Offset { +static createPutFailure(builder:flatbuffers.Builder, transactionOffset:flatbuffers.Offset, requesterOffset:flatbuffers.Offset, targetOffset:flatbuffers.Offset, keyOffset:flatbuffers.Offset, timestamp:bigint):flatbuffers.Offset { PutFailure.startPutFailure(builder); PutFailure.addTransaction(builder, transactionOffset); PutFailure.addRequester(builder, requesterOffset); PutFailure.addTarget(builder, targetOffset); PutFailure.addKey(builder, keyOffset); + PutFailure.addTimestamp(builder, timestamp); return PutFailure.endPutFailure(builder); } } diff --git a/network-monitor/src/generated/topology/subscribed-to-contract.ts b/network-monitor/src/generated/topology/subscribed-to-contract.ts new file mode 100644 index 000000000..c54329bc5 --- /dev/null +++ b/network-monitor/src/generated/topology/subscribed-to-contract.ts @@ -0,0 +1,118 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + +export class SubscribedToContract { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):SubscribedToContract { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsSubscribedToContract(bb:flatbuffers.ByteBuffer, obj?:SubscribedToContract):SubscribedToContract { + return (obj || new SubscribedToContract()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsSubscribedToContract(bb:flatbuffers.ByteBuffer, obj?:SubscribedToContract):SubscribedToContract { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new SubscribedToContract()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +requester():string|null +requester(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +requester(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +transaction():string|null +transaction(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +transaction(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +key():string|null +key(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +key(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 8); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +contractLocation():number { + const offset = this.bb!.__offset(this.bb_pos, 10); + return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0; +} + +atPeer():string|null +atPeer(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +atPeer(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +atPeerLocation():number { + const offset = this.bb!.__offset(this.bb_pos, 14); + return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0; +} + +timestamp():bigint { + const offset = this.bb!.__offset(this.bb_pos, 16); + return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0'); +} + +static startSubscribedToContract(builder:flatbuffers.Builder) { + builder.startObject(7); +} + +static addRequester(builder:flatbuffers.Builder, requesterOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, requesterOffset, 0); +} + +static addTransaction(builder:flatbuffers.Builder, transactionOffset:flatbuffers.Offset) { + builder.addFieldOffset(1, transactionOffset, 0); +} + +static addKey(builder:flatbuffers.Builder, keyOffset:flatbuffers.Offset) { + builder.addFieldOffset(2, keyOffset, 0); +} + +static addContractLocation(builder:flatbuffers.Builder, contractLocation:number) { + builder.addFieldFloat64(3, contractLocation, 0.0); +} + +static addAtPeer(builder:flatbuffers.Builder, atPeerOffset:flatbuffers.Offset) { + builder.addFieldOffset(4, atPeerOffset, 0); +} + +static addAtPeerLocation(builder:flatbuffers.Builder, atPeerLocation:number) { + builder.addFieldFloat64(5, atPeerLocation, 0.0); +} + +static addTimestamp(builder:flatbuffers.Builder, timestamp:bigint) { + builder.addFieldInt64(6, timestamp, BigInt('0')); +} + +static endSubscribedToContract(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + builder.requiredField(offset, 4) // requester + builder.requiredField(offset, 6) // transaction + builder.requiredField(offset, 8) // key + builder.requiredField(offset, 12) // at_peer + return offset; +} + +static createSubscribedToContract(builder:flatbuffers.Builder, requesterOffset:flatbuffers.Offset, transactionOffset:flatbuffers.Offset, keyOffset:flatbuffers.Offset, contractLocation:number, atPeerOffset:flatbuffers.Offset, atPeerLocation:number, timestamp:bigint):flatbuffers.Offset { + SubscribedToContract.startSubscribedToContract(builder); + SubscribedToContract.addRequester(builder, requesterOffset); + SubscribedToContract.addTransaction(builder, transactionOffset); + SubscribedToContract.addKey(builder, keyOffset); + SubscribedToContract.addContractLocation(builder, contractLocation); + SubscribedToContract.addAtPeer(builder, atPeerOffset); + SubscribedToContract.addAtPeerLocation(builder, atPeerLocation); + SubscribedToContract.addTimestamp(builder, timestamp); + return SubscribedToContract.endSubscribedToContract(builder); +} +} diff --git a/network-monitor/src/generated/topology/update-failure.ts b/network-monitor/src/generated/topology/update-failure.ts index f25f2ff89..073342fa8 100644 --- a/network-monitor/src/generated/topology/update-failure.ts +++ b/network-monitor/src/generated/topology/update-failure.ts @@ -48,8 +48,13 @@ key(optionalEncoding?:any):string|Uint8Array|null { return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; } +timestamp():bigint { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0'); +} + static startUpdateFailure(builder:flatbuffers.Builder) { - builder.startObject(4); + builder.startObject(5); } static addTransaction(builder:flatbuffers.Builder, transactionOffset:flatbuffers.Offset) { @@ -68,6 +73,10 @@ static addKey(builder:flatbuffers.Builder, keyOffset:flatbuffers.Offset) { builder.addFieldOffset(3, keyOffset, 0); } +static addTimestamp(builder:flatbuffers.Builder, timestamp:bigint) { + builder.addFieldInt64(4, timestamp, BigInt('0')); +} + static endUpdateFailure(builder:flatbuffers.Builder):flatbuffers.Offset { const offset = builder.endObject(); builder.requiredField(offset, 4) // transaction @@ -77,12 +86,13 @@ static endUpdateFailure(builder:flatbuffers.Builder):flatbuffers.Offset { return offset; } -static createUpdateFailure(builder:flatbuffers.Builder, transactionOffset:flatbuffers.Offset, requesterOffset:flatbuffers.Offset, targetOffset:flatbuffers.Offset, keyOffset:flatbuffers.Offset):flatbuffers.Offset { +static createUpdateFailure(builder:flatbuffers.Builder, transactionOffset:flatbuffers.Offset, requesterOffset:flatbuffers.Offset, targetOffset:flatbuffers.Offset, keyOffset:flatbuffers.Offset, timestamp:bigint):flatbuffers.Offset { UpdateFailure.startUpdateFailure(builder); UpdateFailure.addTransaction(builder, transactionOffset); UpdateFailure.addRequester(builder, requesterOffset); UpdateFailure.addTarget(builder, targetOffset); UpdateFailure.addKey(builder, keyOffset); + UpdateFailure.addTimestamp(builder, timestamp); return UpdateFailure.endUpdateFailure(builder); } } diff --git a/network-monitor/src/generated/topology/update-success.ts b/network-monitor/src/generated/topology/update-success.ts index 535fdff86..8f41f56e1 100644 --- a/network-monitor/src/generated/topology/update-success.ts +++ b/network-monitor/src/generated/topology/update-success.ts @@ -48,8 +48,13 @@ key(optionalEncoding?:any):string|Uint8Array|null { return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; } +timestamp():bigint { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0'); +} + static startUpdateSuccess(builder:flatbuffers.Builder) { - builder.startObject(4); + builder.startObject(5); } static addTransaction(builder:flatbuffers.Builder, transactionOffset:flatbuffers.Offset) { @@ -68,6 +73,10 @@ static addKey(builder:flatbuffers.Builder, keyOffset:flatbuffers.Offset) { builder.addFieldOffset(3, keyOffset, 0); } +static addTimestamp(builder:flatbuffers.Builder, timestamp:bigint) { + builder.addFieldInt64(4, timestamp, BigInt('0')); +} + static endUpdateSuccess(builder:flatbuffers.Builder):flatbuffers.Offset { const offset = builder.endObject(); builder.requiredField(offset, 4) // transaction @@ -77,12 +86,13 @@ static endUpdateSuccess(builder:flatbuffers.Builder):flatbuffers.Offset { return offset; } -static createUpdateSuccess(builder:flatbuffers.Builder, transactionOffset:flatbuffers.Offset, requesterOffset:flatbuffers.Offset, targetOffset:flatbuffers.Offset, keyOffset:flatbuffers.Offset):flatbuffers.Offset { +static createUpdateSuccess(builder:flatbuffers.Builder, transactionOffset:flatbuffers.Offset, requesterOffset:flatbuffers.Offset, targetOffset:flatbuffers.Offset, keyOffset:flatbuffers.Offset, timestamp:bigint):flatbuffers.Offset { UpdateSuccess.startUpdateSuccess(builder); UpdateSuccess.addTransaction(builder, transactionOffset); UpdateSuccess.addRequester(builder, requesterOffset); UpdateSuccess.addTarget(builder, targetOffset); UpdateSuccess.addKey(builder, keyOffset); + UpdateSuccess.addTimestamp(builder, timestamp); return UpdateSuccess.endUpdateSuccess(builder); } } diff --git a/network-monitor/src/transactions-data.ts b/network-monitor/src/transactions-data.ts index fb6df386e..8319a1fe9 100644 --- a/network-monitor/src/transactions-data.ts +++ b/network-monitor/src/transactions-data.ts @@ -191,3 +191,101 @@ export function handleBroadcastReceived( all_contracts.get(key)!.push(obj_data); } + +export function handleGetContract( + transaction_id: string, + requester: string, + contract_id: string, + contract_location: number, + change_type: ChangeType, + timestamp: number, + target: string +) { + let requester_location = parseFloat( + requester.split(" (@ ")[1].split(")")[0] + ); + requester = requester.split(" (@")[0]; + + let target_location = parseFloat(target.split(" (@ ")[1].split(")")[0]); + target = target.split(" (@")[0]; + + let obj_data = { + change_type, + transaction_id, + contract_id: contract_id, + target, + requester, + unique_id: + transaction_id + + contract_id + + contract_location + + requester + + change_type, + timestamp, + contract_location, + requester_location, + } as TransactionData; + + let tx_list = all_tx.get(transaction_id); + + if (tx_list) { + all_tx.set(transaction_id, [...tx_list, obj_data]); + } else { + all_tx.set(transaction_id, [obj_data]); + } + + const this_contract_data = all_contracts.get(contract_id); + if (this_contract_data) { + all_contracts.get(contract_id)!.push(obj_data); + } else { + all_contracts.set(contract_id, [obj_data]); + } +} + +export function handleSubscribedToContract( + transaction_id: string, + requester: string, + contract_id: string, + contract_location: number, + change_type: ChangeType, + at_peer: string, + at_peer_location: number, + timestamp: number +) { + let requester_location = parseFloat( + requester.split(" (@ ")[1].split(")")[0] + ); + requester = requester.split(" (@")[0]; + + let obj_data = { + change_type, + transaction_id, + contract_id: contract_id, + target: at_peer, + requester, + unique_id: + transaction_id + + contract_id + + contract_location + + requester + + change_type, + timestamp, + contract_location, + requester_location, + } as TransactionData; + + let tx_list = all_tx.get(transaction_id); + + if (tx_list) { + all_tx.set(transaction_id, [...tx_list, obj_data]); + } else { + all_tx.set(transaction_id, [obj_data]); + } + + const this_contract_data = all_contracts.get(contract_id); + if (this_contract_data) { + all_contracts.get(contract_id)!.push(obj_data); + } else { + all_contracts.set(contract_id, [obj_data]); + } +} diff --git a/network-monitor/src/type_definitions.ts b/network-monitor/src/type_definitions.ts index 8375da717..ad5f6e165 100644 --- a/network-monitor/src/type_definitions.ts +++ b/network-monitor/src/type_definitions.ts @@ -7,6 +7,8 @@ export enum ChangeType { PUT_FAILURE = "Put Failure", BROADCAST_EMITTED = "Broadcast Emitted", BROADCAST_RECEIVED = "Broadcast Received", + GET_CONTRACT = "Get Contract", + SUBSCRIBED_TO_CONTRACT = "Subscribed to Contract", } export type TransactionData = { diff --git a/network-monitor/src/utils.ts b/network-monitor/src/utils.ts index 953441186..dca76a677 100644 --- a/network-monitor/src/utils.ts +++ b/network-monitor/src/utils.ts @@ -21,6 +21,10 @@ export const get_change_type = ( return ChangeType.BROADCAST_EMITTED; case fbTopology.ContractChangeType.BroadcastReceived: return ChangeType.BROADCAST_RECEIVED; + case fbTopology.ContractChangeType.GetContract: + return ChangeType.GET_CONTRACT; + case fbTopology.ContractChangeType.SubscribedToContract: + return ChangeType.SUBSCRIBED_TO_CONTRACT; default: new Error("Invalid change type"); } @@ -270,6 +274,10 @@ export const get_peers_description_to_render = ( let change_type = peer.change_type; let peer_target = peer.target; + if (peer_target == peer_id) { + continue; + } + if (typeof peer_target == "string") { //peer_target = peer_target.split(" (@")[0].slice(-8); peer_target = [peer_target]; @@ -346,3 +354,102 @@ export const get_peers_caching_the_contract = ( return peers_caching_contract; }; + +export const parse_get_contract_msg_data = ( + contractChange: ContractChange, + changeType: fbTopology.ContractChangeType +) => { + let get_contract_obj = contractChange.change(new fbTopology.GetContract()); + + let transaction = get_contract_obj.transaction(); + + if (!transaction) { + throw new Error("Transaction ID not found"); + } + + let requester = get_contract_obj.requester(); + + if (!requester) { + throw new Error("Requester Peer not found"); + } + + let key = get_contract_obj.key(); + + if (!key) { + throw new Error("Contract Key not found"); + } + + let target = get_contract_obj.target(); + + if (!target) { + throw new Error("Target Peer not found"); + } + + let contract_location = get_contract_obj.contractLocation(); + + let timestamp = get_contract_obj.timestamp()!; + + let change_type = get_change_type(changeType)!; + + return { + transaction, + requester, + key, + contract_location, + change_type, + timestamp, + target, + }; +}; + +export const parse_subscribed_to_contract_msg_data = ( + contractChange: ContractChange, + changeType: fbTopology.ContractChangeType +) => { + let subscribed_to_contract_obj = contractChange.change( + new fbTopology.SubscribedToContract() + ); + + let transaction = subscribed_to_contract_obj.transaction(); + + if (!transaction) { + throw new Error("Transaction ID not found"); + } + + let requester = subscribed_to_contract_obj.requester(); + + if (!requester) { + throw new Error("Requester Peer not found"); + } + + let key = subscribed_to_contract_obj.key(); + + if (!key) { + throw new Error("Contract Key not found"); + } + + let at_peer = subscribed_to_contract_obj.atPeer(); + + if (!at_peer) { + throw new Error("At Peer not found"); + } + + let at_peer_location = subscribed_to_contract_obj.atPeerLocation(); + + let contract_location = subscribed_to_contract_obj.contractLocation(); + + let timestamp = subscribed_to_contract_obj.timestamp()!; + + let change_type = get_change_type(changeType)!; + + return { + transaction, + requester, + key, + contract_location, + change_type, + at_peer, + at_peer_location, + timestamp, + }; +}; diff --git a/schemas/flatbuffers/topology.fbs b/schemas/flatbuffers/topology.fbs index ec1ae17f7..69b79c3b4 100644 --- a/schemas/flatbuffers/topology.fbs +++ b/schemas/flatbuffers/topology.fbs @@ -72,6 +72,7 @@ table PutFailure { requester: string(required); target: string(required); key: string(required); + timestamp: uint64; } table UpdateSuccess { @@ -79,6 +80,7 @@ table UpdateSuccess { requester: string(required); target: string(required); key: string(required); + timestamp: uint64; } table UpdateFailure { @@ -86,6 +88,7 @@ table UpdateFailure { requester: string(required); target: string(required); key: string(required); + timestamp: uint64; } table BroadcastEmitted { @@ -109,6 +112,25 @@ table BroadcastReceived { contract_location: float64; } +table GetContract { + requester: string(required); + target: string(required); + transaction: string(required); + key: string(required); + contract_location: float64; + timestamp: uint64; +} + +table SubscribedToContract { + requester: string(required); + transaction: string(required); + key: string(required); + contract_location: float64; + at_peer: string(required); + at_peer_location: float64; + timestamp: uint64; +} + union ContractChangeType { PutRequest, PutSuccess, @@ -118,6 +140,9 @@ union ContractChangeType { UpdateRequest, UpdateSuccess, UpdateFailure, + GetContract, + SubscribedToContract + } table ContractChange { diff --git a/schemas/flatbuffers/topology.ts b/schemas/flatbuffers/topology.ts index 2f3dead61..f650bab60 100644 --- a/schemas/flatbuffers/topology.ts +++ b/schemas/flatbuffers/topology.ts @@ -1,20 +1,22 @@ // automatically generated by the FlatBuffers compiler, do not modify -export { AddedConnection } from "./topology/added-connection.js"; -export { BroadcastEmitted } from "./topology/broadcast-emitted.js"; -export { BroadcastReceived } from "./topology/broadcast-received.js"; -export { ContractChange } from "./topology/contract-change.js"; -export { ContractChangeType } from "./topology/contract-change-type.js"; -export { ControllerResponse } from "./topology/controller-response.js"; -export { Error } from "./topology/error.js"; -export { Ok } from "./topology/ok.js"; -export { PeerChange } from "./topology/peer-change.js"; -export { PeerChangeType } from "./topology/peer-change-type.js"; -export { PutFailure } from "./topology/put-failure.js"; -export { PutRequest } from "./topology/put-request.js"; -export { PutSuccess } from "./topology/put-success.js"; -export { RemovedConnection } from "./topology/removed-connection.js"; -export { Response } from "./topology/response.js"; -export { UpdateFailure } from "./topology/update-failure.js"; -export { UpdateRequest } from "./topology/update-request.js"; -export { UpdateSuccess } from "./topology/update-success.js"; +export { AddedConnection } from './topology/added-connection.js'; +export { BroadcastEmitted } from './topology/broadcast-emitted.js'; +export { BroadcastReceived } from './topology/broadcast-received.js'; +export { ContractChange } from './topology/contract-change.js'; +export { ContractChangeType } from './topology/contract-change-type.js'; +export { ControllerResponse } from './topology/controller-response.js'; +export { Error } from './topology/error.js'; +export { GetContract } from './topology/get-contract.js'; +export { Ok } from './topology/ok.js'; +export { PeerChange } from './topology/peer-change.js'; +export { PeerChangeType } from './topology/peer-change-type.js'; +export { PutFailure } from './topology/put-failure.js'; +export { PutRequest } from './topology/put-request.js'; +export { PutSuccess } from './topology/put-success.js'; +export { RemovedConnection } from './topology/removed-connection.js'; +export { Response } from './topology/response.js'; +export { SubscribedToContract } from './topology/subscribed-to-contract.js'; +export { UpdateFailure } from './topology/update-failure.js'; +export { UpdateRequest } from './topology/update-request.js'; +export { UpdateSuccess } from './topology/update-success.js'; diff --git a/schemas/flatbuffers/topology/added-connection.ts b/schemas/flatbuffers/topology/added-connection.ts deleted file mode 100644 index 13dca6d07..000000000 --- a/schemas/flatbuffers/topology/added-connection.ts +++ /dev/null @@ -1,94 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - -export class AddedConnection { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):AddedConnection { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsAddedConnection(bb:flatbuffers.ByteBuffer, obj?:AddedConnection):AddedConnection { - return (obj || new AddedConnection()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsAddedConnection(bb:flatbuffers.ByteBuffer, obj?:AddedConnection):AddedConnection { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new AddedConnection()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -transaction():string|null -transaction(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -transaction(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -from():string|null -from(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -from(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -fromLocation():number { - const offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0; -} - -to():string|null -to(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -to(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 10); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -toLocation():number { - const offset = this.bb!.__offset(this.bb_pos, 12); - return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0; -} - -static startAddedConnection(builder:flatbuffers.Builder) { - builder.startObject(5); -} - -static addTransaction(builder:flatbuffers.Builder, transactionOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, transactionOffset, 0); -} - -static addFrom(builder:flatbuffers.Builder, fromOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, fromOffset, 0); -} - -static addFromLocation(builder:flatbuffers.Builder, fromLocation:number) { - builder.addFieldFloat64(2, fromLocation, 0.0); -} - -static addTo(builder:flatbuffers.Builder, toOffset:flatbuffers.Offset) { - builder.addFieldOffset(3, toOffset, 0); -} - -static addToLocation(builder:flatbuffers.Builder, toLocation:number) { - builder.addFieldFloat64(4, toLocation, 0.0); -} - -static endAddedConnection(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - builder.requiredField(offset, 6) // from - builder.requiredField(offset, 10) // to - return offset; -} - -static createAddedConnection(builder:flatbuffers.Builder, transactionOffset:flatbuffers.Offset, fromOffset:flatbuffers.Offset, fromLocation:number, toOffset:flatbuffers.Offset, toLocation:number):flatbuffers.Offset { - AddedConnection.startAddedConnection(builder); - AddedConnection.addTransaction(builder, transactionOffset); - AddedConnection.addFrom(builder, fromOffset); - AddedConnection.addFromLocation(builder, fromLocation); - AddedConnection.addTo(builder, toOffset); - AddedConnection.addToLocation(builder, toLocation); - return AddedConnection.endAddedConnection(builder); -} -} diff --git a/schemas/flatbuffers/topology/broadcast-emitted.ts b/schemas/flatbuffers/topology/broadcast-emitted.ts deleted file mode 100644 index c915be061..000000000 --- a/schemas/flatbuffers/topology/broadcast-emitted.ts +++ /dev/null @@ -1,147 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - -export class BroadcastEmitted { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):BroadcastEmitted { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsBroadcastEmitted(bb:flatbuffers.ByteBuffer, obj?:BroadcastEmitted):BroadcastEmitted { - return (obj || new BroadcastEmitted()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsBroadcastEmitted(bb:flatbuffers.ByteBuffer, obj?:BroadcastEmitted):BroadcastEmitted { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new BroadcastEmitted()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -transaction():string|null -transaction(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -transaction(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -upstream():string|null -upstream(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -upstream(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -broadcastTo(index: number):string -broadcastTo(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array -broadcastTo(index: number,optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; -} - -broadcastToLength():number { - const offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -} - -broadcastedTo():number { - const offset = this.bb!.__offset(this.bb_pos, 10); - return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; -} - -key():string|null -key(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -key(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 12); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -sender():string|null -sender(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -sender(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 14); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -timestamp():bigint { - const offset = this.bb!.__offset(this.bb_pos, 16); - return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0'); -} - -contractLocation():number { - const offset = this.bb!.__offset(this.bb_pos, 18); - return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0; -} - -static startBroadcastEmitted(builder:flatbuffers.Builder) { - builder.startObject(8); -} - -static addTransaction(builder:flatbuffers.Builder, transactionOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, transactionOffset, 0); -} - -static addUpstream(builder:flatbuffers.Builder, upstreamOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, upstreamOffset, 0); -} - -static addBroadcastTo(builder:flatbuffers.Builder, broadcastToOffset:flatbuffers.Offset) { - builder.addFieldOffset(2, broadcastToOffset, 0); -} - -static createBroadcastToVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]!); - } - return builder.endVector(); -} - -static startBroadcastToVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(4, numElems, 4); -} - -static addBroadcastedTo(builder:flatbuffers.Builder, broadcastedTo:number) { - builder.addFieldInt32(3, broadcastedTo, 0); -} - -static addKey(builder:flatbuffers.Builder, keyOffset:flatbuffers.Offset) { - builder.addFieldOffset(4, keyOffset, 0); -} - -static addSender(builder:flatbuffers.Builder, senderOffset:flatbuffers.Offset) { - builder.addFieldOffset(5, senderOffset, 0); -} - -static addTimestamp(builder:flatbuffers.Builder, timestamp:bigint) { - builder.addFieldInt64(6, timestamp, BigInt('0')); -} - -static addContractLocation(builder:flatbuffers.Builder, contractLocation:number) { - builder.addFieldFloat64(7, contractLocation, 0.0); -} - -static endBroadcastEmitted(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - builder.requiredField(offset, 4) // transaction - builder.requiredField(offset, 6) // upstream - builder.requiredField(offset, 12) // key - builder.requiredField(offset, 14) // sender - return offset; -} - -static createBroadcastEmitted(builder:flatbuffers.Builder, transactionOffset:flatbuffers.Offset, upstreamOffset:flatbuffers.Offset, broadcastToOffset:flatbuffers.Offset, broadcastedTo:number, keyOffset:flatbuffers.Offset, senderOffset:flatbuffers.Offset, timestamp:bigint, contractLocation:number):flatbuffers.Offset { - BroadcastEmitted.startBroadcastEmitted(builder); - BroadcastEmitted.addTransaction(builder, transactionOffset); - BroadcastEmitted.addUpstream(builder, upstreamOffset); - BroadcastEmitted.addBroadcastTo(builder, broadcastToOffset); - BroadcastEmitted.addBroadcastedTo(builder, broadcastedTo); - BroadcastEmitted.addKey(builder, keyOffset); - BroadcastEmitted.addSender(builder, senderOffset); - BroadcastEmitted.addTimestamp(builder, timestamp); - BroadcastEmitted.addContractLocation(builder, contractLocation); - return BroadcastEmitted.endBroadcastEmitted(builder); -} -} diff --git a/schemas/flatbuffers/topology/contract-change-type.ts b/schemas/flatbuffers/topology/contract-change-type.ts deleted file mode 100644 index 028d7b8ca..000000000 --- a/schemas/flatbuffers/topology/contract-change-type.ts +++ /dev/null @@ -1,52 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import { PutFailure } from '../topology/put-failure.js'; -import { PutRequest } from '../topology/put-request.js'; -import { PutSuccess } from '../topology/put-success.js'; -import { UpdateFailure } from '../topology/update-failure.js'; -import { UpdateRequest } from '../topology/update-request.js'; -import { UpdateSuccess } from '../topology/update-success.js'; - - -export enum ContractChangeType { - NONE = 0, - PutRequest = 1, - PutSuccess = 2, - PutFailure = 3, - UpdateRequest = 4, - UpdateSuccess = 5, - UpdateFailure = 6 -} - -export function unionToContractChangeType( - type: ContractChangeType, - accessor: (obj:PutFailure|PutRequest|PutSuccess|UpdateFailure|UpdateRequest|UpdateSuccess) => PutFailure|PutRequest|PutSuccess|UpdateFailure|UpdateRequest|UpdateSuccess|null -): PutFailure|PutRequest|PutSuccess|UpdateFailure|UpdateRequest|UpdateSuccess|null { - switch(ContractChangeType[type]) { - case 'NONE': return null; - case 'PutRequest': return accessor(new PutRequest())! as PutRequest; - case 'PutSuccess': return accessor(new PutSuccess())! as PutSuccess; - case 'PutFailure': return accessor(new PutFailure())! as PutFailure; - case 'UpdateRequest': return accessor(new UpdateRequest())! as UpdateRequest; - case 'UpdateSuccess': return accessor(new UpdateSuccess())! as UpdateSuccess; - case 'UpdateFailure': return accessor(new UpdateFailure())! as UpdateFailure; - default: return null; - } -} - -export function unionListToContractChangeType( - type: ContractChangeType, - accessor: (index: number, obj:PutFailure|PutRequest|PutSuccess|UpdateFailure|UpdateRequest|UpdateSuccess) => PutFailure|PutRequest|PutSuccess|UpdateFailure|UpdateRequest|UpdateSuccess|null, - index: number -): PutFailure|PutRequest|PutSuccess|UpdateFailure|UpdateRequest|UpdateSuccess|null { - switch(ContractChangeType[type]) { - case 'NONE': return null; - case 'PutRequest': return accessor(index, new PutRequest())! as PutRequest; - case 'PutSuccess': return accessor(index, new PutSuccess())! as PutSuccess; - case 'PutFailure': return accessor(index, new PutFailure())! as PutFailure; - case 'UpdateRequest': return accessor(index, new UpdateRequest())! as UpdateRequest; - case 'UpdateSuccess': return accessor(index, new UpdateSuccess())! as UpdateSuccess; - case 'UpdateFailure': return accessor(index, new UpdateFailure())! as UpdateFailure; - default: return null; - } -} diff --git a/schemas/flatbuffers/topology/contract-change.ts b/schemas/flatbuffers/topology/contract-change.ts deleted file mode 100644 index baa2ecec5..000000000 --- a/schemas/flatbuffers/topology/contract-change.ts +++ /dev/null @@ -1,72 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - -import { ContractChangeType, unionToContractChangeType, unionListToContractChangeType } from '../topology/contract-change-type.js'; - - -export class ContractChange { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):ContractChange { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsContractChange(bb:flatbuffers.ByteBuffer, obj?:ContractChange):ContractChange { - return (obj || new ContractChange()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsContractChange(bb:flatbuffers.ByteBuffer, obj?:ContractChange):ContractChange { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new ContractChange()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -contractId():string|null -contractId(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -contractId(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -changeType():ContractChangeType { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.readUint8(this.bb_pos + offset) : ContractChangeType.NONE; -} - -change(obj:any):any|null { - const offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null; -} - -static startContractChange(builder:flatbuffers.Builder) { - builder.startObject(3); -} - -static addContractId(builder:flatbuffers.Builder, contractIdOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, contractIdOffset, 0); -} - -static addChangeType(builder:flatbuffers.Builder, changeType:ContractChangeType) { - builder.addFieldInt8(1, changeType, ContractChangeType.NONE); -} - -static addChange(builder:flatbuffers.Builder, changeOffset:flatbuffers.Offset) { - builder.addFieldOffset(2, changeOffset, 0); -} - -static endContractChange(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - builder.requiredField(offset, 4) // contract_id - return offset; -} - -static createContractChange(builder:flatbuffers.Builder, contractIdOffset:flatbuffers.Offset, changeType:ContractChangeType, changeOffset:flatbuffers.Offset):flatbuffers.Offset { - ContractChange.startContractChange(builder); - ContractChange.addContractId(builder, contractIdOffset); - ContractChange.addChangeType(builder, changeType); - ContractChange.addChange(builder, changeOffset); - return ContractChange.endContractChange(builder); -} -} diff --git a/schemas/flatbuffers/topology/controller-response.ts b/schemas/flatbuffers/topology/controller-response.ts deleted file mode 100644 index 9937bdac4..000000000 --- a/schemas/flatbuffers/topology/controller-response.ts +++ /dev/null @@ -1,60 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - -import { Response, unionToResponse, unionListToResponse } from '../topology/response.js'; - - -export class ControllerResponse { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):ControllerResponse { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsControllerResponse(bb:flatbuffers.ByteBuffer, obj?:ControllerResponse):ControllerResponse { - return (obj || new ControllerResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsControllerResponse(bb:flatbuffers.ByteBuffer, obj?:ControllerResponse):ControllerResponse { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new ControllerResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -responseType():Response { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.readUint8(this.bb_pos + offset) : Response.NONE; -} - -response(obj:any):any|null { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null; -} - -static startControllerResponse(builder:flatbuffers.Builder) { - builder.startObject(2); -} - -static addResponseType(builder:flatbuffers.Builder, responseType:Response) { - builder.addFieldInt8(0, responseType, Response.NONE); -} - -static addResponse(builder:flatbuffers.Builder, responseOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, responseOffset, 0); -} - -static endControllerResponse(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - builder.requiredField(offset, 6) // response - return offset; -} - -static createControllerResponse(builder:flatbuffers.Builder, responseType:Response, responseOffset:flatbuffers.Offset):flatbuffers.Offset { - ControllerResponse.startControllerResponse(builder); - ControllerResponse.addResponseType(builder, responseType); - ControllerResponse.addResponse(builder, responseOffset); - return ControllerResponse.endControllerResponse(builder); -} -} diff --git a/schemas/flatbuffers/topology/error.ts b/schemas/flatbuffers/topology/error.ts deleted file mode 100644 index b948e1385..000000000 --- a/schemas/flatbuffers/topology/error.ts +++ /dev/null @@ -1,49 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - -export class Error { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):Error { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsError(bb:flatbuffers.ByteBuffer, obj?:Error):Error { - return (obj || new Error()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsError(bb:flatbuffers.ByteBuffer, obj?:Error):Error { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Error()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -message():string|null -message(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -message(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -static startError(builder:flatbuffers.Builder) { - builder.startObject(1); -} - -static addMessage(builder:flatbuffers.Builder, messageOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, messageOffset, 0); -} - -static endError(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - builder.requiredField(offset, 4) // message - return offset; -} - -static createError(builder:flatbuffers.Builder, messageOffset:flatbuffers.Offset):flatbuffers.Offset { - Error.startError(builder); - Error.addMessage(builder, messageOffset); - return Error.endError(builder); -} -} diff --git a/schemas/flatbuffers/topology/ok.ts b/schemas/flatbuffers/topology/ok.ts deleted file mode 100644 index 521b9e037..000000000 --- a/schemas/flatbuffers/topology/ok.ts +++ /dev/null @@ -1,48 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - -export class Ok { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):Ok { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsOk(bb:flatbuffers.ByteBuffer, obj?:Ok):Ok { - return (obj || new Ok()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsOk(bb:flatbuffers.ByteBuffer, obj?:Ok):Ok { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Ok()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -message():string|null -message(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -message(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -static startOk(builder:flatbuffers.Builder) { - builder.startObject(1); -} - -static addMessage(builder:flatbuffers.Builder, messageOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, messageOffset, 0); -} - -static endOk(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static createOk(builder:flatbuffers.Builder, messageOffset:flatbuffers.Offset):flatbuffers.Offset { - Ok.startOk(builder); - Ok.addMessage(builder, messageOffset); - return Ok.endOk(builder); -} -} diff --git a/schemas/flatbuffers/topology/peer-change-type.ts b/schemas/flatbuffers/topology/peer-change-type.ts deleted file mode 100644 index 28ca65445..000000000 --- a/schemas/flatbuffers/topology/peer-change-type.ts +++ /dev/null @@ -1,40 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import { AddedConnection } from '../topology/added-connection.js'; -import { Error } from '../topology/error.js'; -import { RemovedConnection } from '../topology/removed-connection.js'; - - -export enum PeerChangeType { - NONE = 0, - AddedConnection = 1, - RemovedConnection = 2, - Error = 3 -} - -export function unionToPeerChangeType( - type: PeerChangeType, - accessor: (obj:AddedConnection|Error|RemovedConnection) => AddedConnection|Error|RemovedConnection|null -): AddedConnection|Error|RemovedConnection|null { - switch(PeerChangeType[type]) { - case 'NONE': return null; - case 'AddedConnection': return accessor(new AddedConnection())! as AddedConnection; - case 'RemovedConnection': return accessor(new RemovedConnection())! as RemovedConnection; - case 'Error': return accessor(new Error())! as Error; - default: return null; - } -} - -export function unionListToPeerChangeType( - type: PeerChangeType, - accessor: (index: number, obj:AddedConnection|Error|RemovedConnection) => AddedConnection|Error|RemovedConnection|null, - index: number -): AddedConnection|Error|RemovedConnection|null { - switch(PeerChangeType[type]) { - case 'NONE': return null; - case 'AddedConnection': return accessor(index, new AddedConnection())! as AddedConnection; - case 'RemovedConnection': return accessor(index, new RemovedConnection())! as RemovedConnection; - case 'Error': return accessor(index, new Error())! as Error; - default: return null; - } -} diff --git a/schemas/flatbuffers/topology/peer-change.ts b/schemas/flatbuffers/topology/peer-change.ts deleted file mode 100644 index f375c67eb..000000000 --- a/schemas/flatbuffers/topology/peer-change.ts +++ /dev/null @@ -1,87 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - -import { AddedConnection } from '../topology/added-connection.js'; -import { PeerChangeType, unionToPeerChangeType, unionListToPeerChangeType } from '../topology/peer-change-type.js'; - - -export class PeerChange { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):PeerChange { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsPeerChange(bb:flatbuffers.ByteBuffer, obj?:PeerChange):PeerChange { - return (obj || new PeerChange()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsPeerChange(bb:flatbuffers.ByteBuffer, obj?:PeerChange):PeerChange { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new PeerChange()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -currentState(index: number, obj?:AddedConnection):AddedConnection|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? (obj || new AddedConnection()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; -} - -currentStateLength():number { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -} - -changeType():PeerChangeType { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.readUint8(this.bb_pos + offset) : PeerChangeType.NONE; -} - -change(obj:any):any|null { - const offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null; -} - -static startPeerChange(builder:flatbuffers.Builder) { - builder.startObject(3); -} - -static addCurrentState(builder:flatbuffers.Builder, currentStateOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, currentStateOffset, 0); -} - -static createCurrentStateVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]!); - } - return builder.endVector(); -} - -static startCurrentStateVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(4, numElems, 4); -} - -static addChangeType(builder:flatbuffers.Builder, changeType:PeerChangeType) { - builder.addFieldInt8(1, changeType, PeerChangeType.NONE); -} - -static addChange(builder:flatbuffers.Builder, changeOffset:flatbuffers.Offset) { - builder.addFieldOffset(2, changeOffset, 0); -} - -static endPeerChange(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static createPeerChange(builder:flatbuffers.Builder, currentStateOffset:flatbuffers.Offset, changeType:PeerChangeType, changeOffset:flatbuffers.Offset):flatbuffers.Offset { - PeerChange.startPeerChange(builder); - PeerChange.addCurrentState(builder, currentStateOffset); - PeerChange.addChangeType(builder, changeType); - PeerChange.addChange(builder, changeOffset); - return PeerChange.endPeerChange(builder); -} -} diff --git a/schemas/flatbuffers/topology/put-failure.ts b/schemas/flatbuffers/topology/put-failure.ts deleted file mode 100644 index dfacd429c..000000000 --- a/schemas/flatbuffers/topology/put-failure.ts +++ /dev/null @@ -1,88 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - -export class PutFailure { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):PutFailure { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsPutFailure(bb:flatbuffers.ByteBuffer, obj?:PutFailure):PutFailure { - return (obj || new PutFailure()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsPutFailure(bb:flatbuffers.ByteBuffer, obj?:PutFailure):PutFailure { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new PutFailure()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -transaction():string|null -transaction(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -transaction(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -requester():string|null -requester(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -requester(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -target():string|null -target(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -target(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -key():string|null -key(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -key(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 10); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -static startPutFailure(builder:flatbuffers.Builder) { - builder.startObject(4); -} - -static addTransaction(builder:flatbuffers.Builder, transactionOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, transactionOffset, 0); -} - -static addRequester(builder:flatbuffers.Builder, requesterOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, requesterOffset, 0); -} - -static addTarget(builder:flatbuffers.Builder, targetOffset:flatbuffers.Offset) { - builder.addFieldOffset(2, targetOffset, 0); -} - -static addKey(builder:flatbuffers.Builder, keyOffset:flatbuffers.Offset) { - builder.addFieldOffset(3, keyOffset, 0); -} - -static endPutFailure(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - builder.requiredField(offset, 4) // transaction - builder.requiredField(offset, 6) // requester - builder.requiredField(offset, 8) // target - builder.requiredField(offset, 10) // key - return offset; -} - -static createPutFailure(builder:flatbuffers.Builder, transactionOffset:flatbuffers.Offset, requesterOffset:flatbuffers.Offset, targetOffset:flatbuffers.Offset, keyOffset:flatbuffers.Offset):flatbuffers.Offset { - PutFailure.startPutFailure(builder); - PutFailure.addTransaction(builder, transactionOffset); - PutFailure.addRequester(builder, requesterOffset); - PutFailure.addTarget(builder, targetOffset); - PutFailure.addKey(builder, keyOffset); - return PutFailure.endPutFailure(builder); -} -} diff --git a/schemas/flatbuffers/topology/put-request.ts b/schemas/flatbuffers/topology/put-request.ts deleted file mode 100644 index e033180cb..000000000 --- a/schemas/flatbuffers/topology/put-request.ts +++ /dev/null @@ -1,108 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - -export class PutRequest { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):PutRequest { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsPutRequest(bb:flatbuffers.ByteBuffer, obj?:PutRequest):PutRequest { - return (obj || new PutRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsPutRequest(bb:flatbuffers.ByteBuffer, obj?:PutRequest):PutRequest { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new PutRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -transaction():string|null -transaction(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -transaction(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -key():string|null -key(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -key(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -requester():string|null -requester(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -requester(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -target():string|null -target(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -target(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 10); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -timestamp():bigint { - const offset = this.bb!.__offset(this.bb_pos, 12); - return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0'); -} - -contractLocation():number { - const offset = this.bb!.__offset(this.bb_pos, 14); - return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0; -} - -static startPutRequest(builder:flatbuffers.Builder) { - builder.startObject(6); -} - -static addTransaction(builder:flatbuffers.Builder, transactionOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, transactionOffset, 0); -} - -static addKey(builder:flatbuffers.Builder, keyOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, keyOffset, 0); -} - -static addRequester(builder:flatbuffers.Builder, requesterOffset:flatbuffers.Offset) { - builder.addFieldOffset(2, requesterOffset, 0); -} - -static addTarget(builder:flatbuffers.Builder, targetOffset:flatbuffers.Offset) { - builder.addFieldOffset(3, targetOffset, 0); -} - -static addTimestamp(builder:flatbuffers.Builder, timestamp:bigint) { - builder.addFieldInt64(4, timestamp, BigInt('0')); -} - -static addContractLocation(builder:flatbuffers.Builder, contractLocation:number) { - builder.addFieldFloat64(5, contractLocation, 0.0); -} - -static endPutRequest(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - builder.requiredField(offset, 4) // transaction - builder.requiredField(offset, 6) // key - builder.requiredField(offset, 8) // requester - builder.requiredField(offset, 10) // target - return offset; -} - -static createPutRequest(builder:flatbuffers.Builder, transactionOffset:flatbuffers.Offset, keyOffset:flatbuffers.Offset, requesterOffset:flatbuffers.Offset, targetOffset:flatbuffers.Offset, timestamp:bigint, contractLocation:number):flatbuffers.Offset { - PutRequest.startPutRequest(builder); - PutRequest.addTransaction(builder, transactionOffset); - PutRequest.addKey(builder, keyOffset); - PutRequest.addRequester(builder, requesterOffset); - PutRequest.addTarget(builder, targetOffset); - PutRequest.addTimestamp(builder, timestamp); - PutRequest.addContractLocation(builder, contractLocation); - return PutRequest.endPutRequest(builder); -} -} diff --git a/schemas/flatbuffers/topology/put-success.ts b/schemas/flatbuffers/topology/put-success.ts deleted file mode 100644 index 14acda9f7..000000000 --- a/schemas/flatbuffers/topology/put-success.ts +++ /dev/null @@ -1,108 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - -export class PutSuccess { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):PutSuccess { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsPutSuccess(bb:flatbuffers.ByteBuffer, obj?:PutSuccess):PutSuccess { - return (obj || new PutSuccess()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsPutSuccess(bb:flatbuffers.ByteBuffer, obj?:PutSuccess):PutSuccess { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new PutSuccess()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -transaction():string|null -transaction(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -transaction(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -requester():string|null -requester(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -requester(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -target():string|null -target(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -target(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -key():string|null -key(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -key(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 10); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -timestamp():bigint { - const offset = this.bb!.__offset(this.bb_pos, 12); - return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0'); -} - -contractLocation():number { - const offset = this.bb!.__offset(this.bb_pos, 14); - return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0; -} - -static startPutSuccess(builder:flatbuffers.Builder) { - builder.startObject(6); -} - -static addTransaction(builder:flatbuffers.Builder, transactionOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, transactionOffset, 0); -} - -static addRequester(builder:flatbuffers.Builder, requesterOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, requesterOffset, 0); -} - -static addTarget(builder:flatbuffers.Builder, targetOffset:flatbuffers.Offset) { - builder.addFieldOffset(2, targetOffset, 0); -} - -static addKey(builder:flatbuffers.Builder, keyOffset:flatbuffers.Offset) { - builder.addFieldOffset(3, keyOffset, 0); -} - -static addTimestamp(builder:flatbuffers.Builder, timestamp:bigint) { - builder.addFieldInt64(4, timestamp, BigInt('0')); -} - -static addContractLocation(builder:flatbuffers.Builder, contractLocation:number) { - builder.addFieldFloat64(5, contractLocation, 0.0); -} - -static endPutSuccess(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - builder.requiredField(offset, 4) // transaction - builder.requiredField(offset, 6) // requester - builder.requiredField(offset, 8) // target - builder.requiredField(offset, 10) // key - return offset; -} - -static createPutSuccess(builder:flatbuffers.Builder, transactionOffset:flatbuffers.Offset, requesterOffset:flatbuffers.Offset, targetOffset:flatbuffers.Offset, keyOffset:flatbuffers.Offset, timestamp:bigint, contractLocation:number):flatbuffers.Offset { - PutSuccess.startPutSuccess(builder); - PutSuccess.addTransaction(builder, transactionOffset); - PutSuccess.addRequester(builder, requesterOffset); - PutSuccess.addTarget(builder, targetOffset); - PutSuccess.addKey(builder, keyOffset); - PutSuccess.addTimestamp(builder, timestamp); - PutSuccess.addContractLocation(builder, contractLocation); - return PutSuccess.endPutSuccess(builder); -} -} diff --git a/schemas/flatbuffers/topology/removed-connection.ts b/schemas/flatbuffers/topology/removed-connection.ts deleted file mode 100644 index 30b005cf8..000000000 --- a/schemas/flatbuffers/topology/removed-connection.ts +++ /dev/null @@ -1,62 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - -export class RemovedConnection { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):RemovedConnection { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsRemovedConnection(bb:flatbuffers.ByteBuffer, obj?:RemovedConnection):RemovedConnection { - return (obj || new RemovedConnection()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsRemovedConnection(bb:flatbuffers.ByteBuffer, obj?:RemovedConnection):RemovedConnection { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new RemovedConnection()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -at():string|null -at(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -at(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -from():string|null -from(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -from(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -static startRemovedConnection(builder:flatbuffers.Builder) { - builder.startObject(2); -} - -static addAt(builder:flatbuffers.Builder, atOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, atOffset, 0); -} - -static addFrom(builder:flatbuffers.Builder, fromOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, fromOffset, 0); -} - -static endRemovedConnection(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - builder.requiredField(offset, 4) // at - builder.requiredField(offset, 6) // from - return offset; -} - -static createRemovedConnection(builder:flatbuffers.Builder, atOffset:flatbuffers.Offset, fromOffset:flatbuffers.Offset):flatbuffers.Offset { - RemovedConnection.startRemovedConnection(builder); - RemovedConnection.addAt(builder, atOffset); - RemovedConnection.addFrom(builder, fromOffset); - return RemovedConnection.endRemovedConnection(builder); -} -} diff --git a/schemas/flatbuffers/topology/response.ts b/schemas/flatbuffers/topology/response.ts deleted file mode 100644 index f0ec80263..000000000 --- a/schemas/flatbuffers/topology/response.ts +++ /dev/null @@ -1,36 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import { Error } from '../topology/error.js'; -import { Ok } from '../topology/ok.js'; - - -export enum Response { - NONE = 0, - Error = 1, - Ok = 2 -} - -export function unionToResponse( - type: Response, - accessor: (obj:Error|Ok) => Error|Ok|null -): Error|Ok|null { - switch(Response[type]) { - case 'NONE': return null; - case 'Error': return accessor(new Error())! as Error; - case 'Ok': return accessor(new Ok())! as Ok; - default: return null; - } -} - -export function unionListToResponse( - type: Response, - accessor: (index: number, obj:Error|Ok) => Error|Ok|null, - index: number -): Error|Ok|null { - switch(Response[type]) { - case 'NONE': return null; - case 'Error': return accessor(index, new Error())! as Error; - case 'Ok': return accessor(index, new Ok())! as Ok; - default: return null; - } -} diff --git a/schemas/flatbuffers/topology/update-failure.ts b/schemas/flatbuffers/topology/update-failure.ts deleted file mode 100644 index f25f2ff89..000000000 --- a/schemas/flatbuffers/topology/update-failure.ts +++ /dev/null @@ -1,88 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - -export class UpdateFailure { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):UpdateFailure { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsUpdateFailure(bb:flatbuffers.ByteBuffer, obj?:UpdateFailure):UpdateFailure { - return (obj || new UpdateFailure()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsUpdateFailure(bb:flatbuffers.ByteBuffer, obj?:UpdateFailure):UpdateFailure { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new UpdateFailure()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -transaction():string|null -transaction(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -transaction(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -requester():string|null -requester(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -requester(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -target():string|null -target(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -target(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -key():string|null -key(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -key(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 10); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -static startUpdateFailure(builder:flatbuffers.Builder) { - builder.startObject(4); -} - -static addTransaction(builder:flatbuffers.Builder, transactionOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, transactionOffset, 0); -} - -static addRequester(builder:flatbuffers.Builder, requesterOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, requesterOffset, 0); -} - -static addTarget(builder:flatbuffers.Builder, targetOffset:flatbuffers.Offset) { - builder.addFieldOffset(2, targetOffset, 0); -} - -static addKey(builder:flatbuffers.Builder, keyOffset:flatbuffers.Offset) { - builder.addFieldOffset(3, keyOffset, 0); -} - -static endUpdateFailure(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - builder.requiredField(offset, 4) // transaction - builder.requiredField(offset, 6) // requester - builder.requiredField(offset, 8) // target - builder.requiredField(offset, 10) // key - return offset; -} - -static createUpdateFailure(builder:flatbuffers.Builder, transactionOffset:flatbuffers.Offset, requesterOffset:flatbuffers.Offset, targetOffset:flatbuffers.Offset, keyOffset:flatbuffers.Offset):flatbuffers.Offset { - UpdateFailure.startUpdateFailure(builder); - UpdateFailure.addTransaction(builder, transactionOffset); - UpdateFailure.addRequester(builder, requesterOffset); - UpdateFailure.addTarget(builder, targetOffset); - UpdateFailure.addKey(builder, keyOffset); - return UpdateFailure.endUpdateFailure(builder); -} -} diff --git a/schemas/flatbuffers/topology/update-request.ts b/schemas/flatbuffers/topology/update-request.ts deleted file mode 100644 index b634c452d..000000000 --- a/schemas/flatbuffers/topology/update-request.ts +++ /dev/null @@ -1,88 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - -export class UpdateRequest { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):UpdateRequest { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsUpdateRequest(bb:flatbuffers.ByteBuffer, obj?:UpdateRequest):UpdateRequest { - return (obj || new UpdateRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsUpdateRequest(bb:flatbuffers.ByteBuffer, obj?:UpdateRequest):UpdateRequest { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new UpdateRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -transaction():string|null -transaction(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -transaction(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -key():string|null -key(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -key(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -requester():string|null -requester(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -requester(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -target():string|null -target(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -target(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 10); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -static startUpdateRequest(builder:flatbuffers.Builder) { - builder.startObject(4); -} - -static addTransaction(builder:flatbuffers.Builder, transactionOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, transactionOffset, 0); -} - -static addKey(builder:flatbuffers.Builder, keyOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, keyOffset, 0); -} - -static addRequester(builder:flatbuffers.Builder, requesterOffset:flatbuffers.Offset) { - builder.addFieldOffset(2, requesterOffset, 0); -} - -static addTarget(builder:flatbuffers.Builder, targetOffset:flatbuffers.Offset) { - builder.addFieldOffset(3, targetOffset, 0); -} - -static endUpdateRequest(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - builder.requiredField(offset, 4) // transaction - builder.requiredField(offset, 6) // key - builder.requiredField(offset, 8) // requester - builder.requiredField(offset, 10) // target - return offset; -} - -static createUpdateRequest(builder:flatbuffers.Builder, transactionOffset:flatbuffers.Offset, keyOffset:flatbuffers.Offset, requesterOffset:flatbuffers.Offset, targetOffset:flatbuffers.Offset):flatbuffers.Offset { - UpdateRequest.startUpdateRequest(builder); - UpdateRequest.addTransaction(builder, transactionOffset); - UpdateRequest.addKey(builder, keyOffset); - UpdateRequest.addRequester(builder, requesterOffset); - UpdateRequest.addTarget(builder, targetOffset); - return UpdateRequest.endUpdateRequest(builder); -} -} diff --git a/schemas/flatbuffers/topology/update-success.ts b/schemas/flatbuffers/topology/update-success.ts deleted file mode 100644 index 535fdff86..000000000 --- a/schemas/flatbuffers/topology/update-success.ts +++ /dev/null @@ -1,88 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - -export class UpdateSuccess { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):UpdateSuccess { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsUpdateSuccess(bb:flatbuffers.ByteBuffer, obj?:UpdateSuccess):UpdateSuccess { - return (obj || new UpdateSuccess()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsUpdateSuccess(bb:flatbuffers.ByteBuffer, obj?:UpdateSuccess):UpdateSuccess { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new UpdateSuccess()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -transaction():string|null -transaction(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -transaction(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -requester():string|null -requester(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -requester(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -target():string|null -target(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -target(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -key():string|null -key(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -key(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 10); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -static startUpdateSuccess(builder:flatbuffers.Builder) { - builder.startObject(4); -} - -static addTransaction(builder:flatbuffers.Builder, transactionOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, transactionOffset, 0); -} - -static addRequester(builder:flatbuffers.Builder, requesterOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, requesterOffset, 0); -} - -static addTarget(builder:flatbuffers.Builder, targetOffset:flatbuffers.Offset) { - builder.addFieldOffset(2, targetOffset, 0); -} - -static addKey(builder:flatbuffers.Builder, keyOffset:flatbuffers.Offset) { - builder.addFieldOffset(3, keyOffset, 0); -} - -static endUpdateSuccess(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - builder.requiredField(offset, 4) // transaction - builder.requiredField(offset, 6) // requester - builder.requiredField(offset, 8) // target - builder.requiredField(offset, 10) // key - return offset; -} - -static createUpdateSuccess(builder:flatbuffers.Builder, transactionOffset:flatbuffers.Offset, requesterOffset:flatbuffers.Offset, targetOffset:flatbuffers.Offset, keyOffset:flatbuffers.Offset):flatbuffers.Offset { - UpdateSuccess.startUpdateSuccess(builder); - UpdateSuccess.addTransaction(builder, transactionOffset); - UpdateSuccess.addRequester(builder, requesterOffset); - UpdateSuccess.addTarget(builder, targetOffset); - UpdateSuccess.addKey(builder, keyOffset); - return UpdateSuccess.endUpdateSuccess(builder); -} -} diff --git a/schemas/flatbuffers/topology_generated.rs b/schemas/flatbuffers/topology_generated.rs new file mode 100644 index 000000000..8b86a190a --- /dev/null +++ b/schemas/flatbuffers/topology_generated.rs @@ -0,0 +1,3380 @@ +// automatically generated by the FlatBuffers compiler, do not modify + + +// @generated + +use core::mem; +use core::cmp::Ordering; + +extern crate flatbuffers; +use self::flatbuffers::{EndianScalar, Follow}; + +#[allow(unused_imports, dead_code)] +pub mod topology { + + use core::mem; + use core::cmp::Ordering; + + extern crate flatbuffers; + use self::flatbuffers::{EndianScalar, Follow}; + +#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] +pub const ENUM_MIN_PEER_CHANGE_TYPE: u8 = 0; +#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] +pub const ENUM_MAX_PEER_CHANGE_TYPE: u8 = 3; +#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] +#[allow(non_camel_case_types)] +pub const ENUM_VALUES_PEER_CHANGE_TYPE: [PeerChangeType; 4] = [ + PeerChangeType::NONE, + PeerChangeType::AddedConnection, + PeerChangeType::RemovedConnection, + PeerChangeType::Error, +]; + +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] +#[repr(transparent)] +pub struct PeerChangeType(pub u8); +#[allow(non_upper_case_globals)] +impl PeerChangeType { + pub const NONE: Self = Self(0); + pub const AddedConnection: Self = Self(1); + pub const RemovedConnection: Self = Self(2); + pub const Error: Self = Self(3); + + pub const ENUM_MIN: u8 = 0; + pub const ENUM_MAX: u8 = 3; + pub const ENUM_VALUES: &'static [Self] = &[ + Self::NONE, + Self::AddedConnection, + Self::RemovedConnection, + Self::Error, + ]; + /// Returns the variant's name or "" if unknown. + pub fn variant_name(self) -> Option<&'static str> { + match self { + Self::NONE => Some("NONE"), + Self::AddedConnection => Some("AddedConnection"), + Self::RemovedConnection => Some("RemovedConnection"), + Self::Error => Some("Error"), + _ => None, + } + } +} +impl core::fmt::Debug for PeerChangeType { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + if let Some(name) = self.variant_name() { + f.write_str(name) + } else { + f.write_fmt(format_args!("", self.0)) + } + } +} +impl<'a> flatbuffers::Follow<'a> for PeerChangeType { + type Inner = Self; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + let b = flatbuffers::read_scalar_at::(buf, loc); + Self(b) + } +} + +impl flatbuffers::Push for PeerChangeType { + type Output = PeerChangeType; + #[inline] + unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { + flatbuffers::emplace_scalar::(dst, self.0); + } +} + +impl flatbuffers::EndianScalar for PeerChangeType { + type Scalar = u8; + #[inline] + fn to_little_endian(self) -> u8 { + self.0.to_le() + } + #[inline] + #[allow(clippy::wrong_self_convention)] + fn from_little_endian(v: u8) -> Self { + let b = u8::from_le(v); + Self(b) + } +} + +impl<'a> flatbuffers::Verifiable for PeerChangeType { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + u8::run_verifier(v, pos) + } +} + +impl flatbuffers::SimpleToVerifyInSlice for PeerChangeType {} +pub struct PeerChangeTypeUnionTableOffset {} + +#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] +pub const ENUM_MIN_RESPONSE: u8 = 0; +#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] +pub const ENUM_MAX_RESPONSE: u8 = 2; +#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] +#[allow(non_camel_case_types)] +pub const ENUM_VALUES_RESPONSE: [Response; 3] = [ + Response::NONE, + Response::Error, + Response::Ok, +]; + +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] +#[repr(transparent)] +pub struct Response(pub u8); +#[allow(non_upper_case_globals)] +impl Response { + pub const NONE: Self = Self(0); + pub const Error: Self = Self(1); + pub const Ok: Self = Self(2); + + pub const ENUM_MIN: u8 = 0; + pub const ENUM_MAX: u8 = 2; + pub const ENUM_VALUES: &'static [Self] = &[ + Self::NONE, + Self::Error, + Self::Ok, + ]; + /// Returns the variant's name or "" if unknown. + pub fn variant_name(self) -> Option<&'static str> { + match self { + Self::NONE => Some("NONE"), + Self::Error => Some("Error"), + Self::Ok => Some("Ok"), + _ => None, + } + } +} +impl core::fmt::Debug for Response { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + if let Some(name) = self.variant_name() { + f.write_str(name) + } else { + f.write_fmt(format_args!("", self.0)) + } + } +} +impl<'a> flatbuffers::Follow<'a> for Response { + type Inner = Self; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + let b = flatbuffers::read_scalar_at::(buf, loc); + Self(b) + } +} + +impl flatbuffers::Push for Response { + type Output = Response; + #[inline] + unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { + flatbuffers::emplace_scalar::(dst, self.0); + } +} + +impl flatbuffers::EndianScalar for Response { + type Scalar = u8; + #[inline] + fn to_little_endian(self) -> u8 { + self.0.to_le() + } + #[inline] + #[allow(clippy::wrong_self_convention)] + fn from_little_endian(v: u8) -> Self { + let b = u8::from_le(v); + Self(b) + } +} + +impl<'a> flatbuffers::Verifiable for Response { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + u8::run_verifier(v, pos) + } +} + +impl flatbuffers::SimpleToVerifyInSlice for Response {} +pub struct ResponseUnionTableOffset {} + +#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] +pub const ENUM_MIN_CONTRACT_CHANGE_TYPE: u8 = 0; +#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] +pub const ENUM_MAX_CONTRACT_CHANGE_TYPE: u8 = 10; +#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] +#[allow(non_camel_case_types)] +pub const ENUM_VALUES_CONTRACT_CHANGE_TYPE: [ContractChangeType; 11] = [ + ContractChangeType::NONE, + ContractChangeType::PutRequest, + ContractChangeType::PutSuccess, + ContractChangeType::PutFailure, + ContractChangeType::BroadcastEmitted, + ContractChangeType::BroadcastReceived, + ContractChangeType::UpdateRequest, + ContractChangeType::UpdateSuccess, + ContractChangeType::UpdateFailure, + ContractChangeType::GetContract, + ContractChangeType::SubscribedToContract, +]; + +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] +#[repr(transparent)] +pub struct ContractChangeType(pub u8); +#[allow(non_upper_case_globals)] +impl ContractChangeType { + pub const NONE: Self = Self(0); + pub const PutRequest: Self = Self(1); + pub const PutSuccess: Self = Self(2); + pub const PutFailure: Self = Self(3); + pub const BroadcastEmitted: Self = Self(4); + pub const BroadcastReceived: Self = Self(5); + pub const UpdateRequest: Self = Self(6); + pub const UpdateSuccess: Self = Self(7); + pub const UpdateFailure: Self = Self(8); + pub const GetContract: Self = Self(9); + pub const SubscribedToContract: Self = Self(10); + + pub const ENUM_MIN: u8 = 0; + pub const ENUM_MAX: u8 = 10; + pub const ENUM_VALUES: &'static [Self] = &[ + Self::NONE, + Self::PutRequest, + Self::PutSuccess, + Self::PutFailure, + Self::BroadcastEmitted, + Self::BroadcastReceived, + Self::UpdateRequest, + Self::UpdateSuccess, + Self::UpdateFailure, + Self::GetContract, + Self::SubscribedToContract, + ]; + /// Returns the variant's name or "" if unknown. + pub fn variant_name(self) -> Option<&'static str> { + match self { + Self::NONE => Some("NONE"), + Self::PutRequest => Some("PutRequest"), + Self::PutSuccess => Some("PutSuccess"), + Self::PutFailure => Some("PutFailure"), + Self::BroadcastEmitted => Some("BroadcastEmitted"), + Self::BroadcastReceived => Some("BroadcastReceived"), + Self::UpdateRequest => Some("UpdateRequest"), + Self::UpdateSuccess => Some("UpdateSuccess"), + Self::UpdateFailure => Some("UpdateFailure"), + Self::GetContract => Some("GetContract"), + Self::SubscribedToContract => Some("SubscribedToContract"), + _ => None, + } + } +} +impl core::fmt::Debug for ContractChangeType { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + if let Some(name) = self.variant_name() { + f.write_str(name) + } else { + f.write_fmt(format_args!("", self.0)) + } + } +} +impl<'a> flatbuffers::Follow<'a> for ContractChangeType { + type Inner = Self; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + let b = flatbuffers::read_scalar_at::(buf, loc); + Self(b) + } +} + +impl flatbuffers::Push for ContractChangeType { + type Output = ContractChangeType; + #[inline] + unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { + flatbuffers::emplace_scalar::(dst, self.0); + } +} + +impl flatbuffers::EndianScalar for ContractChangeType { + type Scalar = u8; + #[inline] + fn to_little_endian(self) -> u8 { + self.0.to_le() + } + #[inline] + #[allow(clippy::wrong_self_convention)] + fn from_little_endian(v: u8) -> Self { + let b = u8::from_le(v); + Self(b) + } +} + +impl<'a> flatbuffers::Verifiable for ContractChangeType { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + u8::run_verifier(v, pos) + } +} + +impl flatbuffers::SimpleToVerifyInSlice for ContractChangeType {} +pub struct ContractChangeTypeUnionTableOffset {} + +pub enum AddedConnectionOffset {} +#[derive(Copy, Clone, PartialEq)] + +pub struct AddedConnection<'a> { + pub _tab: flatbuffers::Table<'a>, +} + +impl<'a> flatbuffers::Follow<'a> for AddedConnection<'a> { + type Inner = AddedConnection<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } +} + +impl<'a> AddedConnection<'a> { + pub const VT_TRANSACTION: flatbuffers::VOffsetT = 4; + pub const VT_FROM: flatbuffers::VOffsetT = 6; + pub const VT_FROM_LOCATION: flatbuffers::VOffsetT = 8; + pub const VT_TO: flatbuffers::VOffsetT = 10; + pub const VT_TO_LOCATION: flatbuffers::VOffsetT = 12; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + AddedConnection { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args AddedConnectionArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = AddedConnectionBuilder::new(_fbb); + builder.add_to_location(args.to_location); + builder.add_from_location(args.from_location); + if let Some(x) = args.to { builder.add_to(x); } + if let Some(x) = args.from { builder.add_from(x); } + if let Some(x) = args.transaction { builder.add_transaction(x); } + builder.finish() + } + + + #[inline] + pub fn transaction(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(AddedConnection::VT_TRANSACTION, None)} + } + #[inline] + pub fn from(&self) -> flatbuffers::Vector<'a, u8> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>(AddedConnection::VT_FROM, None).unwrap()} + } + #[inline] + pub fn from_location(&self) -> f64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(AddedConnection::VT_FROM_LOCATION, Some(0.0)).unwrap()} + } + #[inline] + pub fn to(&self) -> flatbuffers::Vector<'a, u8> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>(AddedConnection::VT_TO, None).unwrap()} + } + #[inline] + pub fn to_location(&self) -> f64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(AddedConnection::VT_TO_LOCATION, Some(0.0)).unwrap()} + } +} + +impl flatbuffers::Verifiable for AddedConnection<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>("transaction", Self::VT_TRANSACTION, false)? + .visit_field::>>("from", Self::VT_FROM, true)? + .visit_field::("from_location", Self::VT_FROM_LOCATION, false)? + .visit_field::>>("to", Self::VT_TO, true)? + .visit_field::("to_location", Self::VT_TO_LOCATION, false)? + .finish(); + Ok(()) + } +} +pub struct AddedConnectionArgs<'a> { + pub transaction: Option>, + pub from: Option>>, + pub from_location: f64, + pub to: Option>>, + pub to_location: f64, +} +impl<'a> Default for AddedConnectionArgs<'a> { + #[inline] + fn default() -> Self { + AddedConnectionArgs { + transaction: None, + from: None, // required field + from_location: 0.0, + to: None, // required field + to_location: 0.0, + } + } +} + +pub struct AddedConnectionBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b> AddedConnectionBuilder<'a, 'b> { + #[inline] + pub fn add_transaction(&mut self, transaction: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(AddedConnection::VT_TRANSACTION, transaction); + } + #[inline] + pub fn add_from(&mut self, from: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(AddedConnection::VT_FROM, from); + } + #[inline] + pub fn add_from_location(&mut self, from_location: f64) { + self.fbb_.push_slot::(AddedConnection::VT_FROM_LOCATION, from_location, 0.0); + } + #[inline] + pub fn add_to(&mut self, to: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(AddedConnection::VT_TO, to); + } + #[inline] + pub fn add_to_location(&mut self, to_location: f64) { + self.fbb_.push_slot::(AddedConnection::VT_TO_LOCATION, to_location, 0.0); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> AddedConnectionBuilder<'a, 'b> { + let start = _fbb.start_table(); + AddedConnectionBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + self.fbb_.required(o, AddedConnection::VT_FROM,"from"); + self.fbb_.required(o, AddedConnection::VT_TO,"to"); + flatbuffers::WIPOffset::new(o.value()) + } +} + +impl core::fmt::Debug for AddedConnection<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("AddedConnection"); + ds.field("transaction", &self.transaction()); + ds.field("from", &self.from()); + ds.field("from_location", &self.from_location()); + ds.field("to", &self.to()); + ds.field("to_location", &self.to_location()); + ds.finish() + } +} +pub enum RemovedConnectionOffset {} +#[derive(Copy, Clone, PartialEq)] + +pub struct RemovedConnection<'a> { + pub _tab: flatbuffers::Table<'a>, +} + +impl<'a> flatbuffers::Follow<'a> for RemovedConnection<'a> { + type Inner = RemovedConnection<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } +} + +impl<'a> RemovedConnection<'a> { + pub const VT_AT: flatbuffers::VOffsetT = 4; + pub const VT_FROM: flatbuffers::VOffsetT = 6; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + RemovedConnection { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args RemovedConnectionArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = RemovedConnectionBuilder::new(_fbb); + if let Some(x) = args.from { builder.add_from(x); } + if let Some(x) = args.at { builder.add_at(x); } + builder.finish() + } + + + #[inline] + pub fn at(&self) -> flatbuffers::Vector<'a, u8> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>(RemovedConnection::VT_AT, None).unwrap()} + } + #[inline] + pub fn from(&self) -> flatbuffers::Vector<'a, u8> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>(RemovedConnection::VT_FROM, None).unwrap()} + } +} + +impl flatbuffers::Verifiable for RemovedConnection<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>>("at", Self::VT_AT, true)? + .visit_field::>>("from", Self::VT_FROM, true)? + .finish(); + Ok(()) + } +} +pub struct RemovedConnectionArgs<'a> { + pub at: Option>>, + pub from: Option>>, +} +impl<'a> Default for RemovedConnectionArgs<'a> { + #[inline] + fn default() -> Self { + RemovedConnectionArgs { + at: None, // required field + from: None, // required field + } + } +} + +pub struct RemovedConnectionBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b> RemovedConnectionBuilder<'a, 'b> { + #[inline] + pub fn add_at(&mut self, at: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(RemovedConnection::VT_AT, at); + } + #[inline] + pub fn add_from(&mut self, from: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(RemovedConnection::VT_FROM, from); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> RemovedConnectionBuilder<'a, 'b> { + let start = _fbb.start_table(); + RemovedConnectionBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + self.fbb_.required(o, RemovedConnection::VT_AT,"at"); + self.fbb_.required(o, RemovedConnection::VT_FROM,"from"); + flatbuffers::WIPOffset::new(o.value()) + } +} + +impl core::fmt::Debug for RemovedConnection<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("RemovedConnection"); + ds.field("at", &self.at()); + ds.field("from", &self.from()); + ds.finish() + } +} +pub enum ErrorOffset {} +#[derive(Copy, Clone, PartialEq)] + +pub struct Error<'a> { + pub _tab: flatbuffers::Table<'a>, +} + +impl<'a> flatbuffers::Follow<'a> for Error<'a> { + type Inner = Error<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } +} + +impl<'a> Error<'a> { + pub const VT_MESSAGE: flatbuffers::VOffsetT = 4; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + Error { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args ErrorArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = ErrorBuilder::new(_fbb); + if let Some(x) = args.message { builder.add_message(x); } + builder.finish() + } + + + #[inline] + pub fn message(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(Error::VT_MESSAGE, None).unwrap()} + } +} + +impl flatbuffers::Verifiable for Error<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>("message", Self::VT_MESSAGE, true)? + .finish(); + Ok(()) + } +} +pub struct ErrorArgs<'a> { + pub message: Option>, +} +impl<'a> Default for ErrorArgs<'a> { + #[inline] + fn default() -> Self { + ErrorArgs { + message: None, // required field + } + } +} + +pub struct ErrorBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b> ErrorBuilder<'a, 'b> { + #[inline] + pub fn add_message(&mut self, message: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(Error::VT_MESSAGE, message); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> ErrorBuilder<'a, 'b> { + let start = _fbb.start_table(); + ErrorBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + self.fbb_.required(o, Error::VT_MESSAGE,"message"); + flatbuffers::WIPOffset::new(o.value()) + } +} + +impl core::fmt::Debug for Error<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("Error"); + ds.field("message", &self.message()); + ds.finish() + } +} +pub enum PeerChangeOffset {} +#[derive(Copy, Clone, PartialEq)] + +pub struct PeerChange<'a> { + pub _tab: flatbuffers::Table<'a>, +} + +impl<'a> flatbuffers::Follow<'a> for PeerChange<'a> { + type Inner = PeerChange<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } +} + +impl<'a> PeerChange<'a> { + pub const VT_CURRENT_STATE: flatbuffers::VOffsetT = 4; + pub const VT_CHANGE_TYPE: flatbuffers::VOffsetT = 6; + pub const VT_CHANGE: flatbuffers::VOffsetT = 8; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + PeerChange { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args PeerChangeArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = PeerChangeBuilder::new(_fbb); + if let Some(x) = args.change { builder.add_change(x); } + if let Some(x) = args.current_state { builder.add_current_state(x); } + builder.add_change_type(args.change_type); + builder.finish() + } + + + #[inline] + pub fn current_state(&self) -> Option>>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>>(PeerChange::VT_CURRENT_STATE, None)} + } + #[inline] + pub fn change_type(&self) -> PeerChangeType { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(PeerChange::VT_CHANGE_TYPE, Some(PeerChangeType::NONE)).unwrap()} + } + #[inline] + pub fn change(&self) -> Option> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>(PeerChange::VT_CHANGE, None)} + } + #[inline] + #[allow(non_snake_case)] + pub fn change_as_added_connection(&self) -> Option> { + if self.change_type() == PeerChangeType::AddedConnection { + self.change().map(|t| { + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + unsafe { AddedConnection::init_from_table(t) } + }) + } else { + None + } + } + + #[inline] + #[allow(non_snake_case)] + pub fn change_as_removed_connection(&self) -> Option> { + if self.change_type() == PeerChangeType::RemovedConnection { + self.change().map(|t| { + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + unsafe { RemovedConnection::init_from_table(t) } + }) + } else { + None + } + } + + #[inline] + #[allow(non_snake_case)] + pub fn change_as_error(&self) -> Option> { + if self.change_type() == PeerChangeType::Error { + self.change().map(|t| { + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + unsafe { Error::init_from_table(t) } + }) + } else { + None + } + } + +} + +impl flatbuffers::Verifiable for PeerChange<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>>>("current_state", Self::VT_CURRENT_STATE, false)? + .visit_union::("change_type", Self::VT_CHANGE_TYPE, "change", Self::VT_CHANGE, false, |key, v, pos| { + match key { + PeerChangeType::AddedConnection => v.verify_union_variant::>("PeerChangeType::AddedConnection", pos), + PeerChangeType::RemovedConnection => v.verify_union_variant::>("PeerChangeType::RemovedConnection", pos), + PeerChangeType::Error => v.verify_union_variant::>("PeerChangeType::Error", pos), + _ => Ok(()), + } + })? + .finish(); + Ok(()) + } +} +pub struct PeerChangeArgs<'a> { + pub current_state: Option>>>>, + pub change_type: PeerChangeType, + pub change: Option>, +} +impl<'a> Default for PeerChangeArgs<'a> { + #[inline] + fn default() -> Self { + PeerChangeArgs { + current_state: None, + change_type: PeerChangeType::NONE, + change: None, + } + } +} + +pub struct PeerChangeBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b> PeerChangeBuilder<'a, 'b> { + #[inline] + pub fn add_current_state(&mut self, current_state: flatbuffers::WIPOffset>>>) { + self.fbb_.push_slot_always::>(PeerChange::VT_CURRENT_STATE, current_state); + } + #[inline] + pub fn add_change_type(&mut self, change_type: PeerChangeType) { + self.fbb_.push_slot::(PeerChange::VT_CHANGE_TYPE, change_type, PeerChangeType::NONE); + } + #[inline] + pub fn add_change(&mut self, change: flatbuffers::WIPOffset) { + self.fbb_.push_slot_always::>(PeerChange::VT_CHANGE, change); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> PeerChangeBuilder<'a, 'b> { + let start = _fbb.start_table(); + PeerChangeBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + flatbuffers::WIPOffset::new(o.value()) + } +} + +impl core::fmt::Debug for PeerChange<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("PeerChange"); + ds.field("current_state", &self.current_state()); + ds.field("change_type", &self.change_type()); + match self.change_type() { + PeerChangeType::AddedConnection => { + if let Some(x) = self.change_as_added_connection() { + ds.field("change", &x) + } else { + ds.field("change", &"InvalidFlatbuffer: Union discriminant does not match value.") + } + }, + PeerChangeType::RemovedConnection => { + if let Some(x) = self.change_as_removed_connection() { + ds.field("change", &x) + } else { + ds.field("change", &"InvalidFlatbuffer: Union discriminant does not match value.") + } + }, + PeerChangeType::Error => { + if let Some(x) = self.change_as_error() { + ds.field("change", &x) + } else { + ds.field("change", &"InvalidFlatbuffer: Union discriminant does not match value.") + } + }, + _ => { + let x: Option<()> = None; + ds.field("change", &x) + }, + }; + ds.finish() + } +} +pub enum OkOffset {} +#[derive(Copy, Clone, PartialEq)] + +pub struct Ok<'a> { + pub _tab: flatbuffers::Table<'a>, +} + +impl<'a> flatbuffers::Follow<'a> for Ok<'a> { + type Inner = Ok<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } +} + +impl<'a> Ok<'a> { + pub const VT_MESSAGE: flatbuffers::VOffsetT = 4; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + Ok { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args OkArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = OkBuilder::new(_fbb); + if let Some(x) = args.message { builder.add_message(x); } + builder.finish() + } + + + #[inline] + pub fn message(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(Ok::VT_MESSAGE, None)} + } +} + +impl flatbuffers::Verifiable for Ok<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>("message", Self::VT_MESSAGE, false)? + .finish(); + Ok(()) + } +} +pub struct OkArgs<'a> { + pub message: Option>, +} +impl<'a> Default for OkArgs<'a> { + #[inline] + fn default() -> Self { + OkArgs { + message: None, + } + } +} + +pub struct OkBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b> OkBuilder<'a, 'b> { + #[inline] + pub fn add_message(&mut self, message: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(Ok::VT_MESSAGE, message); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> OkBuilder<'a, 'b> { + let start = _fbb.start_table(); + OkBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + flatbuffers::WIPOffset::new(o.value()) + } +} + +impl core::fmt::Debug for Ok<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("Ok"); + ds.field("message", &self.message()); + ds.finish() + } +} +pub enum ControllerResponseOffset {} +#[derive(Copy, Clone, PartialEq)] + +pub struct ControllerResponse<'a> { + pub _tab: flatbuffers::Table<'a>, +} + +impl<'a> flatbuffers::Follow<'a> for ControllerResponse<'a> { + type Inner = ControllerResponse<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } +} + +impl<'a> ControllerResponse<'a> { + pub const VT_RESPONSE_TYPE: flatbuffers::VOffsetT = 4; + pub const VT_RESPONSE: flatbuffers::VOffsetT = 6; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + ControllerResponse { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args ControllerResponseArgs + ) -> flatbuffers::WIPOffset> { + let mut builder = ControllerResponseBuilder::new(_fbb); + if let Some(x) = args.response { builder.add_response(x); } + builder.add_response_type(args.response_type); + builder.finish() + } + + + #[inline] + pub fn response_type(&self) -> Response { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(ControllerResponse::VT_RESPONSE_TYPE, Some(Response::NONE)).unwrap()} + } + #[inline] + pub fn response(&self) -> flatbuffers::Table<'a> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>(ControllerResponse::VT_RESPONSE, None).unwrap()} + } + #[inline] + #[allow(non_snake_case)] + pub fn response_as_error(&self) -> Option> { + if self.response_type() == Response::Error { + let u = self.response(); + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + Some(unsafe { Error::init_from_table(u) }) + } else { + None + } + } + + #[inline] + #[allow(non_snake_case)] + pub fn response_as_ok(&self) -> Option> { + if self.response_type() == Response::Ok { + let u = self.response(); + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + Some(unsafe { Ok::init_from_table(u) }) + } else { + None + } + } + +} + +impl flatbuffers::Verifiable for ControllerResponse<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_union::("response_type", Self::VT_RESPONSE_TYPE, "response", Self::VT_RESPONSE, true, |key, v, pos| { + match key { + Response::Error => v.verify_union_variant::>("Response::Error", pos), + Response::Ok => v.verify_union_variant::>("Response::Ok", pos), + _ => Ok(()), + } + })? + .finish(); + Ok(()) + } +} +pub struct ControllerResponseArgs { + pub response_type: Response, + pub response: Option>, +} +impl<'a> Default for ControllerResponseArgs { + #[inline] + fn default() -> Self { + ControllerResponseArgs { + response_type: Response::NONE, + response: None, // required field + } + } +} + +pub struct ControllerResponseBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b> ControllerResponseBuilder<'a, 'b> { + #[inline] + pub fn add_response_type(&mut self, response_type: Response) { + self.fbb_.push_slot::(ControllerResponse::VT_RESPONSE_TYPE, response_type, Response::NONE); + } + #[inline] + pub fn add_response(&mut self, response: flatbuffers::WIPOffset) { + self.fbb_.push_slot_always::>(ControllerResponse::VT_RESPONSE, response); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> ControllerResponseBuilder<'a, 'b> { + let start = _fbb.start_table(); + ControllerResponseBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + self.fbb_.required(o, ControllerResponse::VT_RESPONSE,"response"); + flatbuffers::WIPOffset::new(o.value()) + } +} + +impl core::fmt::Debug for ControllerResponse<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("ControllerResponse"); + ds.field("response_type", &self.response_type()); + match self.response_type() { + Response::Error => { + if let Some(x) = self.response_as_error() { + ds.field("response", &x) + } else { + ds.field("response", &"InvalidFlatbuffer: Union discriminant does not match value.") + } + }, + Response::Ok => { + if let Some(x) = self.response_as_ok() { + ds.field("response", &x) + } else { + ds.field("response", &"InvalidFlatbuffer: Union discriminant does not match value.") + } + }, + _ => { + let x: Option<()> = None; + ds.field("response", &x) + }, + }; + ds.finish() + } +} +pub enum PutRequestOffset {} +#[derive(Copy, Clone, PartialEq)] + +pub struct PutRequest<'a> { + pub _tab: flatbuffers::Table<'a>, +} + +impl<'a> flatbuffers::Follow<'a> for PutRequest<'a> { + type Inner = PutRequest<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } +} + +impl<'a> PutRequest<'a> { + pub const VT_TRANSACTION: flatbuffers::VOffsetT = 4; + pub const VT_KEY: flatbuffers::VOffsetT = 6; + pub const VT_REQUESTER: flatbuffers::VOffsetT = 8; + pub const VT_TARGET: flatbuffers::VOffsetT = 10; + pub const VT_TIMESTAMP: flatbuffers::VOffsetT = 12; + pub const VT_CONTRACT_LOCATION: flatbuffers::VOffsetT = 14; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + PutRequest { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args PutRequestArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = PutRequestBuilder::new(_fbb); + builder.add_contract_location(args.contract_location); + builder.add_timestamp(args.timestamp); + if let Some(x) = args.target { builder.add_target(x); } + if let Some(x) = args.requester { builder.add_requester(x); } + if let Some(x) = args.key { builder.add_key(x); } + if let Some(x) = args.transaction { builder.add_transaction(x); } + builder.finish() + } + + + #[inline] + pub fn transaction(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(PutRequest::VT_TRANSACTION, None).unwrap()} + } + #[inline] + pub fn key(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(PutRequest::VT_KEY, None).unwrap()} + } + #[inline] + pub fn requester(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(PutRequest::VT_REQUESTER, None).unwrap()} + } + #[inline] + pub fn target(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(PutRequest::VT_TARGET, None).unwrap()} + } + #[inline] + pub fn timestamp(&self) -> u64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(PutRequest::VT_TIMESTAMP, Some(0)).unwrap()} + } + #[inline] + pub fn contract_location(&self) -> f64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(PutRequest::VT_CONTRACT_LOCATION, Some(0.0)).unwrap()} + } +} + +impl flatbuffers::Verifiable for PutRequest<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>("transaction", Self::VT_TRANSACTION, true)? + .visit_field::>("key", Self::VT_KEY, true)? + .visit_field::>("requester", Self::VT_REQUESTER, true)? + .visit_field::>("target", Self::VT_TARGET, true)? + .visit_field::("timestamp", Self::VT_TIMESTAMP, false)? + .visit_field::("contract_location", Self::VT_CONTRACT_LOCATION, false)? + .finish(); + Ok(()) + } +} +pub struct PutRequestArgs<'a> { + pub transaction: Option>, + pub key: Option>, + pub requester: Option>, + pub target: Option>, + pub timestamp: u64, + pub contract_location: f64, +} +impl<'a> Default for PutRequestArgs<'a> { + #[inline] + fn default() -> Self { + PutRequestArgs { + transaction: None, // required field + key: None, // required field + requester: None, // required field + target: None, // required field + timestamp: 0, + contract_location: 0.0, + } + } +} + +pub struct PutRequestBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b> PutRequestBuilder<'a, 'b> { + #[inline] + pub fn add_transaction(&mut self, transaction: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(PutRequest::VT_TRANSACTION, transaction); + } + #[inline] + pub fn add_key(&mut self, key: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(PutRequest::VT_KEY, key); + } + #[inline] + pub fn add_requester(&mut self, requester: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(PutRequest::VT_REQUESTER, requester); + } + #[inline] + pub fn add_target(&mut self, target: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(PutRequest::VT_TARGET, target); + } + #[inline] + pub fn add_timestamp(&mut self, timestamp: u64) { + self.fbb_.push_slot::(PutRequest::VT_TIMESTAMP, timestamp, 0); + } + #[inline] + pub fn add_contract_location(&mut self, contract_location: f64) { + self.fbb_.push_slot::(PutRequest::VT_CONTRACT_LOCATION, contract_location, 0.0); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> PutRequestBuilder<'a, 'b> { + let start = _fbb.start_table(); + PutRequestBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + self.fbb_.required(o, PutRequest::VT_TRANSACTION,"transaction"); + self.fbb_.required(o, PutRequest::VT_KEY,"key"); + self.fbb_.required(o, PutRequest::VT_REQUESTER,"requester"); + self.fbb_.required(o, PutRequest::VT_TARGET,"target"); + flatbuffers::WIPOffset::new(o.value()) + } +} + +impl core::fmt::Debug for PutRequest<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("PutRequest"); + ds.field("transaction", &self.transaction()); + ds.field("key", &self.key()); + ds.field("requester", &self.requester()); + ds.field("target", &self.target()); + ds.field("timestamp", &self.timestamp()); + ds.field("contract_location", &self.contract_location()); + ds.finish() + } +} +pub enum UpdateRequestOffset {} +#[derive(Copy, Clone, PartialEq)] + +pub struct UpdateRequest<'a> { + pub _tab: flatbuffers::Table<'a>, +} + +impl<'a> flatbuffers::Follow<'a> for UpdateRequest<'a> { + type Inner = UpdateRequest<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } +} + +impl<'a> UpdateRequest<'a> { + pub const VT_TRANSACTION: flatbuffers::VOffsetT = 4; + pub const VT_KEY: flatbuffers::VOffsetT = 6; + pub const VT_REQUESTER: flatbuffers::VOffsetT = 8; + pub const VT_TARGET: flatbuffers::VOffsetT = 10; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + UpdateRequest { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args UpdateRequestArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = UpdateRequestBuilder::new(_fbb); + if let Some(x) = args.target { builder.add_target(x); } + if let Some(x) = args.requester { builder.add_requester(x); } + if let Some(x) = args.key { builder.add_key(x); } + if let Some(x) = args.transaction { builder.add_transaction(x); } + builder.finish() + } + + + #[inline] + pub fn transaction(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(UpdateRequest::VT_TRANSACTION, None).unwrap()} + } + #[inline] + pub fn key(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(UpdateRequest::VT_KEY, None).unwrap()} + } + #[inline] + pub fn requester(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(UpdateRequest::VT_REQUESTER, None).unwrap()} + } + #[inline] + pub fn target(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(UpdateRequest::VT_TARGET, None).unwrap()} + } +} + +impl flatbuffers::Verifiable for UpdateRequest<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>("transaction", Self::VT_TRANSACTION, true)? + .visit_field::>("key", Self::VT_KEY, true)? + .visit_field::>("requester", Self::VT_REQUESTER, true)? + .visit_field::>("target", Self::VT_TARGET, true)? + .finish(); + Ok(()) + } +} +pub struct UpdateRequestArgs<'a> { + pub transaction: Option>, + pub key: Option>, + pub requester: Option>, + pub target: Option>, +} +impl<'a> Default for UpdateRequestArgs<'a> { + #[inline] + fn default() -> Self { + UpdateRequestArgs { + transaction: None, // required field + key: None, // required field + requester: None, // required field + target: None, // required field + } + } +} + +pub struct UpdateRequestBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b> UpdateRequestBuilder<'a, 'b> { + #[inline] + pub fn add_transaction(&mut self, transaction: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(UpdateRequest::VT_TRANSACTION, transaction); + } + #[inline] + pub fn add_key(&mut self, key: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(UpdateRequest::VT_KEY, key); + } + #[inline] + pub fn add_requester(&mut self, requester: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(UpdateRequest::VT_REQUESTER, requester); + } + #[inline] + pub fn add_target(&mut self, target: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(UpdateRequest::VT_TARGET, target); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> UpdateRequestBuilder<'a, 'b> { + let start = _fbb.start_table(); + UpdateRequestBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + self.fbb_.required(o, UpdateRequest::VT_TRANSACTION,"transaction"); + self.fbb_.required(o, UpdateRequest::VT_KEY,"key"); + self.fbb_.required(o, UpdateRequest::VT_REQUESTER,"requester"); + self.fbb_.required(o, UpdateRequest::VT_TARGET,"target"); + flatbuffers::WIPOffset::new(o.value()) + } +} + +impl core::fmt::Debug for UpdateRequest<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("UpdateRequest"); + ds.field("transaction", &self.transaction()); + ds.field("key", &self.key()); + ds.field("requester", &self.requester()); + ds.field("target", &self.target()); + ds.finish() + } +} +pub enum PutSuccessOffset {} +#[derive(Copy, Clone, PartialEq)] + +pub struct PutSuccess<'a> { + pub _tab: flatbuffers::Table<'a>, +} + +impl<'a> flatbuffers::Follow<'a> for PutSuccess<'a> { + type Inner = PutSuccess<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } +} + +impl<'a> PutSuccess<'a> { + pub const VT_TRANSACTION: flatbuffers::VOffsetT = 4; + pub const VT_REQUESTER: flatbuffers::VOffsetT = 6; + pub const VT_TARGET: flatbuffers::VOffsetT = 8; + pub const VT_KEY: flatbuffers::VOffsetT = 10; + pub const VT_TIMESTAMP: flatbuffers::VOffsetT = 12; + pub const VT_CONTRACT_LOCATION: flatbuffers::VOffsetT = 14; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + PutSuccess { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args PutSuccessArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = PutSuccessBuilder::new(_fbb); + builder.add_contract_location(args.contract_location); + builder.add_timestamp(args.timestamp); + if let Some(x) = args.key { builder.add_key(x); } + if let Some(x) = args.target { builder.add_target(x); } + if let Some(x) = args.requester { builder.add_requester(x); } + if let Some(x) = args.transaction { builder.add_transaction(x); } + builder.finish() + } + + + #[inline] + pub fn transaction(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(PutSuccess::VT_TRANSACTION, None).unwrap()} + } + #[inline] + pub fn requester(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(PutSuccess::VT_REQUESTER, None).unwrap()} + } + #[inline] + pub fn target(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(PutSuccess::VT_TARGET, None).unwrap()} + } + #[inline] + pub fn key(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(PutSuccess::VT_KEY, None).unwrap()} + } + #[inline] + pub fn timestamp(&self) -> u64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(PutSuccess::VT_TIMESTAMP, Some(0)).unwrap()} + } + #[inline] + pub fn contract_location(&self) -> f64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(PutSuccess::VT_CONTRACT_LOCATION, Some(0.0)).unwrap()} + } +} + +impl flatbuffers::Verifiable for PutSuccess<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>("transaction", Self::VT_TRANSACTION, true)? + .visit_field::>("requester", Self::VT_REQUESTER, true)? + .visit_field::>("target", Self::VT_TARGET, true)? + .visit_field::>("key", Self::VT_KEY, true)? + .visit_field::("timestamp", Self::VT_TIMESTAMP, false)? + .visit_field::("contract_location", Self::VT_CONTRACT_LOCATION, false)? + .finish(); + Ok(()) + } +} +pub struct PutSuccessArgs<'a> { + pub transaction: Option>, + pub requester: Option>, + pub target: Option>, + pub key: Option>, + pub timestamp: u64, + pub contract_location: f64, +} +impl<'a> Default for PutSuccessArgs<'a> { + #[inline] + fn default() -> Self { + PutSuccessArgs { + transaction: None, // required field + requester: None, // required field + target: None, // required field + key: None, // required field + timestamp: 0, + contract_location: 0.0, + } + } +} + +pub struct PutSuccessBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b> PutSuccessBuilder<'a, 'b> { + #[inline] + pub fn add_transaction(&mut self, transaction: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(PutSuccess::VT_TRANSACTION, transaction); + } + #[inline] + pub fn add_requester(&mut self, requester: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(PutSuccess::VT_REQUESTER, requester); + } + #[inline] + pub fn add_target(&mut self, target: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(PutSuccess::VT_TARGET, target); + } + #[inline] + pub fn add_key(&mut self, key: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(PutSuccess::VT_KEY, key); + } + #[inline] + pub fn add_timestamp(&mut self, timestamp: u64) { + self.fbb_.push_slot::(PutSuccess::VT_TIMESTAMP, timestamp, 0); + } + #[inline] + pub fn add_contract_location(&mut self, contract_location: f64) { + self.fbb_.push_slot::(PutSuccess::VT_CONTRACT_LOCATION, contract_location, 0.0); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> PutSuccessBuilder<'a, 'b> { + let start = _fbb.start_table(); + PutSuccessBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + self.fbb_.required(o, PutSuccess::VT_TRANSACTION,"transaction"); + self.fbb_.required(o, PutSuccess::VT_REQUESTER,"requester"); + self.fbb_.required(o, PutSuccess::VT_TARGET,"target"); + self.fbb_.required(o, PutSuccess::VT_KEY,"key"); + flatbuffers::WIPOffset::new(o.value()) + } +} + +impl core::fmt::Debug for PutSuccess<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("PutSuccess"); + ds.field("transaction", &self.transaction()); + ds.field("requester", &self.requester()); + ds.field("target", &self.target()); + ds.field("key", &self.key()); + ds.field("timestamp", &self.timestamp()); + ds.field("contract_location", &self.contract_location()); + ds.finish() + } +} +pub enum PutFailureOffset {} +#[derive(Copy, Clone, PartialEq)] + +pub struct PutFailure<'a> { + pub _tab: flatbuffers::Table<'a>, +} + +impl<'a> flatbuffers::Follow<'a> for PutFailure<'a> { + type Inner = PutFailure<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } +} + +impl<'a> PutFailure<'a> { + pub const VT_TRANSACTION: flatbuffers::VOffsetT = 4; + pub const VT_REQUESTER: flatbuffers::VOffsetT = 6; + pub const VT_TARGET: flatbuffers::VOffsetT = 8; + pub const VT_KEY: flatbuffers::VOffsetT = 10; + pub const VT_TIMESTAMP: flatbuffers::VOffsetT = 12; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + PutFailure { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args PutFailureArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = PutFailureBuilder::new(_fbb); + builder.add_timestamp(args.timestamp); + if let Some(x) = args.key { builder.add_key(x); } + if let Some(x) = args.target { builder.add_target(x); } + if let Some(x) = args.requester { builder.add_requester(x); } + if let Some(x) = args.transaction { builder.add_transaction(x); } + builder.finish() + } + + + #[inline] + pub fn transaction(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(PutFailure::VT_TRANSACTION, None).unwrap()} + } + #[inline] + pub fn requester(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(PutFailure::VT_REQUESTER, None).unwrap()} + } + #[inline] + pub fn target(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(PutFailure::VT_TARGET, None).unwrap()} + } + #[inline] + pub fn key(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(PutFailure::VT_KEY, None).unwrap()} + } + #[inline] + pub fn timestamp(&self) -> u64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(PutFailure::VT_TIMESTAMP, Some(0)).unwrap()} + } +} + +impl flatbuffers::Verifiable for PutFailure<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>("transaction", Self::VT_TRANSACTION, true)? + .visit_field::>("requester", Self::VT_REQUESTER, true)? + .visit_field::>("target", Self::VT_TARGET, true)? + .visit_field::>("key", Self::VT_KEY, true)? + .visit_field::("timestamp", Self::VT_TIMESTAMP, false)? + .finish(); + Ok(()) + } +} +pub struct PutFailureArgs<'a> { + pub transaction: Option>, + pub requester: Option>, + pub target: Option>, + pub key: Option>, + pub timestamp: u64, +} +impl<'a> Default for PutFailureArgs<'a> { + #[inline] + fn default() -> Self { + PutFailureArgs { + transaction: None, // required field + requester: None, // required field + target: None, // required field + key: None, // required field + timestamp: 0, + } + } +} + +pub struct PutFailureBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b> PutFailureBuilder<'a, 'b> { + #[inline] + pub fn add_transaction(&mut self, transaction: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(PutFailure::VT_TRANSACTION, transaction); + } + #[inline] + pub fn add_requester(&mut self, requester: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(PutFailure::VT_REQUESTER, requester); + } + #[inline] + pub fn add_target(&mut self, target: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(PutFailure::VT_TARGET, target); + } + #[inline] + pub fn add_key(&mut self, key: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(PutFailure::VT_KEY, key); + } + #[inline] + pub fn add_timestamp(&mut self, timestamp: u64) { + self.fbb_.push_slot::(PutFailure::VT_TIMESTAMP, timestamp, 0); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> PutFailureBuilder<'a, 'b> { + let start = _fbb.start_table(); + PutFailureBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + self.fbb_.required(o, PutFailure::VT_TRANSACTION,"transaction"); + self.fbb_.required(o, PutFailure::VT_REQUESTER,"requester"); + self.fbb_.required(o, PutFailure::VT_TARGET,"target"); + self.fbb_.required(o, PutFailure::VT_KEY,"key"); + flatbuffers::WIPOffset::new(o.value()) + } +} + +impl core::fmt::Debug for PutFailure<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("PutFailure"); + ds.field("transaction", &self.transaction()); + ds.field("requester", &self.requester()); + ds.field("target", &self.target()); + ds.field("key", &self.key()); + ds.field("timestamp", &self.timestamp()); + ds.finish() + } +} +pub enum UpdateSuccessOffset {} +#[derive(Copy, Clone, PartialEq)] + +pub struct UpdateSuccess<'a> { + pub _tab: flatbuffers::Table<'a>, +} + +impl<'a> flatbuffers::Follow<'a> for UpdateSuccess<'a> { + type Inner = UpdateSuccess<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } +} + +impl<'a> UpdateSuccess<'a> { + pub const VT_TRANSACTION: flatbuffers::VOffsetT = 4; + pub const VT_REQUESTER: flatbuffers::VOffsetT = 6; + pub const VT_TARGET: flatbuffers::VOffsetT = 8; + pub const VT_KEY: flatbuffers::VOffsetT = 10; + pub const VT_TIMESTAMP: flatbuffers::VOffsetT = 12; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + UpdateSuccess { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args UpdateSuccessArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = UpdateSuccessBuilder::new(_fbb); + builder.add_timestamp(args.timestamp); + if let Some(x) = args.key { builder.add_key(x); } + if let Some(x) = args.target { builder.add_target(x); } + if let Some(x) = args.requester { builder.add_requester(x); } + if let Some(x) = args.transaction { builder.add_transaction(x); } + builder.finish() + } + + + #[inline] + pub fn transaction(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(UpdateSuccess::VT_TRANSACTION, None).unwrap()} + } + #[inline] + pub fn requester(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(UpdateSuccess::VT_REQUESTER, None).unwrap()} + } + #[inline] + pub fn target(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(UpdateSuccess::VT_TARGET, None).unwrap()} + } + #[inline] + pub fn key(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(UpdateSuccess::VT_KEY, None).unwrap()} + } + #[inline] + pub fn timestamp(&self) -> u64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(UpdateSuccess::VT_TIMESTAMP, Some(0)).unwrap()} + } +} + +impl flatbuffers::Verifiable for UpdateSuccess<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>("transaction", Self::VT_TRANSACTION, true)? + .visit_field::>("requester", Self::VT_REQUESTER, true)? + .visit_field::>("target", Self::VT_TARGET, true)? + .visit_field::>("key", Self::VT_KEY, true)? + .visit_field::("timestamp", Self::VT_TIMESTAMP, false)? + .finish(); + Ok(()) + } +} +pub struct UpdateSuccessArgs<'a> { + pub transaction: Option>, + pub requester: Option>, + pub target: Option>, + pub key: Option>, + pub timestamp: u64, +} +impl<'a> Default for UpdateSuccessArgs<'a> { + #[inline] + fn default() -> Self { + UpdateSuccessArgs { + transaction: None, // required field + requester: None, // required field + target: None, // required field + key: None, // required field + timestamp: 0, + } + } +} + +pub struct UpdateSuccessBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b> UpdateSuccessBuilder<'a, 'b> { + #[inline] + pub fn add_transaction(&mut self, transaction: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(UpdateSuccess::VT_TRANSACTION, transaction); + } + #[inline] + pub fn add_requester(&mut self, requester: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(UpdateSuccess::VT_REQUESTER, requester); + } + #[inline] + pub fn add_target(&mut self, target: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(UpdateSuccess::VT_TARGET, target); + } + #[inline] + pub fn add_key(&mut self, key: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(UpdateSuccess::VT_KEY, key); + } + #[inline] + pub fn add_timestamp(&mut self, timestamp: u64) { + self.fbb_.push_slot::(UpdateSuccess::VT_TIMESTAMP, timestamp, 0); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> UpdateSuccessBuilder<'a, 'b> { + let start = _fbb.start_table(); + UpdateSuccessBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + self.fbb_.required(o, UpdateSuccess::VT_TRANSACTION,"transaction"); + self.fbb_.required(o, UpdateSuccess::VT_REQUESTER,"requester"); + self.fbb_.required(o, UpdateSuccess::VT_TARGET,"target"); + self.fbb_.required(o, UpdateSuccess::VT_KEY,"key"); + flatbuffers::WIPOffset::new(o.value()) + } +} + +impl core::fmt::Debug for UpdateSuccess<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("UpdateSuccess"); + ds.field("transaction", &self.transaction()); + ds.field("requester", &self.requester()); + ds.field("target", &self.target()); + ds.field("key", &self.key()); + ds.field("timestamp", &self.timestamp()); + ds.finish() + } +} +pub enum UpdateFailureOffset {} +#[derive(Copy, Clone, PartialEq)] + +pub struct UpdateFailure<'a> { + pub _tab: flatbuffers::Table<'a>, +} + +impl<'a> flatbuffers::Follow<'a> for UpdateFailure<'a> { + type Inner = UpdateFailure<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } +} + +impl<'a> UpdateFailure<'a> { + pub const VT_TRANSACTION: flatbuffers::VOffsetT = 4; + pub const VT_REQUESTER: flatbuffers::VOffsetT = 6; + pub const VT_TARGET: flatbuffers::VOffsetT = 8; + pub const VT_KEY: flatbuffers::VOffsetT = 10; + pub const VT_TIMESTAMP: flatbuffers::VOffsetT = 12; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + UpdateFailure { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args UpdateFailureArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = UpdateFailureBuilder::new(_fbb); + builder.add_timestamp(args.timestamp); + if let Some(x) = args.key { builder.add_key(x); } + if let Some(x) = args.target { builder.add_target(x); } + if let Some(x) = args.requester { builder.add_requester(x); } + if let Some(x) = args.transaction { builder.add_transaction(x); } + builder.finish() + } + + + #[inline] + pub fn transaction(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(UpdateFailure::VT_TRANSACTION, None).unwrap()} + } + #[inline] + pub fn requester(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(UpdateFailure::VT_REQUESTER, None).unwrap()} + } + #[inline] + pub fn target(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(UpdateFailure::VT_TARGET, None).unwrap()} + } + #[inline] + pub fn key(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(UpdateFailure::VT_KEY, None).unwrap()} + } + #[inline] + pub fn timestamp(&self) -> u64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(UpdateFailure::VT_TIMESTAMP, Some(0)).unwrap()} + } +} + +impl flatbuffers::Verifiable for UpdateFailure<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>("transaction", Self::VT_TRANSACTION, true)? + .visit_field::>("requester", Self::VT_REQUESTER, true)? + .visit_field::>("target", Self::VT_TARGET, true)? + .visit_field::>("key", Self::VT_KEY, true)? + .visit_field::("timestamp", Self::VT_TIMESTAMP, false)? + .finish(); + Ok(()) + } +} +pub struct UpdateFailureArgs<'a> { + pub transaction: Option>, + pub requester: Option>, + pub target: Option>, + pub key: Option>, + pub timestamp: u64, +} +impl<'a> Default for UpdateFailureArgs<'a> { + #[inline] + fn default() -> Self { + UpdateFailureArgs { + transaction: None, // required field + requester: None, // required field + target: None, // required field + key: None, // required field + timestamp: 0, + } + } +} + +pub struct UpdateFailureBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b> UpdateFailureBuilder<'a, 'b> { + #[inline] + pub fn add_transaction(&mut self, transaction: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(UpdateFailure::VT_TRANSACTION, transaction); + } + #[inline] + pub fn add_requester(&mut self, requester: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(UpdateFailure::VT_REQUESTER, requester); + } + #[inline] + pub fn add_target(&mut self, target: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(UpdateFailure::VT_TARGET, target); + } + #[inline] + pub fn add_key(&mut self, key: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(UpdateFailure::VT_KEY, key); + } + #[inline] + pub fn add_timestamp(&mut self, timestamp: u64) { + self.fbb_.push_slot::(UpdateFailure::VT_TIMESTAMP, timestamp, 0); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> UpdateFailureBuilder<'a, 'b> { + let start = _fbb.start_table(); + UpdateFailureBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + self.fbb_.required(o, UpdateFailure::VT_TRANSACTION,"transaction"); + self.fbb_.required(o, UpdateFailure::VT_REQUESTER,"requester"); + self.fbb_.required(o, UpdateFailure::VT_TARGET,"target"); + self.fbb_.required(o, UpdateFailure::VT_KEY,"key"); + flatbuffers::WIPOffset::new(o.value()) + } +} + +impl core::fmt::Debug for UpdateFailure<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("UpdateFailure"); + ds.field("transaction", &self.transaction()); + ds.field("requester", &self.requester()); + ds.field("target", &self.target()); + ds.field("key", &self.key()); + ds.field("timestamp", &self.timestamp()); + ds.finish() + } +} +pub enum BroadcastEmittedOffset {} +#[derive(Copy, Clone, PartialEq)] + +pub struct BroadcastEmitted<'a> { + pub _tab: flatbuffers::Table<'a>, +} + +impl<'a> flatbuffers::Follow<'a> for BroadcastEmitted<'a> { + type Inner = BroadcastEmitted<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } +} + +impl<'a> BroadcastEmitted<'a> { + pub const VT_TRANSACTION: flatbuffers::VOffsetT = 4; + pub const VT_UPSTREAM: flatbuffers::VOffsetT = 6; + pub const VT_BROADCAST_TO: flatbuffers::VOffsetT = 8; + pub const VT_BROADCASTED_TO: flatbuffers::VOffsetT = 10; + pub const VT_KEY: flatbuffers::VOffsetT = 12; + pub const VT_SENDER: flatbuffers::VOffsetT = 14; + pub const VT_TIMESTAMP: flatbuffers::VOffsetT = 16; + pub const VT_CONTRACT_LOCATION: flatbuffers::VOffsetT = 18; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + BroadcastEmitted { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args BroadcastEmittedArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = BroadcastEmittedBuilder::new(_fbb); + builder.add_contract_location(args.contract_location); + builder.add_timestamp(args.timestamp); + if let Some(x) = args.sender { builder.add_sender(x); } + if let Some(x) = args.key { builder.add_key(x); } + builder.add_broadcasted_to(args.broadcasted_to); + if let Some(x) = args.broadcast_to { builder.add_broadcast_to(x); } + if let Some(x) = args.upstream { builder.add_upstream(x); } + if let Some(x) = args.transaction { builder.add_transaction(x); } + builder.finish() + } + + + #[inline] + pub fn transaction(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(BroadcastEmitted::VT_TRANSACTION, None).unwrap()} + } + #[inline] + pub fn upstream(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(BroadcastEmitted::VT_UPSTREAM, None).unwrap()} + } + #[inline] + pub fn broadcast_to(&self) -> Option>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>>(BroadcastEmitted::VT_BROADCAST_TO, None)} + } + #[inline] + pub fn broadcasted_to(&self) -> u32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(BroadcastEmitted::VT_BROADCASTED_TO, Some(0)).unwrap()} + } + #[inline] + pub fn key(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(BroadcastEmitted::VT_KEY, None).unwrap()} + } + #[inline] + pub fn sender(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(BroadcastEmitted::VT_SENDER, None).unwrap()} + } + #[inline] + pub fn timestamp(&self) -> u64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(BroadcastEmitted::VT_TIMESTAMP, Some(0)).unwrap()} + } + #[inline] + pub fn contract_location(&self) -> f64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(BroadcastEmitted::VT_CONTRACT_LOCATION, Some(0.0)).unwrap()} + } +} + +impl flatbuffers::Verifiable for BroadcastEmitted<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>("transaction", Self::VT_TRANSACTION, true)? + .visit_field::>("upstream", Self::VT_UPSTREAM, true)? + .visit_field::>>>("broadcast_to", Self::VT_BROADCAST_TO, false)? + .visit_field::("broadcasted_to", Self::VT_BROADCASTED_TO, false)? + .visit_field::>("key", Self::VT_KEY, true)? + .visit_field::>("sender", Self::VT_SENDER, true)? + .visit_field::("timestamp", Self::VT_TIMESTAMP, false)? + .visit_field::("contract_location", Self::VT_CONTRACT_LOCATION, false)? + .finish(); + Ok(()) + } +} +pub struct BroadcastEmittedArgs<'a> { + pub transaction: Option>, + pub upstream: Option>, + pub broadcast_to: Option>>>, + pub broadcasted_to: u32, + pub key: Option>, + pub sender: Option>, + pub timestamp: u64, + pub contract_location: f64, +} +impl<'a> Default for BroadcastEmittedArgs<'a> { + #[inline] + fn default() -> Self { + BroadcastEmittedArgs { + transaction: None, // required field + upstream: None, // required field + broadcast_to: None, + broadcasted_to: 0, + key: None, // required field + sender: None, // required field + timestamp: 0, + contract_location: 0.0, + } + } +} + +pub struct BroadcastEmittedBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b> BroadcastEmittedBuilder<'a, 'b> { + #[inline] + pub fn add_transaction(&mut self, transaction: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(BroadcastEmitted::VT_TRANSACTION, transaction); + } + #[inline] + pub fn add_upstream(&mut self, upstream: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(BroadcastEmitted::VT_UPSTREAM, upstream); + } + #[inline] + pub fn add_broadcast_to(&mut self, broadcast_to: flatbuffers::WIPOffset>>) { + self.fbb_.push_slot_always::>(BroadcastEmitted::VT_BROADCAST_TO, broadcast_to); + } + #[inline] + pub fn add_broadcasted_to(&mut self, broadcasted_to: u32) { + self.fbb_.push_slot::(BroadcastEmitted::VT_BROADCASTED_TO, broadcasted_to, 0); + } + #[inline] + pub fn add_key(&mut self, key: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(BroadcastEmitted::VT_KEY, key); + } + #[inline] + pub fn add_sender(&mut self, sender: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(BroadcastEmitted::VT_SENDER, sender); + } + #[inline] + pub fn add_timestamp(&mut self, timestamp: u64) { + self.fbb_.push_slot::(BroadcastEmitted::VT_TIMESTAMP, timestamp, 0); + } + #[inline] + pub fn add_contract_location(&mut self, contract_location: f64) { + self.fbb_.push_slot::(BroadcastEmitted::VT_CONTRACT_LOCATION, contract_location, 0.0); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> BroadcastEmittedBuilder<'a, 'b> { + let start = _fbb.start_table(); + BroadcastEmittedBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + self.fbb_.required(o, BroadcastEmitted::VT_TRANSACTION,"transaction"); + self.fbb_.required(o, BroadcastEmitted::VT_UPSTREAM,"upstream"); + self.fbb_.required(o, BroadcastEmitted::VT_KEY,"key"); + self.fbb_.required(o, BroadcastEmitted::VT_SENDER,"sender"); + flatbuffers::WIPOffset::new(o.value()) + } +} + +impl core::fmt::Debug for BroadcastEmitted<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("BroadcastEmitted"); + ds.field("transaction", &self.transaction()); + ds.field("upstream", &self.upstream()); + ds.field("broadcast_to", &self.broadcast_to()); + ds.field("broadcasted_to", &self.broadcasted_to()); + ds.field("key", &self.key()); + ds.field("sender", &self.sender()); + ds.field("timestamp", &self.timestamp()); + ds.field("contract_location", &self.contract_location()); + ds.finish() + } +} +pub enum BroadcastReceivedOffset {} +#[derive(Copy, Clone, PartialEq)] + +pub struct BroadcastReceived<'a> { + pub _tab: flatbuffers::Table<'a>, +} + +impl<'a> flatbuffers::Follow<'a> for BroadcastReceived<'a> { + type Inner = BroadcastReceived<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } +} + +impl<'a> BroadcastReceived<'a> { + pub const VT_TRANSACTION: flatbuffers::VOffsetT = 4; + pub const VT_TARGET: flatbuffers::VOffsetT = 6; + pub const VT_REQUESTER: flatbuffers::VOffsetT = 8; + pub const VT_KEY: flatbuffers::VOffsetT = 10; + pub const VT_TIMESTAMP: flatbuffers::VOffsetT = 12; + pub const VT_CONTRACT_LOCATION: flatbuffers::VOffsetT = 14; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + BroadcastReceived { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args BroadcastReceivedArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = BroadcastReceivedBuilder::new(_fbb); + builder.add_contract_location(args.contract_location); + builder.add_timestamp(args.timestamp); + if let Some(x) = args.key { builder.add_key(x); } + if let Some(x) = args.requester { builder.add_requester(x); } + if let Some(x) = args.target { builder.add_target(x); } + if let Some(x) = args.transaction { builder.add_transaction(x); } + builder.finish() + } + + + #[inline] + pub fn transaction(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(BroadcastReceived::VT_TRANSACTION, None).unwrap()} + } + #[inline] + pub fn target(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(BroadcastReceived::VT_TARGET, None).unwrap()} + } + #[inline] + pub fn requester(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(BroadcastReceived::VT_REQUESTER, None).unwrap()} + } + #[inline] + pub fn key(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(BroadcastReceived::VT_KEY, None).unwrap()} + } + #[inline] + pub fn timestamp(&self) -> u64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(BroadcastReceived::VT_TIMESTAMP, Some(0)).unwrap()} + } + #[inline] + pub fn contract_location(&self) -> f64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(BroadcastReceived::VT_CONTRACT_LOCATION, Some(0.0)).unwrap()} + } +} + +impl flatbuffers::Verifiable for BroadcastReceived<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>("transaction", Self::VT_TRANSACTION, true)? + .visit_field::>("target", Self::VT_TARGET, true)? + .visit_field::>("requester", Self::VT_REQUESTER, true)? + .visit_field::>("key", Self::VT_KEY, true)? + .visit_field::("timestamp", Self::VT_TIMESTAMP, false)? + .visit_field::("contract_location", Self::VT_CONTRACT_LOCATION, false)? + .finish(); + Ok(()) + } +} +pub struct BroadcastReceivedArgs<'a> { + pub transaction: Option>, + pub target: Option>, + pub requester: Option>, + pub key: Option>, + pub timestamp: u64, + pub contract_location: f64, +} +impl<'a> Default for BroadcastReceivedArgs<'a> { + #[inline] + fn default() -> Self { + BroadcastReceivedArgs { + transaction: None, // required field + target: None, // required field + requester: None, // required field + key: None, // required field + timestamp: 0, + contract_location: 0.0, + } + } +} + +pub struct BroadcastReceivedBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b> BroadcastReceivedBuilder<'a, 'b> { + #[inline] + pub fn add_transaction(&mut self, transaction: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(BroadcastReceived::VT_TRANSACTION, transaction); + } + #[inline] + pub fn add_target(&mut self, target: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(BroadcastReceived::VT_TARGET, target); + } + #[inline] + pub fn add_requester(&mut self, requester: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(BroadcastReceived::VT_REQUESTER, requester); + } + #[inline] + pub fn add_key(&mut self, key: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(BroadcastReceived::VT_KEY, key); + } + #[inline] + pub fn add_timestamp(&mut self, timestamp: u64) { + self.fbb_.push_slot::(BroadcastReceived::VT_TIMESTAMP, timestamp, 0); + } + #[inline] + pub fn add_contract_location(&mut self, contract_location: f64) { + self.fbb_.push_slot::(BroadcastReceived::VT_CONTRACT_LOCATION, contract_location, 0.0); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> BroadcastReceivedBuilder<'a, 'b> { + let start = _fbb.start_table(); + BroadcastReceivedBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + self.fbb_.required(o, BroadcastReceived::VT_TRANSACTION,"transaction"); + self.fbb_.required(o, BroadcastReceived::VT_TARGET,"target"); + self.fbb_.required(o, BroadcastReceived::VT_REQUESTER,"requester"); + self.fbb_.required(o, BroadcastReceived::VT_KEY,"key"); + flatbuffers::WIPOffset::new(o.value()) + } +} + +impl core::fmt::Debug for BroadcastReceived<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("BroadcastReceived"); + ds.field("transaction", &self.transaction()); + ds.field("target", &self.target()); + ds.field("requester", &self.requester()); + ds.field("key", &self.key()); + ds.field("timestamp", &self.timestamp()); + ds.field("contract_location", &self.contract_location()); + ds.finish() + } +} +pub enum GetContractOffset {} +#[derive(Copy, Clone, PartialEq)] + +pub struct GetContract<'a> { + pub _tab: flatbuffers::Table<'a>, +} + +impl<'a> flatbuffers::Follow<'a> for GetContract<'a> { + type Inner = GetContract<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } +} + +impl<'a> GetContract<'a> { + pub const VT_REQUESTER: flatbuffers::VOffsetT = 4; + pub const VT_TARGET: flatbuffers::VOffsetT = 6; + pub const VT_TRANSACTION: flatbuffers::VOffsetT = 8; + pub const VT_KEY: flatbuffers::VOffsetT = 10; + pub const VT_CONTRACT_LOCATION: flatbuffers::VOffsetT = 12; + pub const VT_TIMESTAMP: flatbuffers::VOffsetT = 14; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + GetContract { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args GetContractArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = GetContractBuilder::new(_fbb); + builder.add_timestamp(args.timestamp); + builder.add_contract_location(args.contract_location); + if let Some(x) = args.key { builder.add_key(x); } + if let Some(x) = args.transaction { builder.add_transaction(x); } + if let Some(x) = args.target { builder.add_target(x); } + if let Some(x) = args.requester { builder.add_requester(x); } + builder.finish() + } + + + #[inline] + pub fn requester(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(GetContract::VT_REQUESTER, None).unwrap()} + } + #[inline] + pub fn target(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(GetContract::VT_TARGET, None).unwrap()} + } + #[inline] + pub fn transaction(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(GetContract::VT_TRANSACTION, None).unwrap()} + } + #[inline] + pub fn key(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(GetContract::VT_KEY, None).unwrap()} + } + #[inline] + pub fn contract_location(&self) -> f64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(GetContract::VT_CONTRACT_LOCATION, Some(0.0)).unwrap()} + } + #[inline] + pub fn timestamp(&self) -> u64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(GetContract::VT_TIMESTAMP, Some(0)).unwrap()} + } +} + +impl flatbuffers::Verifiable for GetContract<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>("requester", Self::VT_REQUESTER, true)? + .visit_field::>("target", Self::VT_TARGET, true)? + .visit_field::>("transaction", Self::VT_TRANSACTION, true)? + .visit_field::>("key", Self::VT_KEY, true)? + .visit_field::("contract_location", Self::VT_CONTRACT_LOCATION, false)? + .visit_field::("timestamp", Self::VT_TIMESTAMP, false)? + .finish(); + Ok(()) + } +} +pub struct GetContractArgs<'a> { + pub requester: Option>, + pub target: Option>, + pub transaction: Option>, + pub key: Option>, + pub contract_location: f64, + pub timestamp: u64, +} +impl<'a> Default for GetContractArgs<'a> { + #[inline] + fn default() -> Self { + GetContractArgs { + requester: None, // required field + target: None, // required field + transaction: None, // required field + key: None, // required field + contract_location: 0.0, + timestamp: 0, + } + } +} + +pub struct GetContractBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b> GetContractBuilder<'a, 'b> { + #[inline] + pub fn add_requester(&mut self, requester: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(GetContract::VT_REQUESTER, requester); + } + #[inline] + pub fn add_target(&mut self, target: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(GetContract::VT_TARGET, target); + } + #[inline] + pub fn add_transaction(&mut self, transaction: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(GetContract::VT_TRANSACTION, transaction); + } + #[inline] + pub fn add_key(&mut self, key: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(GetContract::VT_KEY, key); + } + #[inline] + pub fn add_contract_location(&mut self, contract_location: f64) { + self.fbb_.push_slot::(GetContract::VT_CONTRACT_LOCATION, contract_location, 0.0); + } + #[inline] + pub fn add_timestamp(&mut self, timestamp: u64) { + self.fbb_.push_slot::(GetContract::VT_TIMESTAMP, timestamp, 0); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> GetContractBuilder<'a, 'b> { + let start = _fbb.start_table(); + GetContractBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + self.fbb_.required(o, GetContract::VT_REQUESTER,"requester"); + self.fbb_.required(o, GetContract::VT_TARGET,"target"); + self.fbb_.required(o, GetContract::VT_TRANSACTION,"transaction"); + self.fbb_.required(o, GetContract::VT_KEY,"key"); + flatbuffers::WIPOffset::new(o.value()) + } +} + +impl core::fmt::Debug for GetContract<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("GetContract"); + ds.field("requester", &self.requester()); + ds.field("target", &self.target()); + ds.field("transaction", &self.transaction()); + ds.field("key", &self.key()); + ds.field("contract_location", &self.contract_location()); + ds.field("timestamp", &self.timestamp()); + ds.finish() + } +} +pub enum SubscribedToContractOffset {} +#[derive(Copy, Clone, PartialEq)] + +pub struct SubscribedToContract<'a> { + pub _tab: flatbuffers::Table<'a>, +} + +impl<'a> flatbuffers::Follow<'a> for SubscribedToContract<'a> { + type Inner = SubscribedToContract<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } +} + +impl<'a> SubscribedToContract<'a> { + pub const VT_REQUESTER: flatbuffers::VOffsetT = 4; + pub const VT_TRANSACTION: flatbuffers::VOffsetT = 6; + pub const VT_KEY: flatbuffers::VOffsetT = 8; + pub const VT_CONTRACT_LOCATION: flatbuffers::VOffsetT = 10; + pub const VT_AT_PEER: flatbuffers::VOffsetT = 12; + pub const VT_AT_PEER_LOCATION: flatbuffers::VOffsetT = 14; + pub const VT_TIMESTAMP: flatbuffers::VOffsetT = 16; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + SubscribedToContract { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args SubscribedToContractArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = SubscribedToContractBuilder::new(_fbb); + builder.add_timestamp(args.timestamp); + builder.add_at_peer_location(args.at_peer_location); + builder.add_contract_location(args.contract_location); + if let Some(x) = args.at_peer { builder.add_at_peer(x); } + if let Some(x) = args.key { builder.add_key(x); } + if let Some(x) = args.transaction { builder.add_transaction(x); } + if let Some(x) = args.requester { builder.add_requester(x); } + builder.finish() + } + + + #[inline] + pub fn requester(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(SubscribedToContract::VT_REQUESTER, None).unwrap()} + } + #[inline] + pub fn transaction(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(SubscribedToContract::VT_TRANSACTION, None).unwrap()} + } + #[inline] + pub fn key(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(SubscribedToContract::VT_KEY, None).unwrap()} + } + #[inline] + pub fn contract_location(&self) -> f64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(SubscribedToContract::VT_CONTRACT_LOCATION, Some(0.0)).unwrap()} + } + #[inline] + pub fn at_peer(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(SubscribedToContract::VT_AT_PEER, None).unwrap()} + } + #[inline] + pub fn at_peer_location(&self) -> f64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(SubscribedToContract::VT_AT_PEER_LOCATION, Some(0.0)).unwrap()} + } + #[inline] + pub fn timestamp(&self) -> u64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(SubscribedToContract::VT_TIMESTAMP, Some(0)).unwrap()} + } +} + +impl flatbuffers::Verifiable for SubscribedToContract<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>("requester", Self::VT_REQUESTER, true)? + .visit_field::>("transaction", Self::VT_TRANSACTION, true)? + .visit_field::>("key", Self::VT_KEY, true)? + .visit_field::("contract_location", Self::VT_CONTRACT_LOCATION, false)? + .visit_field::>("at_peer", Self::VT_AT_PEER, true)? + .visit_field::("at_peer_location", Self::VT_AT_PEER_LOCATION, false)? + .visit_field::("timestamp", Self::VT_TIMESTAMP, false)? + .finish(); + Ok(()) + } +} +pub struct SubscribedToContractArgs<'a> { + pub requester: Option>, + pub transaction: Option>, + pub key: Option>, + pub contract_location: f64, + pub at_peer: Option>, + pub at_peer_location: f64, + pub timestamp: u64, +} +impl<'a> Default for SubscribedToContractArgs<'a> { + #[inline] + fn default() -> Self { + SubscribedToContractArgs { + requester: None, // required field + transaction: None, // required field + key: None, // required field + contract_location: 0.0, + at_peer: None, // required field + at_peer_location: 0.0, + timestamp: 0, + } + } +} + +pub struct SubscribedToContractBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b> SubscribedToContractBuilder<'a, 'b> { + #[inline] + pub fn add_requester(&mut self, requester: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(SubscribedToContract::VT_REQUESTER, requester); + } + #[inline] + pub fn add_transaction(&mut self, transaction: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(SubscribedToContract::VT_TRANSACTION, transaction); + } + #[inline] + pub fn add_key(&mut self, key: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(SubscribedToContract::VT_KEY, key); + } + #[inline] + pub fn add_contract_location(&mut self, contract_location: f64) { + self.fbb_.push_slot::(SubscribedToContract::VT_CONTRACT_LOCATION, contract_location, 0.0); + } + #[inline] + pub fn add_at_peer(&mut self, at_peer: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(SubscribedToContract::VT_AT_PEER, at_peer); + } + #[inline] + pub fn add_at_peer_location(&mut self, at_peer_location: f64) { + self.fbb_.push_slot::(SubscribedToContract::VT_AT_PEER_LOCATION, at_peer_location, 0.0); + } + #[inline] + pub fn add_timestamp(&mut self, timestamp: u64) { + self.fbb_.push_slot::(SubscribedToContract::VT_TIMESTAMP, timestamp, 0); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> SubscribedToContractBuilder<'a, 'b> { + let start = _fbb.start_table(); + SubscribedToContractBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + self.fbb_.required(o, SubscribedToContract::VT_REQUESTER,"requester"); + self.fbb_.required(o, SubscribedToContract::VT_TRANSACTION,"transaction"); + self.fbb_.required(o, SubscribedToContract::VT_KEY,"key"); + self.fbb_.required(o, SubscribedToContract::VT_AT_PEER,"at_peer"); + flatbuffers::WIPOffset::new(o.value()) + } +} + +impl core::fmt::Debug for SubscribedToContract<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("SubscribedToContract"); + ds.field("requester", &self.requester()); + ds.field("transaction", &self.transaction()); + ds.field("key", &self.key()); + ds.field("contract_location", &self.contract_location()); + ds.field("at_peer", &self.at_peer()); + ds.field("at_peer_location", &self.at_peer_location()); + ds.field("timestamp", &self.timestamp()); + ds.finish() + } +} +pub enum ContractChangeOffset {} +#[derive(Copy, Clone, PartialEq)] + +pub struct ContractChange<'a> { + pub _tab: flatbuffers::Table<'a>, +} + +impl<'a> flatbuffers::Follow<'a> for ContractChange<'a> { + type Inner = ContractChange<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } +} + +impl<'a> ContractChange<'a> { + pub const VT_CONTRACT_ID: flatbuffers::VOffsetT = 4; + pub const VT_CHANGE_TYPE: flatbuffers::VOffsetT = 6; + pub const VT_CHANGE: flatbuffers::VOffsetT = 8; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + ContractChange { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args ContractChangeArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = ContractChangeBuilder::new(_fbb); + if let Some(x) = args.change { builder.add_change(x); } + if let Some(x) = args.contract_id { builder.add_contract_id(x); } + builder.add_change_type(args.change_type); + builder.finish() + } + + + #[inline] + pub fn contract_id(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(ContractChange::VT_CONTRACT_ID, None).unwrap()} + } + #[inline] + pub fn change_type(&self) -> ContractChangeType { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(ContractChange::VT_CHANGE_TYPE, Some(ContractChangeType::NONE)).unwrap()} + } + #[inline] + pub fn change(&self) -> Option> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>(ContractChange::VT_CHANGE, None)} + } + #[inline] + #[allow(non_snake_case)] + pub fn change_as_put_request(&self) -> Option> { + if self.change_type() == ContractChangeType::PutRequest { + self.change().map(|t| { + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + unsafe { PutRequest::init_from_table(t) } + }) + } else { + None + } + } + + #[inline] + #[allow(non_snake_case)] + pub fn change_as_put_success(&self) -> Option> { + if self.change_type() == ContractChangeType::PutSuccess { + self.change().map(|t| { + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + unsafe { PutSuccess::init_from_table(t) } + }) + } else { + None + } + } + + #[inline] + #[allow(non_snake_case)] + pub fn change_as_put_failure(&self) -> Option> { + if self.change_type() == ContractChangeType::PutFailure { + self.change().map(|t| { + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + unsafe { PutFailure::init_from_table(t) } + }) + } else { + None + } + } + + #[inline] + #[allow(non_snake_case)] + pub fn change_as_broadcast_emitted(&self) -> Option> { + if self.change_type() == ContractChangeType::BroadcastEmitted { + self.change().map(|t| { + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + unsafe { BroadcastEmitted::init_from_table(t) } + }) + } else { + None + } + } + + #[inline] + #[allow(non_snake_case)] + pub fn change_as_broadcast_received(&self) -> Option> { + if self.change_type() == ContractChangeType::BroadcastReceived { + self.change().map(|t| { + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + unsafe { BroadcastReceived::init_from_table(t) } + }) + } else { + None + } + } + + #[inline] + #[allow(non_snake_case)] + pub fn change_as_update_request(&self) -> Option> { + if self.change_type() == ContractChangeType::UpdateRequest { + self.change().map(|t| { + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + unsafe { UpdateRequest::init_from_table(t) } + }) + } else { + None + } + } + + #[inline] + #[allow(non_snake_case)] + pub fn change_as_update_success(&self) -> Option> { + if self.change_type() == ContractChangeType::UpdateSuccess { + self.change().map(|t| { + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + unsafe { UpdateSuccess::init_from_table(t) } + }) + } else { + None + } + } + + #[inline] + #[allow(non_snake_case)] + pub fn change_as_update_failure(&self) -> Option> { + if self.change_type() == ContractChangeType::UpdateFailure { + self.change().map(|t| { + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + unsafe { UpdateFailure::init_from_table(t) } + }) + } else { + None + } + } + + #[inline] + #[allow(non_snake_case)] + pub fn change_as_get_contract(&self) -> Option> { + if self.change_type() == ContractChangeType::GetContract { + self.change().map(|t| { + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + unsafe { GetContract::init_from_table(t) } + }) + } else { + None + } + } + + #[inline] + #[allow(non_snake_case)] + pub fn change_as_subscribed_to_contract(&self) -> Option> { + if self.change_type() == ContractChangeType::SubscribedToContract { + self.change().map(|t| { + // Safety: + // Created from a valid Table for this object + // Which contains a valid union in this slot + unsafe { SubscribedToContract::init_from_table(t) } + }) + } else { + None + } + } + +} + +impl flatbuffers::Verifiable for ContractChange<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>("contract_id", Self::VT_CONTRACT_ID, true)? + .visit_union::("change_type", Self::VT_CHANGE_TYPE, "change", Self::VT_CHANGE, false, |key, v, pos| { + match key { + ContractChangeType::PutRequest => v.verify_union_variant::>("ContractChangeType::PutRequest", pos), + ContractChangeType::PutSuccess => v.verify_union_variant::>("ContractChangeType::PutSuccess", pos), + ContractChangeType::PutFailure => v.verify_union_variant::>("ContractChangeType::PutFailure", pos), + ContractChangeType::BroadcastEmitted => v.verify_union_variant::>("ContractChangeType::BroadcastEmitted", pos), + ContractChangeType::BroadcastReceived => v.verify_union_variant::>("ContractChangeType::BroadcastReceived", pos), + ContractChangeType::UpdateRequest => v.verify_union_variant::>("ContractChangeType::UpdateRequest", pos), + ContractChangeType::UpdateSuccess => v.verify_union_variant::>("ContractChangeType::UpdateSuccess", pos), + ContractChangeType::UpdateFailure => v.verify_union_variant::>("ContractChangeType::UpdateFailure", pos), + ContractChangeType::GetContract => v.verify_union_variant::>("ContractChangeType::GetContract", pos), + ContractChangeType::SubscribedToContract => v.verify_union_variant::>("ContractChangeType::SubscribedToContract", pos), + _ => Ok(()), + } + })? + .finish(); + Ok(()) + } +} +pub struct ContractChangeArgs<'a> { + pub contract_id: Option>, + pub change_type: ContractChangeType, + pub change: Option>, +} +impl<'a> Default for ContractChangeArgs<'a> { + #[inline] + fn default() -> Self { + ContractChangeArgs { + contract_id: None, // required field + change_type: ContractChangeType::NONE, + change: None, + } + } +} + +pub struct ContractChangeBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b> ContractChangeBuilder<'a, 'b> { + #[inline] + pub fn add_contract_id(&mut self, contract_id: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(ContractChange::VT_CONTRACT_ID, contract_id); + } + #[inline] + pub fn add_change_type(&mut self, change_type: ContractChangeType) { + self.fbb_.push_slot::(ContractChange::VT_CHANGE_TYPE, change_type, ContractChangeType::NONE); + } + #[inline] + pub fn add_change(&mut self, change: flatbuffers::WIPOffset) { + self.fbb_.push_slot_always::>(ContractChange::VT_CHANGE, change); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> ContractChangeBuilder<'a, 'b> { + let start = _fbb.start_table(); + ContractChangeBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + self.fbb_.required(o, ContractChange::VT_CONTRACT_ID,"contract_id"); + flatbuffers::WIPOffset::new(o.value()) + } +} + +impl core::fmt::Debug for ContractChange<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("ContractChange"); + ds.field("contract_id", &self.contract_id()); + ds.field("change_type", &self.change_type()); + match self.change_type() { + ContractChangeType::PutRequest => { + if let Some(x) = self.change_as_put_request() { + ds.field("change", &x) + } else { + ds.field("change", &"InvalidFlatbuffer: Union discriminant does not match value.") + } + }, + ContractChangeType::PutSuccess => { + if let Some(x) = self.change_as_put_success() { + ds.field("change", &x) + } else { + ds.field("change", &"InvalidFlatbuffer: Union discriminant does not match value.") + } + }, + ContractChangeType::PutFailure => { + if let Some(x) = self.change_as_put_failure() { + ds.field("change", &x) + } else { + ds.field("change", &"InvalidFlatbuffer: Union discriminant does not match value.") + } + }, + ContractChangeType::BroadcastEmitted => { + if let Some(x) = self.change_as_broadcast_emitted() { + ds.field("change", &x) + } else { + ds.field("change", &"InvalidFlatbuffer: Union discriminant does not match value.") + } + }, + ContractChangeType::BroadcastReceived => { + if let Some(x) = self.change_as_broadcast_received() { + ds.field("change", &x) + } else { + ds.field("change", &"InvalidFlatbuffer: Union discriminant does not match value.") + } + }, + ContractChangeType::UpdateRequest => { + if let Some(x) = self.change_as_update_request() { + ds.field("change", &x) + } else { + ds.field("change", &"InvalidFlatbuffer: Union discriminant does not match value.") + } + }, + ContractChangeType::UpdateSuccess => { + if let Some(x) = self.change_as_update_success() { + ds.field("change", &x) + } else { + ds.field("change", &"InvalidFlatbuffer: Union discriminant does not match value.") + } + }, + ContractChangeType::UpdateFailure => { + if let Some(x) = self.change_as_update_failure() { + ds.field("change", &x) + } else { + ds.field("change", &"InvalidFlatbuffer: Union discriminant does not match value.") + } + }, + ContractChangeType::GetContract => { + if let Some(x) = self.change_as_get_contract() { + ds.field("change", &x) + } else { + ds.field("change", &"InvalidFlatbuffer: Union discriminant does not match value.") + } + }, + ContractChangeType::SubscribedToContract => { + if let Some(x) = self.change_as_subscribed_to_contract() { + ds.field("change", &x) + } else { + ds.field("change", &"InvalidFlatbuffer: Union discriminant does not match value.") + } + }, + _ => { + let x: Option<()> = None; + ds.field("change", &x) + }, + }; + ds.finish() + } +} +} // pub mod topology +