diff --git a/src/api/account.rs b/src/api/account.rs index c5cb661..fc6cdba 100644 --- a/src/api/account.rs +++ b/src/api/account.rs @@ -3,6 +3,9 @@ // Account creation use crate::coinconfig::CoinConfig; +use crate::db::data_generated::fb::{ + AddressBalance, AddressBalanceArgs, AddressBalanceVec, AddressBalanceVecArgs, +}; use crate::db::AccountData; use crate::key2::decode_key; use crate::orchard::OrchardKeyBytes; @@ -21,7 +24,6 @@ use zcash_address::{ToAddress, ZcashAddress}; use zcash_client_backend::encoding::{decode_extended_full_viewing_key, encode_payment_address}; use zcash_client_backend::keys::UnifiedFullViewingKey; use zcash_primitives::consensus::Parameters; -use crate::db::data_generated::fb::{AddressBalance, AddressBalanceArgs, AddressBalanceVec, AddressBalanceVecArgs}; /// Create a new account /// # Arguments @@ -264,22 +266,29 @@ pub async fn get_taddr_balance(coin: u8, id_account: u32) -> anyhow::Result pub async fn scan_transparent_accounts(gap_limit: usize) -> anyhow::Result> { let c = CoinConfig::get_active(); let mut client = c.connect_lwd().await?; - let addresses = crate::taddr::scan_transparent_accounts(c.chain.network(), &mut client, gap_limit).await?; + let addresses = + crate::taddr::scan_transparent_accounts(c.chain.network(), &mut client, gap_limit).await?; let mut builder = flatbuffers::FlatBufferBuilder::new(); let mut addrs = vec![]; for a in addresses { let address = builder.create_string(&a.address); - let ab = AddressBalance::create(&mut builder, &AddressBalanceArgs { - index: a.index, - address: Some(address), - balance: a.balance, - }); + let ab = AddressBalance::create( + &mut builder, + &AddressBalanceArgs { + index: a.index, + address: Some(address), + balance: a.balance, + }, + ); addrs.push(ab); } let addrs = builder.create_vector(&addrs); - let addrs = AddressBalanceVec::create(&mut builder, &AddressBalanceVecArgs { - values: Some(addrs) - }); + let addrs = AddressBalanceVec::create( + &mut builder, + &AddressBalanceVecArgs { + values: Some(addrs), + }, + ); builder.finish(addrs, None); let data = builder.finished_data().to_vec(); Ok(data) diff --git a/src/api/contact.rs b/src/api/contact.rs index 8fa46ed..09907e3 100644 --- a/src/api/contact.rs +++ b/src/api/contact.rs @@ -6,8 +6,8 @@ use crate::api::sync::get_latest_height; use crate::coinconfig::CoinConfig; use crate::contact::{serialize_contacts, Contact}; use crate::db::AccountData; -use zcash_primitives::memo::Memo; use crate::TransactionPlan; +use zcash_primitives::memo::Memo; /// Store contact in the database /// # Arguments diff --git a/src/api/dart_ffi.rs b/src/api/dart_ffi.rs index c68f240..bcd24ff 100644 --- a/src/api/dart_ffi.rs +++ b/src/api/dart_ffi.rs @@ -1,4 +1,5 @@ use crate::coinconfig::{init_coin, CoinConfig, MEMPOOL, MEMPOOL_RUNNER}; +use crate::db::data_generated::fb::SendTemplate; use crate::db::FullEncryptedBackup; use crate::note_selection::TransactionReport; use crate::{ChainError, DbAdapter, TransactionPlan, Tx}; @@ -6,14 +7,13 @@ use allo_isolate::{ffi, IntoDart}; use android_logger::Config; use lazy_static::lazy_static; use log::Level; +use rusqlite::Connection; use std::ffi::{CStr, CString}; use std::os::raw::c_char; use std::path::Path; use std::sync::{Mutex, MutexGuard}; -use rusqlite::Connection; use tokio::sync::Semaphore; use zcash_primitives::transaction::builder::Progress; -use crate::db::data_generated::fb::SendTemplate; static mut POST_COBJ: Option = None; @@ -78,7 +78,7 @@ fn to_cresult_bytes(res: Result, anyhow::Error>) -> CResult<*const u8> { len: len as u32, error: std::ptr::null_mut::(), } - }, + } Err(e) => { log::error!("{}", e); CResult { @@ -484,7 +484,8 @@ pub async unsafe extern "C" fn shield_taddr( confirmations: u32, ) -> CResult<*mut c_char> { let res = async move { - let tx_plan = crate::api::payment_v2::shield_taddr(coin, account, amount, confirmations).await?; + let tx_plan = + crate::api::payment_v2::shield_taddr(coin, account, amount, confirmations).await?; let tx_plan_json = serde_json::to_string(&tx_plan)?; Ok(tx_plan_json) }; @@ -804,7 +805,11 @@ pub unsafe extern "C" fn derive_zip32( to_cresult_str(res()) } -fn with_account anyhow::Result>(coin: u8, id: u32, f: F) -> anyhow::Result { +fn with_account anyhow::Result>( + coin: u8, + id: u32, + f: F, +) -> anyhow::Result { let c = CoinConfig::get(coin); let db = c.db()?; let connection = &db.connection; @@ -858,7 +863,11 @@ pub unsafe extern "C" fn update_account_name(coin: u8, id: u32, name: *mut c_cha } #[no_mangle] -pub unsafe extern "C" fn get_balances(coin: u8, id: u32, confirmed_height: u32) -> CResult<*const u8> { +pub unsafe extern "C" fn get_balances( + coin: u8, + id: u32, + confirmed_height: u32, +) -> CResult<*const u8> { let res = |connection: &Connection| { let data = crate::db::read::get_balances(connection, id, confirmed_height)?; Ok(data) @@ -903,7 +912,12 @@ pub unsafe extern "C" fn get_messages(coin: u8, id: u32) -> CResult<*const u8> { } #[no_mangle] -pub unsafe extern "C" fn get_prev_next_message(coin: u8, id: u32, subject: *mut c_char, height: u32) -> CResult<*const u8> { +pub unsafe extern "C" fn get_prev_next_message( + coin: u8, + id: u32, + subject: *mut c_char, + height: u32, +) -> CResult<*const u8> { from_c_str!(subject); let res = |connection: &Connection| { let data = crate::db::read::get_prev_next_message(connection, &subject, height, id)?; @@ -964,7 +978,11 @@ pub unsafe extern "C" fn get_pnl_txs(coin: u8, id: u32, timestamp: u32) -> CResu } #[no_mangle] -pub unsafe extern "C" fn get_historical_prices(coin: u8, timestamp: u32, currency: *mut c_char) -> CResult<*const u8> { +pub unsafe extern "C" fn get_historical_prices( + coin: u8, + timestamp: u32, + currency: *mut c_char, +) -> CResult<*const u8> { from_c_str!(currency); let res = |connection: &Connection| { let data = crate::db::read::get_historical_prices(connection, timestamp, ¤cy)?; diff --git a/src/db.rs b/src/db.rs index 7447335..16cc9a0 100644 --- a/src/db.rs +++ b/src/db.rs @@ -11,10 +11,12 @@ use crate::unified::UnifiedAddressType; use crate::{sync, BlockId, CompactTxStreamerClient, Hash}; use orchard::keys::FullViewingKey; use rusqlite::Error::QueryReturnedNoRows; -use rusqlite::{params, Connection, OptionalExtension, Transaction}; +use rusqlite::{params, Connection, OptionalExtension, Transaction, OpenFlags}; use serde::Serialize; use std::collections::HashMap; use std::convert::TryInto; +use std::path::Path; +use anyhow::anyhow; use tonic::transport::Channel; use tonic::Request; use zcash_client_backend::encoding::decode_extended_full_viewing_key; @@ -25,12 +27,12 @@ use zcash_primitives::sapling::{Diversifier, Node, Note, SaplingIvk}; use zcash_primitives::zip32::{DiversifierIndex, ExtendedFullViewingKey}; mod backup; -mod migration; pub mod data_generated; +mod migration; pub mod read; -pub use backup::FullEncryptedBackup; use crate::db::data_generated::fb::SendTemplate; +pub use backup::FullEncryptedBackup; #[allow(dead_code)] pub const DEFAULT_DB_PATH: &str = "zec.db"; @@ -106,7 +108,9 @@ impl DbAdapter { } pub fn migrate_db(network: &Network, db_path: &str, has_ua: bool) -> anyhow::Result<()> { - let connection = Connection::open(db_path)?; + let dir = Path::new(db_path).parent().ok_or(anyhow!("Invalid db path"))?; + std::fs::create_dir_all(dir)?; + let connection = Connection::open_with_flags(db_path, OpenFlags::SQLITE_OPEN_READ_WRITE | OpenFlags::SQLITE_OPEN_CREATE)?; migration::init_db(&connection, network, has_ua)?; Ok(()) } @@ -709,17 +713,29 @@ impl DbAdapter { pub fn purge_old_witnesses(&mut self, height: u32) -> anyhow::Result<()> { log::debug!("+purge_old_witnesses"); - const BLOCKS_PER_HOUR: u32 = 60*60/75; - const BLOCKS_PER_DAY: u32 = 24*BLOCKS_PER_HOUR; - const BLOCKS_PER_MONTH: u32 = 30*BLOCKS_PER_DAY; - for i in 1..=24 { // 1 checkpoint per hour - self.prune_interval(height - i*BLOCKS_PER_HOUR, height - (i-1)*BLOCKS_PER_HOUR)?; + const BLOCKS_PER_HOUR: u32 = 60 * 60 / 75; + const BLOCKS_PER_DAY: u32 = 24 * BLOCKS_PER_HOUR; + const BLOCKS_PER_MONTH: u32 = 30 * BLOCKS_PER_DAY; + for i in 1..=24 { + // 1 checkpoint per hour + self.prune_interval( + height - i * BLOCKS_PER_HOUR, + height - (i - 1) * BLOCKS_PER_HOUR, + )?; } - for i in 2..=30 { // 1 checkpoint per day - self.prune_interval(height - i*BLOCKS_PER_DAY, height - (i-1)*BLOCKS_PER_DAY)?; + for i in 2..=30 { + // 1 checkpoint per day + self.prune_interval( + height - i * BLOCKS_PER_DAY, + height - (i - 1) * BLOCKS_PER_DAY, + )?; } - for i in 2..=12 { // 1 checkpoint per 30 days - self.prune_interval(height - i*BLOCKS_PER_MONTH, height - (i-1)*BLOCKS_PER_MONTH)?; + for i in 2..=12 { + // 1 checkpoint per 30 days + self.prune_interval( + height - i * BLOCKS_PER_MONTH, + height - (i - 1) * BLOCKS_PER_MONTH, + )?; } log::debug!("-purge_old_witnesses"); @@ -745,8 +761,10 @@ impl DbAdapter { "DELETE FROM orchard_witnesses WHERE height >= ?1 AND height < ?2 AND height != ?3", params![low, high, keep_height], )?; - transaction.execute("DELETE FROM blocks WHERE height >= ?1 AND height < ?2 AND height != ?3", - params![low, high, keep_height])?; + transaction.execute( + "DELETE FROM blocks WHERE height >= ?1 AND height < ?2 AND height != ?3", + params![low, high, keep_height], + )?; transaction.execute( "DELETE FROM sapling_tree WHERE height >= ?1 AND height < ?2 AND height != ?3", params![low, high, keep_height], @@ -1102,7 +1120,7 @@ impl DbAdapter { )?; Ok(()) } - + pub fn get_accounts(&self) -> anyhow::Result> { let mut s = self .connection @@ -1181,11 +1199,10 @@ impl DbAdapter { self.connection.execute("INSERT INTO \ send_templates(title, address, amount, fiat_amount, fee_included, fiat, include_reply_to, subject, body) \ VALUES (?1,?2,?3,?4,?5,?6,?7,?8,?9)", - params![t.title().unwrap(), t.address().unwrap(), t.amount(), t.fiat_amount(), t.fee_included(), t.fiat().unwrap(), + params![t.title().unwrap(), t.address().unwrap(), t.amount(), t.fiat_amount(), t.fee_included(), t.fiat(), t.include_reply_to(), t.subject().unwrap(), t.body().unwrap()])?; self.connection.last_insert_rowid() as u32 - } - else { + } else { self.connection.execute("UPDATE send_templates SET \ title=?1, address=?2, amount=?3, fiat_amount=?4, fee_included=?5, fiat=?6, include_reply_to=?7, subject=?8, body=?9 \ WHERE id_send_template=?10", @@ -1197,8 +1214,10 @@ impl DbAdapter { } pub fn delete_template(&self, id: u32) -> anyhow::Result<()> { - self.connection.execute("DELETE FROM send_templates WHERE id_send_template=?1", - params![id])?; + self.connection.execute( + "DELETE FROM send_templates WHERE id_send_template=?1", + params![id], + )?; Ok(()) } diff --git a/src/db/backup.rs b/src/db/backup.rs index 969454c..3d8af91 100644 --- a/src/db/backup.rs +++ b/src/db/backup.rs @@ -60,13 +60,15 @@ impl FullEncryptedBackup { let mut f = File::open(data_path)?; f.read_to_end(&mut cipher_text)?; - let decryptor = match age::Decryptor::new(&*cipher_text).map_err(|_| anyhow!("Decryption Error"))? { - age::Decryptor::Recipients(d) => d, - _ => unreachable!(), - }; + let decryptor = + match age::Decryptor::new(&*cipher_text).map_err(|_| anyhow!("Decryption Error"))? { + age::Decryptor::Recipients(d) => d, + _ => unreachable!(), + }; let mut plain_text = vec![]; - let mut reader = decryptor.decrypt(iter::once(&key as &dyn age::Identity)) + let mut reader = decryptor + .decrypt(iter::once(&key as &dyn age::Identity)) .map_err(|_| anyhow!("Decryption Error"))?; reader.read_to_end(&mut plain_text)?; diff --git a/src/db/data_generated.rs b/src/db/data_generated.rs index f3febaf..dbb2407 100644 --- a/src/db/data_generated.rs +++ b/src/db/data_generated.rs @@ -1,10 +1,9 @@ // automatically generated by the FlatBuffers compiler, do not modify - // @generated -use core::mem; use core::cmp::Ordering; +use core::mem; extern crate flatbuffers; use self::flatbuffers::{EndianScalar, Follow}; @@ -12,4152 +11,4513 @@ use self::flatbuffers::{EndianScalar, Follow}; #[allow(unused_imports, dead_code)] pub mod fb { - use core::mem; - use core::cmp::Ordering; - - extern crate flatbuffers; - use self::flatbuffers::{EndianScalar, Follow}; - -pub enum AccountOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct Account<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for Account<'a> { - type Inner = Account<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } - } -} - -impl<'a> Account<'a> { - pub const VT_ID: flatbuffers::VOffsetT = 4; - pub const VT_NAME: flatbuffers::VOffsetT = 6; - pub const VT_BALANCE: flatbuffers::VOffsetT = 8; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - Account { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args AccountArgs<'args> - ) -> flatbuffers::WIPOffset> { - let mut builder = AccountBuilder::new(_fbb); - builder.add_balance(args.balance); - if let Some(x) = args.name { builder.add_name(x); } - builder.add_id(args.id); - builder.finish() - } - - pub fn unpack(&self) -> AccountT { - let id = self.id(); - let name = self.name().map(|x| { - x.to_string() - }); - let balance = self.balance(); - AccountT { - id, - name, - balance, - } - } - - #[inline] - pub fn id(&self) -> u32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Account::VT_ID, Some(0)).unwrap()} - } - #[inline] - pub fn name(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>(Account::VT_NAME, None)} - } - #[inline] - pub fn balance(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Account::VT_BALANCE, Some(0)).unwrap()} - } -} - -impl flatbuffers::Verifiable for Account<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, pos: usize - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("id", Self::VT_ID, false)? - .visit_field::>("name", Self::VT_NAME, false)? - .visit_field::("balance", Self::VT_BALANCE, false)? - .finish(); - Ok(()) - } -} -pub struct AccountArgs<'a> { - pub id: u32, - pub name: Option>, - pub balance: u64, -} -impl<'a> Default for AccountArgs<'a> { - #[inline] - fn default() -> Self { - AccountArgs { - id: 0, - name: None, - balance: 0, - } - } -} - -pub struct AccountBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, -} -impl<'a: 'b, 'b> AccountBuilder<'a, 'b> { - #[inline] - pub fn add_id(&mut self, id: u32) { - self.fbb_.push_slot::(Account::VT_ID, id, 0); - } - #[inline] - pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>(Account::VT_NAME, name); - } - #[inline] - pub fn add_balance(&mut self, balance: u64) { - self.fbb_.push_slot::(Account::VT_BALANCE, balance, 0); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> AccountBuilder<'a, 'b> { - let start = _fbb.start_table(); - AccountBuilder { - 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 Account<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("Account"); - ds.field("id", &self.id()); - ds.field("name", &self.name()); - ds.field("balance", &self.balance()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct AccountT { - pub id: u32, - pub name: Option, - pub balance: u64, -} -impl Default for AccountT { - fn default() -> Self { - Self { - id: 0, - name: None, - balance: 0, - } - } -} -impl AccountT { - pub fn pack<'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b> - ) -> flatbuffers::WIPOffset> { - let id = self.id; - let name = self.name.as_ref().map(|x|{ - _fbb.create_string(x) - }); - let balance = self.balance; - Account::create(_fbb, &AccountArgs{ - id, - name, - balance, - }) - } -} -pub enum AccountVecOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct AccountVec<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for AccountVec<'a> { - type Inner = AccountVec<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } - } -} - -impl<'a> AccountVec<'a> { - pub const VT_ACCOUNTS: flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - AccountVec { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args AccountVecArgs<'args> - ) -> flatbuffers::WIPOffset> { - let mut builder = AccountVecBuilder::new(_fbb); - if let Some(x) = args.accounts { builder.add_accounts(x); } - builder.finish() - } - - pub fn unpack(&self) -> AccountVecT { - let accounts = self.accounts().map(|x| { - x.iter().map(|t| t.unpack()).collect() - }); - AccountVecT { - accounts, - } - } - - #[inline] - pub fn accounts(&self) -> Option>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>>>(AccountVec::VT_ACCOUNTS, None)} - } -} - -impl flatbuffers::Verifiable for AccountVec<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, pos: usize - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>>>("accounts", Self::VT_ACCOUNTS, false)? - .finish(); - Ok(()) - } -} -pub struct AccountVecArgs<'a> { - pub accounts: Option>>>>, -} -impl<'a> Default for AccountVecArgs<'a> { - #[inline] - fn default() -> Self { - AccountVecArgs { - accounts: None, - } - } -} - -pub struct AccountVecBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, -} -impl<'a: 'b, 'b> AccountVecBuilder<'a, 'b> { - #[inline] - pub fn add_accounts(&mut self, accounts: flatbuffers::WIPOffset>>>) { - self.fbb_.push_slot_always::>(AccountVec::VT_ACCOUNTS, accounts); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> AccountVecBuilder<'a, 'b> { - let start = _fbb.start_table(); - AccountVecBuilder { - 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 AccountVec<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("AccountVec"); - ds.field("accounts", &self.accounts()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct AccountVecT { - pub accounts: Option>, -} -impl Default for AccountVecT { - fn default() -> Self { - Self { - accounts: None, - } - } -} -impl AccountVecT { - pub fn pack<'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b> - ) -> flatbuffers::WIPOffset> { - let accounts = self.accounts.as_ref().map(|x|{ - let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) - }); - AccountVec::create(_fbb, &AccountVecArgs{ - accounts, - }) - } -} -pub enum BalanceOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct Balance<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for Balance<'a> { - type Inner = Balance<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } - } -} - -impl<'a> Balance<'a> { - pub const VT_SHIELDED: flatbuffers::VOffsetT = 4; - pub const VT_UNCONFIRMED_SPENT: flatbuffers::VOffsetT = 6; - pub const VT_BALANCE: flatbuffers::VOffsetT = 8; - pub const VT_UNDER_CONFIRMED: flatbuffers::VOffsetT = 10; - pub const VT_EXCLUDED: flatbuffers::VOffsetT = 12; - pub const VT_SAPLING: flatbuffers::VOffsetT = 14; - pub const VT_ORCHARD: flatbuffers::VOffsetT = 16; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - Balance { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args BalanceArgs - ) -> flatbuffers::WIPOffset> { - let mut builder = BalanceBuilder::new(_fbb); - builder.add_orchard(args.orchard); - builder.add_sapling(args.sapling); - builder.add_excluded(args.excluded); - builder.add_under_confirmed(args.under_confirmed); - builder.add_balance(args.balance); - builder.add_unconfirmed_spent(args.unconfirmed_spent); - builder.add_shielded(args.shielded); - builder.finish() - } - - pub fn unpack(&self) -> BalanceT { - let shielded = self.shielded(); - let unconfirmed_spent = self.unconfirmed_spent(); - let balance = self.balance(); - let under_confirmed = self.under_confirmed(); - let excluded = self.excluded(); - let sapling = self.sapling(); - let orchard = self.orchard(); - BalanceT { - shielded, - unconfirmed_spent, - balance, - under_confirmed, - excluded, - sapling, - orchard, - } - } - - #[inline] - pub fn shielded(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Balance::VT_SHIELDED, Some(0)).unwrap()} - } - #[inline] - pub fn unconfirmed_spent(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Balance::VT_UNCONFIRMED_SPENT, Some(0)).unwrap()} - } - #[inline] - pub fn balance(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Balance::VT_BALANCE, Some(0)).unwrap()} - } - #[inline] - pub fn under_confirmed(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Balance::VT_UNDER_CONFIRMED, Some(0)).unwrap()} - } - #[inline] - pub fn excluded(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Balance::VT_EXCLUDED, Some(0)).unwrap()} - } - #[inline] - pub fn sapling(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Balance::VT_SAPLING, Some(0)).unwrap()} - } - #[inline] - pub fn orchard(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Balance::VT_ORCHARD, Some(0)).unwrap()} - } -} - -impl flatbuffers::Verifiable for Balance<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, pos: usize - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("shielded", Self::VT_SHIELDED, false)? - .visit_field::("unconfirmed_spent", Self::VT_UNCONFIRMED_SPENT, false)? - .visit_field::("balance", Self::VT_BALANCE, false)? - .visit_field::("under_confirmed", Self::VT_UNDER_CONFIRMED, false)? - .visit_field::("excluded", Self::VT_EXCLUDED, false)? - .visit_field::("sapling", Self::VT_SAPLING, false)? - .visit_field::("orchard", Self::VT_ORCHARD, false)? - .finish(); - Ok(()) - } -} -pub struct BalanceArgs { - pub shielded: u64, - pub unconfirmed_spent: u64, - pub balance: u64, - pub under_confirmed: u64, - pub excluded: u64, - pub sapling: u64, - pub orchard: u64, -} -impl<'a> Default for BalanceArgs { - #[inline] - fn default() -> Self { - BalanceArgs { - shielded: 0, - unconfirmed_spent: 0, - balance: 0, - under_confirmed: 0, - excluded: 0, - sapling: 0, - orchard: 0, - } - } -} - -pub struct BalanceBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, -} -impl<'a: 'b, 'b> BalanceBuilder<'a, 'b> { - #[inline] - pub fn add_shielded(&mut self, shielded: u64) { - self.fbb_.push_slot::(Balance::VT_SHIELDED, shielded, 0); - } - #[inline] - pub fn add_unconfirmed_spent(&mut self, unconfirmed_spent: u64) { - self.fbb_.push_slot::(Balance::VT_UNCONFIRMED_SPENT, unconfirmed_spent, 0); - } - #[inline] - pub fn add_balance(&mut self, balance: u64) { - self.fbb_.push_slot::(Balance::VT_BALANCE, balance, 0); - } - #[inline] - pub fn add_under_confirmed(&mut self, under_confirmed: u64) { - self.fbb_.push_slot::(Balance::VT_UNDER_CONFIRMED, under_confirmed, 0); - } - #[inline] - pub fn add_excluded(&mut self, excluded: u64) { - self.fbb_.push_slot::(Balance::VT_EXCLUDED, excluded, 0); - } - #[inline] - pub fn add_sapling(&mut self, sapling: u64) { - self.fbb_.push_slot::(Balance::VT_SAPLING, sapling, 0); - } - #[inline] - pub fn add_orchard(&mut self, orchard: u64) { - self.fbb_.push_slot::(Balance::VT_ORCHARD, orchard, 0); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> BalanceBuilder<'a, 'b> { - let start = _fbb.start_table(); - BalanceBuilder { - 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 Balance<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("Balance"); - ds.field("shielded", &self.shielded()); - ds.field("unconfirmed_spent", &self.unconfirmed_spent()); - ds.field("balance", &self.balance()); - ds.field("under_confirmed", &self.under_confirmed()); - ds.field("excluded", &self.excluded()); - ds.field("sapling", &self.sapling()); - ds.field("orchard", &self.orchard()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct BalanceT { - pub shielded: u64, - pub unconfirmed_spent: u64, - pub balance: u64, - pub under_confirmed: u64, - pub excluded: u64, - pub sapling: u64, - pub orchard: u64, -} -impl Default for BalanceT { - fn default() -> Self { - Self { - shielded: 0, - unconfirmed_spent: 0, - balance: 0, - under_confirmed: 0, - excluded: 0, - sapling: 0, - orchard: 0, - } - } -} -impl BalanceT { - pub fn pack<'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b> - ) -> flatbuffers::WIPOffset> { - let shielded = self.shielded; - let unconfirmed_spent = self.unconfirmed_spent; - let balance = self.balance; - let under_confirmed = self.under_confirmed; - let excluded = self.excluded; - let sapling = self.sapling; - let orchard = self.orchard; - Balance::create(_fbb, &BalanceArgs{ - shielded, - unconfirmed_spent, - balance, - under_confirmed, - excluded, - sapling, - orchard, - }) - } -} -pub enum HeightOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct Height<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for Height<'a> { - type Inner = Height<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } - } -} - -impl<'a> Height<'a> { - pub const VT_HEIGHT: flatbuffers::VOffsetT = 4; - pub const VT_TIMESTAMP: flatbuffers::VOffsetT = 6; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - Height { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args HeightArgs - ) -> flatbuffers::WIPOffset> { - let mut builder = HeightBuilder::new(_fbb); - builder.add_timestamp(args.timestamp); - builder.add_height(args.height); - builder.finish() - } - - pub fn unpack(&self) -> HeightT { - let height = self.height(); - let timestamp = self.timestamp(); - HeightT { - height, - timestamp, - } - } - - #[inline] - pub fn height(&self) -> u32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Height::VT_HEIGHT, Some(0)).unwrap()} - } - #[inline] - pub fn timestamp(&self) -> u32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Height::VT_TIMESTAMP, Some(0)).unwrap()} - } -} - -impl flatbuffers::Verifiable for Height<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, pos: usize - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("height", Self::VT_HEIGHT, false)? - .visit_field::("timestamp", Self::VT_TIMESTAMP, false)? - .finish(); - Ok(()) - } -} -pub struct HeightArgs { - pub height: u32, - pub timestamp: u32, -} -impl<'a> Default for HeightArgs { - #[inline] - fn default() -> Self { - HeightArgs { - height: 0, - timestamp: 0, - } - } -} - -pub struct HeightBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, -} -impl<'a: 'b, 'b> HeightBuilder<'a, 'b> { - #[inline] - pub fn add_height(&mut self, height: u32) { - self.fbb_.push_slot::(Height::VT_HEIGHT, height, 0); - } - #[inline] - pub fn add_timestamp(&mut self, timestamp: u32) { - self.fbb_.push_slot::(Height::VT_TIMESTAMP, timestamp, 0); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> HeightBuilder<'a, 'b> { - let start = _fbb.start_table(); - HeightBuilder { - 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 Height<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("Height"); - ds.field("height", &self.height()); - ds.field("timestamp", &self.timestamp()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct HeightT { - pub height: u32, - pub timestamp: u32, -} -impl Default for HeightT { - fn default() -> Self { - Self { - height: 0, - timestamp: 0, - } - } -} -impl HeightT { - pub fn pack<'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b> - ) -> flatbuffers::WIPOffset> { - let height = self.height; - let timestamp = self.timestamp; - Height::create(_fbb, &HeightArgs{ - height, - timestamp, - }) - } -} -pub enum ShieldedNoteOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct ShieldedNote<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for ShieldedNote<'a> { - type Inner = ShieldedNote<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } - } -} - -impl<'a> ShieldedNote<'a> { - pub const VT_ID: flatbuffers::VOffsetT = 4; - pub const VT_HEIGHT: flatbuffers::VOffsetT = 6; - pub const VT_VALUE: flatbuffers::VOffsetT = 8; - pub const VT_TIMESTAMP: flatbuffers::VOffsetT = 10; - pub const VT_ORCHARD: flatbuffers::VOffsetT = 12; - pub const VT_EXCLUDED: flatbuffers::VOffsetT = 14; - pub const VT_SPENT: flatbuffers::VOffsetT = 16; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - ShieldedNote { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args ShieldedNoteArgs - ) -> flatbuffers::WIPOffset> { - let mut builder = ShieldedNoteBuilder::new(_fbb); - builder.add_value(args.value); - builder.add_timestamp(args.timestamp); - builder.add_height(args.height); - builder.add_id(args.id); - builder.add_spent(args.spent); - builder.add_excluded(args.excluded); - builder.add_orchard(args.orchard); - builder.finish() - } - - pub fn unpack(&self) -> ShieldedNoteT { - let id = self.id(); - let height = self.height(); - let value = self.value(); - let timestamp = self.timestamp(); - let orchard = self.orchard(); - let excluded = self.excluded(); - let spent = self.spent(); - ShieldedNoteT { - id, - height, - value, - timestamp, - orchard, - excluded, - spent, - } - } - - #[inline] - pub fn id(&self) -> u32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(ShieldedNote::VT_ID, Some(0)).unwrap()} - } - #[inline] - pub fn height(&self) -> u32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(ShieldedNote::VT_HEIGHT, Some(0)).unwrap()} - } - #[inline] - pub fn value(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(ShieldedNote::VT_VALUE, Some(0)).unwrap()} - } - #[inline] - pub fn timestamp(&self) -> u32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(ShieldedNote::VT_TIMESTAMP, Some(0)).unwrap()} - } - #[inline] - pub fn orchard(&self) -> bool { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(ShieldedNote::VT_ORCHARD, Some(false)).unwrap()} - } - #[inline] - pub fn excluded(&self) -> bool { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(ShieldedNote::VT_EXCLUDED, Some(false)).unwrap()} - } - #[inline] - pub fn spent(&self) -> bool { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(ShieldedNote::VT_SPENT, Some(false)).unwrap()} - } -} - -impl flatbuffers::Verifiable for ShieldedNote<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, pos: usize - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("id", Self::VT_ID, false)? - .visit_field::("height", Self::VT_HEIGHT, false)? - .visit_field::("value", Self::VT_VALUE, false)? - .visit_field::("timestamp", Self::VT_TIMESTAMP, false)? - .visit_field::("orchard", Self::VT_ORCHARD, false)? - .visit_field::("excluded", Self::VT_EXCLUDED, false)? - .visit_field::("spent", Self::VT_SPENT, false)? - .finish(); - Ok(()) - } -} -pub struct ShieldedNoteArgs { - pub id: u32, - pub height: u32, - pub value: u64, - pub timestamp: u32, - pub orchard: bool, - pub excluded: bool, - pub spent: bool, -} -impl<'a> Default for ShieldedNoteArgs { - #[inline] - fn default() -> Self { - ShieldedNoteArgs { - id: 0, - height: 0, - value: 0, - timestamp: 0, - orchard: false, - excluded: false, - spent: false, - } - } -} - -pub struct ShieldedNoteBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, -} -impl<'a: 'b, 'b> ShieldedNoteBuilder<'a, 'b> { - #[inline] - pub fn add_id(&mut self, id: u32) { - self.fbb_.push_slot::(ShieldedNote::VT_ID, id, 0); - } - #[inline] - pub fn add_height(&mut self, height: u32) { - self.fbb_.push_slot::(ShieldedNote::VT_HEIGHT, height, 0); - } - #[inline] - pub fn add_value(&mut self, value: u64) { - self.fbb_.push_slot::(ShieldedNote::VT_VALUE, value, 0); - } - #[inline] - pub fn add_timestamp(&mut self, timestamp: u32) { - self.fbb_.push_slot::(ShieldedNote::VT_TIMESTAMP, timestamp, 0); - } - #[inline] - pub fn add_orchard(&mut self, orchard: bool) { - self.fbb_.push_slot::(ShieldedNote::VT_ORCHARD, orchard, false); - } - #[inline] - pub fn add_excluded(&mut self, excluded: bool) { - self.fbb_.push_slot::(ShieldedNote::VT_EXCLUDED, excluded, false); - } - #[inline] - pub fn add_spent(&mut self, spent: bool) { - self.fbb_.push_slot::(ShieldedNote::VT_SPENT, spent, false); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> ShieldedNoteBuilder<'a, 'b> { - let start = _fbb.start_table(); - ShieldedNoteBuilder { - 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 ShieldedNote<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("ShieldedNote"); - ds.field("id", &self.id()); - ds.field("height", &self.height()); - ds.field("value", &self.value()); - ds.field("timestamp", &self.timestamp()); - ds.field("orchard", &self.orchard()); - ds.field("excluded", &self.excluded()); - ds.field("spent", &self.spent()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct ShieldedNoteT { - pub id: u32, - pub height: u32, - pub value: u64, - pub timestamp: u32, - pub orchard: bool, - pub excluded: bool, - pub spent: bool, -} -impl Default for ShieldedNoteT { - fn default() -> Self { - Self { - id: 0, - height: 0, - value: 0, - timestamp: 0, - orchard: false, - excluded: false, - spent: false, - } - } -} -impl ShieldedNoteT { - pub fn pack<'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b> - ) -> flatbuffers::WIPOffset> { - let id = self.id; - let height = self.height; - let value = self.value; - let timestamp = self.timestamp; - let orchard = self.orchard; - let excluded = self.excluded; - let spent = self.spent; - ShieldedNote::create(_fbb, &ShieldedNoteArgs{ - id, - height, - value, - timestamp, - orchard, - excluded, - spent, - }) - } -} -pub enum ShieldedNoteVecOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct ShieldedNoteVec<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for ShieldedNoteVec<'a> { - type Inner = ShieldedNoteVec<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } - } -} - -impl<'a> ShieldedNoteVec<'a> { - pub const VT_NOTES: flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - ShieldedNoteVec { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args ShieldedNoteVecArgs<'args> - ) -> flatbuffers::WIPOffset> { - let mut builder = ShieldedNoteVecBuilder::new(_fbb); - if let Some(x) = args.notes { builder.add_notes(x); } - builder.finish() - } - - pub fn unpack(&self) -> ShieldedNoteVecT { - let notes = self.notes().map(|x| { - x.iter().map(|t| t.unpack()).collect() - }); - ShieldedNoteVecT { - notes, - } - } - - #[inline] - pub fn notes(&self) -> Option>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>>>(ShieldedNoteVec::VT_NOTES, None)} - } -} - -impl flatbuffers::Verifiable for ShieldedNoteVec<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, pos: usize - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>>>("notes", Self::VT_NOTES, false)? - .finish(); - Ok(()) - } -} -pub struct ShieldedNoteVecArgs<'a> { - pub notes: Option>>>>, -} -impl<'a> Default for ShieldedNoteVecArgs<'a> { - #[inline] - fn default() -> Self { - ShieldedNoteVecArgs { - notes: None, - } - } -} - -pub struct ShieldedNoteVecBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, -} -impl<'a: 'b, 'b> ShieldedNoteVecBuilder<'a, 'b> { - #[inline] - pub fn add_notes(&mut self, notes: flatbuffers::WIPOffset>>>) { - self.fbb_.push_slot_always::>(ShieldedNoteVec::VT_NOTES, notes); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> ShieldedNoteVecBuilder<'a, 'b> { - let start = _fbb.start_table(); - ShieldedNoteVecBuilder { - 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 ShieldedNoteVec<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("ShieldedNoteVec"); - ds.field("notes", &self.notes()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct ShieldedNoteVecT { - pub notes: Option>, -} -impl Default for ShieldedNoteVecT { - fn default() -> Self { - Self { - notes: None, - } - } -} -impl ShieldedNoteVecT { - pub fn pack<'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b> - ) -> flatbuffers::WIPOffset> { - let notes = self.notes.as_ref().map(|x|{ - let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) - }); - ShieldedNoteVec::create(_fbb, &ShieldedNoteVecArgs{ - notes, - }) - } -} -pub enum ShieldedTxOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct ShieldedTx<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for ShieldedTx<'a> { - type Inner = ShieldedTx<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } - } -} - -impl<'a> ShieldedTx<'a> { - pub const VT_ID: flatbuffers::VOffsetT = 4; - pub const VT_TX_ID: flatbuffers::VOffsetT = 6; - pub const VT_HEIGHT: flatbuffers::VOffsetT = 8; - pub const VT_SHORT_TX_ID: flatbuffers::VOffsetT = 10; - pub const VT_TIMESTAMP: flatbuffers::VOffsetT = 12; - pub const VT_NAME: flatbuffers::VOffsetT = 14; - pub const VT_VALUE: flatbuffers::VOffsetT = 16; - pub const VT_ADDRESS: flatbuffers::VOffsetT = 18; - pub const VT_MEMO: flatbuffers::VOffsetT = 20; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - ShieldedTx { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args ShieldedTxArgs<'args> - ) -> flatbuffers::WIPOffset> { - let mut builder = ShieldedTxBuilder::new(_fbb); - builder.add_value(args.value); - if let Some(x) = args.memo { builder.add_memo(x); } - if let Some(x) = args.address { builder.add_address(x); } - if let Some(x) = args.name { builder.add_name(x); } - builder.add_timestamp(args.timestamp); - if let Some(x) = args.short_tx_id { builder.add_short_tx_id(x); } - builder.add_height(args.height); - if let Some(x) = args.tx_id { builder.add_tx_id(x); } - builder.add_id(args.id); - builder.finish() - } - - pub fn unpack(&self) -> ShieldedTxT { - let id = self.id(); - let tx_id = self.tx_id().map(|x| { - x.to_string() - }); - let height = self.height(); - let short_tx_id = self.short_tx_id().map(|x| { - x.to_string() - }); - let timestamp = self.timestamp(); - let name = self.name().map(|x| { - x.to_string() - }); - let value = self.value(); - let address = self.address().map(|x| { - x.to_string() - }); - let memo = self.memo().map(|x| { - x.to_string() - }); - ShieldedTxT { - id, - tx_id, - height, - short_tx_id, - timestamp, - name, - value, - address, - memo, - } - } - - #[inline] - pub fn id(&self) -> u32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(ShieldedTx::VT_ID, Some(0)).unwrap()} - } - #[inline] - pub fn tx_id(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>(ShieldedTx::VT_TX_ID, None)} - } - #[inline] - pub fn height(&self) -> u32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(ShieldedTx::VT_HEIGHT, Some(0)).unwrap()} - } - #[inline] - pub fn short_tx_id(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>(ShieldedTx::VT_SHORT_TX_ID, None)} - } - #[inline] - pub fn timestamp(&self) -> u32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(ShieldedTx::VT_TIMESTAMP, Some(0)).unwrap()} - } - #[inline] - pub fn name(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>(ShieldedTx::VT_NAME, None)} - } - #[inline] - pub fn value(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(ShieldedTx::VT_VALUE, Some(0)).unwrap()} - } - #[inline] - pub fn address(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>(ShieldedTx::VT_ADDRESS, None)} - } - #[inline] - pub fn memo(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>(ShieldedTx::VT_MEMO, None)} - } -} - -impl flatbuffers::Verifiable for ShieldedTx<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, pos: usize - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("id", Self::VT_ID, false)? - .visit_field::>("tx_id", Self::VT_TX_ID, false)? - .visit_field::("height", Self::VT_HEIGHT, false)? - .visit_field::>("short_tx_id", Self::VT_SHORT_TX_ID, false)? - .visit_field::("timestamp", Self::VT_TIMESTAMP, false)? - .visit_field::>("name", Self::VT_NAME, false)? - .visit_field::("value", Self::VT_VALUE, false)? - .visit_field::>("address", Self::VT_ADDRESS, false)? - .visit_field::>("memo", Self::VT_MEMO, false)? - .finish(); - Ok(()) - } -} -pub struct ShieldedTxArgs<'a> { - pub id: u32, - pub tx_id: Option>, - pub height: u32, - pub short_tx_id: Option>, - pub timestamp: u32, - pub name: Option>, - pub value: u64, - pub address: Option>, - pub memo: Option>, -} -impl<'a> Default for ShieldedTxArgs<'a> { - #[inline] - fn default() -> Self { - ShieldedTxArgs { - id: 0, - tx_id: None, - height: 0, - short_tx_id: None, - timestamp: 0, - name: None, - value: 0, - address: None, - memo: None, - } - } -} - -pub struct ShieldedTxBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, -} -impl<'a: 'b, 'b> ShieldedTxBuilder<'a, 'b> { - #[inline] - pub fn add_id(&mut self, id: u32) { - self.fbb_.push_slot::(ShieldedTx::VT_ID, id, 0); - } - #[inline] - pub fn add_tx_id(&mut self, tx_id: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>(ShieldedTx::VT_TX_ID, tx_id); - } - #[inline] - pub fn add_height(&mut self, height: u32) { - self.fbb_.push_slot::(ShieldedTx::VT_HEIGHT, height, 0); - } - #[inline] - pub fn add_short_tx_id(&mut self, short_tx_id: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>(ShieldedTx::VT_SHORT_TX_ID, short_tx_id); - } - #[inline] - pub fn add_timestamp(&mut self, timestamp: u32) { - self.fbb_.push_slot::(ShieldedTx::VT_TIMESTAMP, timestamp, 0); - } - #[inline] - pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>(ShieldedTx::VT_NAME, name); - } - #[inline] - pub fn add_value(&mut self, value: u64) { - self.fbb_.push_slot::(ShieldedTx::VT_VALUE, value, 0); - } - #[inline] - pub fn add_address(&mut self, address: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>(ShieldedTx::VT_ADDRESS, address); - } - #[inline] - pub fn add_memo(&mut self, memo: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>(ShieldedTx::VT_MEMO, memo); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> ShieldedTxBuilder<'a, 'b> { - let start = _fbb.start_table(); - ShieldedTxBuilder { - 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 ShieldedTx<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("ShieldedTx"); - ds.field("id", &self.id()); - ds.field("tx_id", &self.tx_id()); - ds.field("height", &self.height()); - ds.field("short_tx_id", &self.short_tx_id()); - ds.field("timestamp", &self.timestamp()); - ds.field("name", &self.name()); - ds.field("value", &self.value()); - ds.field("address", &self.address()); - ds.field("memo", &self.memo()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct ShieldedTxT { - pub id: u32, - pub tx_id: Option, - pub height: u32, - pub short_tx_id: Option, - pub timestamp: u32, - pub name: Option, - pub value: u64, - pub address: Option, - pub memo: Option, -} -impl Default for ShieldedTxT { - fn default() -> Self { - Self { - id: 0, - tx_id: None, - height: 0, - short_tx_id: None, - timestamp: 0, - name: None, - value: 0, - address: None, - memo: None, - } - } -} -impl ShieldedTxT { - pub fn pack<'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b> - ) -> flatbuffers::WIPOffset> { - let id = self.id; - let tx_id = self.tx_id.as_ref().map(|x|{ - _fbb.create_string(x) - }); - let height = self.height; - let short_tx_id = self.short_tx_id.as_ref().map(|x|{ - _fbb.create_string(x) - }); - let timestamp = self.timestamp; - let name = self.name.as_ref().map(|x|{ - _fbb.create_string(x) - }); - let value = self.value; - let address = self.address.as_ref().map(|x|{ - _fbb.create_string(x) - }); - let memo = self.memo.as_ref().map(|x|{ - _fbb.create_string(x) - }); - ShieldedTx::create(_fbb, &ShieldedTxArgs{ - id, - tx_id, - height, - short_tx_id, - timestamp, - name, - value, - address, - memo, - }) - } -} -pub enum ShieldedTxVecOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct ShieldedTxVec<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for ShieldedTxVec<'a> { - type Inner = ShieldedTxVec<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } - } -} - -impl<'a> ShieldedTxVec<'a> { - pub const VT_TXS: flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - ShieldedTxVec { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args ShieldedTxVecArgs<'args> - ) -> flatbuffers::WIPOffset> { - let mut builder = ShieldedTxVecBuilder::new(_fbb); - if let Some(x) = args.txs { builder.add_txs(x); } - builder.finish() - } - - pub fn unpack(&self) -> ShieldedTxVecT { - let txs = self.txs().map(|x| { - x.iter().map(|t| t.unpack()).collect() - }); - ShieldedTxVecT { - txs, - } - } - - #[inline] - pub fn txs(&self) -> Option>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>>>(ShieldedTxVec::VT_TXS, None)} - } -} - -impl flatbuffers::Verifiable for ShieldedTxVec<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, pos: usize - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>>>("txs", Self::VT_TXS, false)? - .finish(); - Ok(()) - } -} -pub struct ShieldedTxVecArgs<'a> { - pub txs: Option>>>>, -} -impl<'a> Default for ShieldedTxVecArgs<'a> { - #[inline] - fn default() -> Self { - ShieldedTxVecArgs { - txs: None, - } - } -} - -pub struct ShieldedTxVecBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, -} -impl<'a: 'b, 'b> ShieldedTxVecBuilder<'a, 'b> { - #[inline] - pub fn add_txs(&mut self, txs: flatbuffers::WIPOffset>>>) { - self.fbb_.push_slot_always::>(ShieldedTxVec::VT_TXS, txs); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> ShieldedTxVecBuilder<'a, 'b> { - let start = _fbb.start_table(); - ShieldedTxVecBuilder { - 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 ShieldedTxVec<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("ShieldedTxVec"); - ds.field("txs", &self.txs()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct ShieldedTxVecT { - pub txs: Option>, -} -impl Default for ShieldedTxVecT { - fn default() -> Self { - Self { - txs: None, - } - } -} -impl ShieldedTxVecT { - pub fn pack<'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b> - ) -> flatbuffers::WIPOffset> { - let txs = self.txs.as_ref().map(|x|{ - let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) - }); - ShieldedTxVec::create(_fbb, &ShieldedTxVecArgs{ - txs, - }) - } -} -pub enum MessageOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct Message<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for Message<'a> { - type Inner = Message<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } - } -} - -impl<'a> Message<'a> { - pub const VT_ID_MSG: flatbuffers::VOffsetT = 4; - pub const VT_ID_TX: flatbuffers::VOffsetT = 6; - pub const VT_HEIGHT: flatbuffers::VOffsetT = 8; - pub const VT_TIMESTAMP: flatbuffers::VOffsetT = 10; - pub const VT_FROM: flatbuffers::VOffsetT = 12; - pub const VT_TO: flatbuffers::VOffsetT = 14; - pub const VT_SUBJECT: flatbuffers::VOffsetT = 16; - pub const VT_BODY: flatbuffers::VOffsetT = 18; - pub const VT_READ: flatbuffers::VOffsetT = 20; - pub const VT_INCOMING: flatbuffers::VOffsetT = 22; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - Message { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args MessageArgs<'args> - ) -> flatbuffers::WIPOffset> { - let mut builder = MessageBuilder::new(_fbb); - if let Some(x) = args.body { builder.add_body(x); } - if let Some(x) = args.subject { builder.add_subject(x); } - if let Some(x) = args.to { builder.add_to(x); } - if let Some(x) = args.from { builder.add_from(x); } - builder.add_timestamp(args.timestamp); - builder.add_height(args.height); - builder.add_id_tx(args.id_tx); - builder.add_id_msg(args.id_msg); - builder.add_incoming(args.incoming); - builder.add_read(args.read); - builder.finish() - } - - pub fn unpack(&self) -> MessageT { - let id_msg = self.id_msg(); - let id_tx = self.id_tx(); - let height = self.height(); - let timestamp = self.timestamp(); - let from = self.from().map(|x| { - x.to_string() - }); - let to = self.to().map(|x| { - x.to_string() - }); - let subject = self.subject().map(|x| { - x.to_string() - }); - let body = self.body().map(|x| { - x.to_string() - }); - let read = self.read(); - let incoming = self.incoming(); - MessageT { - id_msg, - id_tx, - height, - timestamp, - from, - to, - subject, - body, - read, - incoming, - } - } - - #[inline] - pub fn id_msg(&self) -> u32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Message::VT_ID_MSG, Some(0)).unwrap()} - } - #[inline] - pub fn id_tx(&self) -> u32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Message::VT_ID_TX, Some(0)).unwrap()} - } - #[inline] - pub fn height(&self) -> u32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Message::VT_HEIGHT, Some(0)).unwrap()} - } - #[inline] - pub fn timestamp(&self) -> u32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Message::VT_TIMESTAMP, Some(0)).unwrap()} - } - #[inline] - pub fn from(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>(Message::VT_FROM, None)} - } - #[inline] - pub fn to(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>(Message::VT_TO, None)} - } - #[inline] - pub fn subject(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>(Message::VT_SUBJECT, None)} - } - #[inline] - pub fn body(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>(Message::VT_BODY, None)} - } - #[inline] - pub fn read(&self) -> bool { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Message::VT_READ, Some(false)).unwrap()} - } - #[inline] - pub fn incoming(&self) -> bool { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Message::VT_INCOMING, Some(false)).unwrap()} - } -} - -impl flatbuffers::Verifiable for Message<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, pos: usize - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("id_msg", Self::VT_ID_MSG, false)? - .visit_field::("id_tx", Self::VT_ID_TX, false)? - .visit_field::("height", Self::VT_HEIGHT, false)? - .visit_field::("timestamp", Self::VT_TIMESTAMP, false)? - .visit_field::>("from", Self::VT_FROM, false)? - .visit_field::>("to", Self::VT_TO, false)? - .visit_field::>("subject", Self::VT_SUBJECT, false)? - .visit_field::>("body", Self::VT_BODY, false)? - .visit_field::("read", Self::VT_READ, false)? - .visit_field::("incoming", Self::VT_INCOMING, false)? - .finish(); - Ok(()) - } -} -pub struct MessageArgs<'a> { - pub id_msg: u32, - pub id_tx: u32, - pub height: u32, - pub timestamp: u32, - pub from: Option>, - pub to: Option>, - pub subject: Option>, - pub body: Option>, - pub read: bool, - pub incoming: bool, -} -impl<'a> Default for MessageArgs<'a> { - #[inline] - fn default() -> Self { - MessageArgs { - id_msg: 0, - id_tx: 0, - height: 0, - timestamp: 0, - from: None, - to: None, - subject: None, - body: None, - read: false, - incoming: false, - } - } -} - -pub struct MessageBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, -} -impl<'a: 'b, 'b> MessageBuilder<'a, 'b> { - #[inline] - pub fn add_id_msg(&mut self, id_msg: u32) { - self.fbb_.push_slot::(Message::VT_ID_MSG, id_msg, 0); - } - #[inline] - pub fn add_id_tx(&mut self, id_tx: u32) { - self.fbb_.push_slot::(Message::VT_ID_TX, id_tx, 0); - } - #[inline] - pub fn add_height(&mut self, height: u32) { - self.fbb_.push_slot::(Message::VT_HEIGHT, height, 0); - } - #[inline] - pub fn add_timestamp(&mut self, timestamp: u32) { - self.fbb_.push_slot::(Message::VT_TIMESTAMP, timestamp, 0); - } - #[inline] - pub fn add_from(&mut self, from: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>(Message::VT_FROM, from); - } - #[inline] - pub fn add_to(&mut self, to: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>(Message::VT_TO, to); - } - #[inline] - pub fn add_subject(&mut self, subject: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>(Message::VT_SUBJECT, subject); - } - #[inline] - pub fn add_body(&mut self, body: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>(Message::VT_BODY, body); - } - #[inline] - pub fn add_read(&mut self, read: bool) { - self.fbb_.push_slot::(Message::VT_READ, read, false); - } - #[inline] - pub fn add_incoming(&mut self, incoming: bool) { - self.fbb_.push_slot::(Message::VT_INCOMING, incoming, false); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> MessageBuilder<'a, 'b> { - let start = _fbb.start_table(); - MessageBuilder { - 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 Message<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("Message"); - ds.field("id_msg", &self.id_msg()); - ds.field("id_tx", &self.id_tx()); - ds.field("height", &self.height()); - ds.field("timestamp", &self.timestamp()); - ds.field("from", &self.from()); - ds.field("to", &self.to()); - ds.field("subject", &self.subject()); - ds.field("body", &self.body()); - ds.field("read", &self.read()); - ds.field("incoming", &self.incoming()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct MessageT { - pub id_msg: u32, - pub id_tx: u32, - pub height: u32, - pub timestamp: u32, - pub from: Option, - pub to: Option, - pub subject: Option, - pub body: Option, - pub read: bool, - pub incoming: bool, -} -impl Default for MessageT { - fn default() -> Self { - Self { - id_msg: 0, - id_tx: 0, - height: 0, - timestamp: 0, - from: None, - to: None, - subject: None, - body: None, - read: false, - incoming: false, - } - } -} -impl MessageT { - pub fn pack<'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b> - ) -> flatbuffers::WIPOffset> { - let id_msg = self.id_msg; - let id_tx = self.id_tx; - let height = self.height; - let timestamp = self.timestamp; - let from = self.from.as_ref().map(|x|{ - _fbb.create_string(x) - }); - let to = self.to.as_ref().map(|x|{ - _fbb.create_string(x) - }); - let subject = self.subject.as_ref().map(|x|{ - _fbb.create_string(x) - }); - let body = self.body.as_ref().map(|x|{ - _fbb.create_string(x) - }); - let read = self.read; - let incoming = self.incoming; - Message::create(_fbb, &MessageArgs{ - id_msg, - id_tx, - height, - timestamp, - from, - to, - subject, - body, - read, - incoming, - }) - } -} -pub enum MessageVecOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct MessageVec<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for MessageVec<'a> { - type Inner = MessageVec<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } - } -} - -impl<'a> MessageVec<'a> { - pub const VT_MESSAGES: flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - MessageVec { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args MessageVecArgs<'args> - ) -> flatbuffers::WIPOffset> { - let mut builder = MessageVecBuilder::new(_fbb); - if let Some(x) = args.messages { builder.add_messages(x); } - builder.finish() - } - - pub fn unpack(&self) -> MessageVecT { - let messages = self.messages().map(|x| { - x.iter().map(|t| t.unpack()).collect() - }); - MessageVecT { - messages, - } - } - - #[inline] - pub fn messages(&self) -> Option>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>>>(MessageVec::VT_MESSAGES, None)} - } -} - -impl flatbuffers::Verifiable for MessageVec<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, pos: usize - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>>>("messages", Self::VT_MESSAGES, false)? - .finish(); - Ok(()) - } -} -pub struct MessageVecArgs<'a> { - pub messages: Option>>>>, -} -impl<'a> Default for MessageVecArgs<'a> { - #[inline] - fn default() -> Self { - MessageVecArgs { - messages: None, - } - } -} - -pub struct MessageVecBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, -} -impl<'a: 'b, 'b> MessageVecBuilder<'a, 'b> { - #[inline] - pub fn add_messages(&mut self, messages: flatbuffers::WIPOffset>>>) { - self.fbb_.push_slot_always::>(MessageVec::VT_MESSAGES, messages); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> MessageVecBuilder<'a, 'b> { - let start = _fbb.start_table(); - MessageVecBuilder { - 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 MessageVec<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("MessageVec"); - ds.field("messages", &self.messages()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct MessageVecT { - pub messages: Option>, -} -impl Default for MessageVecT { - fn default() -> Self { - Self { - messages: None, - } - } -} -impl MessageVecT { - pub fn pack<'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b> - ) -> flatbuffers::WIPOffset> { - let messages = self.messages.as_ref().map(|x|{ - let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) - }); - MessageVec::create(_fbb, &MessageVecArgs{ - messages, - }) - } -} -pub enum PrevNextOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct PrevNext<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for PrevNext<'a> { - type Inner = PrevNext<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } - } -} - -impl<'a> PrevNext<'a> { - pub const VT_PREV: flatbuffers::VOffsetT = 4; - pub const VT_NEXT: flatbuffers::VOffsetT = 6; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - PrevNext { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args PrevNextArgs - ) -> flatbuffers::WIPOffset> { - let mut builder = PrevNextBuilder::new(_fbb); - builder.add_next(args.next); - builder.add_prev(args.prev); - builder.finish() - } - - pub fn unpack(&self) -> PrevNextT { - let prev = self.prev(); - let next = self.next(); - PrevNextT { - prev, - next, - } - } - - #[inline] - pub fn prev(&self) -> u32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(PrevNext::VT_PREV, Some(0)).unwrap()} - } - #[inline] - pub fn next(&self) -> u32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(PrevNext::VT_NEXT, Some(0)).unwrap()} - } -} - -impl flatbuffers::Verifiable for PrevNext<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, pos: usize - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("prev", Self::VT_PREV, false)? - .visit_field::("next", Self::VT_NEXT, false)? - .finish(); - Ok(()) - } -} -pub struct PrevNextArgs { - pub prev: u32, - pub next: u32, -} -impl<'a> Default for PrevNextArgs { - #[inline] - fn default() -> Self { - PrevNextArgs { - prev: 0, - next: 0, - } - } -} - -pub struct PrevNextBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, -} -impl<'a: 'b, 'b> PrevNextBuilder<'a, 'b> { - #[inline] - pub fn add_prev(&mut self, prev: u32) { - self.fbb_.push_slot::(PrevNext::VT_PREV, prev, 0); - } - #[inline] - pub fn add_next(&mut self, next: u32) { - self.fbb_.push_slot::(PrevNext::VT_NEXT, next, 0); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> PrevNextBuilder<'a, 'b> { - let start = _fbb.start_table(); - PrevNextBuilder { - 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 PrevNext<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("PrevNext"); - ds.field("prev", &self.prev()); - ds.field("next", &self.next()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct PrevNextT { - pub prev: u32, - pub next: u32, -} -impl Default for PrevNextT { - fn default() -> Self { - Self { - prev: 0, - next: 0, - } - } -} -impl PrevNextT { - pub fn pack<'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b> - ) -> flatbuffers::WIPOffset> { - let prev = self.prev; - let next = self.next; - PrevNext::create(_fbb, &PrevNextArgs{ - prev, - next, - }) - } -} -pub enum SendTemplateOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct SendTemplate<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for SendTemplate<'a> { - type Inner = SendTemplate<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } - } -} - -impl<'a> SendTemplate<'a> { - pub const VT_ID: flatbuffers::VOffsetT = 4; - pub const VT_TITLE: flatbuffers::VOffsetT = 6; - pub const VT_ADDRESS: flatbuffers::VOffsetT = 8; - pub const VT_AMOUNT: flatbuffers::VOffsetT = 10; - pub const VT_FIAT_AMOUNT: flatbuffers::VOffsetT = 12; - pub const VT_FEE_INCLUDED: flatbuffers::VOffsetT = 14; - pub const VT_FIAT: flatbuffers::VOffsetT = 16; - pub const VT_INCLUDE_REPLY_TO: flatbuffers::VOffsetT = 18; - pub const VT_SUBJECT: flatbuffers::VOffsetT = 20; - pub const VT_BODY: flatbuffers::VOffsetT = 22; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - SendTemplate { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args SendTemplateArgs<'args> - ) -> flatbuffers::WIPOffset> { - let mut builder = SendTemplateBuilder::new(_fbb); - builder.add_fiat_amount(args.fiat_amount); - builder.add_amount(args.amount); - if let Some(x) = args.body { builder.add_body(x); } - if let Some(x) = args.subject { builder.add_subject(x); } - if let Some(x) = args.fiat { builder.add_fiat(x); } - if let Some(x) = args.address { builder.add_address(x); } - if let Some(x) = args.title { builder.add_title(x); } - builder.add_id(args.id); - builder.add_include_reply_to(args.include_reply_to); - builder.add_fee_included(args.fee_included); - builder.finish() - } - - pub fn unpack(&self) -> SendTemplateT { - let id = self.id(); - let title = self.title().map(|x| { - x.to_string() - }); - let address = self.address().map(|x| { - x.to_string() - }); - let amount = self.amount(); - let fiat_amount = self.fiat_amount(); - let fee_included = self.fee_included(); - let fiat = self.fiat().map(|x| { - x.to_string() - }); - let include_reply_to = self.include_reply_to(); - let subject = self.subject().map(|x| { - x.to_string() - }); - let body = self.body().map(|x| { - x.to_string() - }); - SendTemplateT { - id, - title, - address, - amount, - fiat_amount, - fee_included, - fiat, - include_reply_to, - subject, - body, - } - } - - #[inline] - pub fn id(&self) -> u32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(SendTemplate::VT_ID, Some(0)).unwrap()} - } - #[inline] - pub fn title(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>(SendTemplate::VT_TITLE, None)} - } - #[inline] - pub fn address(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>(SendTemplate::VT_ADDRESS, None)} - } - #[inline] - pub fn amount(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(SendTemplate::VT_AMOUNT, Some(0)).unwrap()} - } - #[inline] - pub fn fiat_amount(&self) -> f64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(SendTemplate::VT_FIAT_AMOUNT, Some(0.0)).unwrap()} - } - #[inline] - pub fn fee_included(&self) -> bool { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(SendTemplate::VT_FEE_INCLUDED, Some(false)).unwrap()} - } - #[inline] - pub fn fiat(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>(SendTemplate::VT_FIAT, None)} - } - #[inline] - pub fn include_reply_to(&self) -> bool { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(SendTemplate::VT_INCLUDE_REPLY_TO, Some(false)).unwrap()} - } - #[inline] - pub fn subject(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>(SendTemplate::VT_SUBJECT, None)} - } - #[inline] - pub fn body(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>(SendTemplate::VT_BODY, None)} - } -} - -impl flatbuffers::Verifiable for SendTemplate<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, pos: usize - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("id", Self::VT_ID, false)? - .visit_field::>("title", Self::VT_TITLE, false)? - .visit_field::>("address", Self::VT_ADDRESS, false)? - .visit_field::("amount", Self::VT_AMOUNT, false)? - .visit_field::("fiat_amount", Self::VT_FIAT_AMOUNT, false)? - .visit_field::("fee_included", Self::VT_FEE_INCLUDED, false)? - .visit_field::>("fiat", Self::VT_FIAT, false)? - .visit_field::("include_reply_to", Self::VT_INCLUDE_REPLY_TO, false)? - .visit_field::>("subject", Self::VT_SUBJECT, false)? - .visit_field::>("body", Self::VT_BODY, false)? - .finish(); - Ok(()) - } -} -pub struct SendTemplateArgs<'a> { - pub id: u32, - pub title: Option>, - pub address: Option>, - pub amount: u64, - pub fiat_amount: f64, - pub fee_included: bool, - pub fiat: Option>, - pub include_reply_to: bool, - pub subject: Option>, - pub body: Option>, -} -impl<'a> Default for SendTemplateArgs<'a> { - #[inline] - fn default() -> Self { - SendTemplateArgs { - id: 0, - title: None, - address: None, - amount: 0, - fiat_amount: 0.0, - fee_included: false, - fiat: None, - include_reply_to: false, - subject: None, - body: None, - } - } -} - -pub struct SendTemplateBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, -} -impl<'a: 'b, 'b> SendTemplateBuilder<'a, 'b> { - #[inline] - pub fn add_id(&mut self, id: u32) { - self.fbb_.push_slot::(SendTemplate::VT_ID, id, 0); - } - #[inline] - pub fn add_title(&mut self, title: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>(SendTemplate::VT_TITLE, title); - } - #[inline] - pub fn add_address(&mut self, address: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>(SendTemplate::VT_ADDRESS, address); - } - #[inline] - pub fn add_amount(&mut self, amount: u64) { - self.fbb_.push_slot::(SendTemplate::VT_AMOUNT, amount, 0); - } - #[inline] - pub fn add_fiat_amount(&mut self, fiat_amount: f64) { - self.fbb_.push_slot::(SendTemplate::VT_FIAT_AMOUNT, fiat_amount, 0.0); - } - #[inline] - pub fn add_fee_included(&mut self, fee_included: bool) { - self.fbb_.push_slot::(SendTemplate::VT_FEE_INCLUDED, fee_included, false); - } - #[inline] - pub fn add_fiat(&mut self, fiat: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>(SendTemplate::VT_FIAT, fiat); - } - #[inline] - pub fn add_include_reply_to(&mut self, include_reply_to: bool) { - self.fbb_.push_slot::(SendTemplate::VT_INCLUDE_REPLY_TO, include_reply_to, false); - } - #[inline] - pub fn add_subject(&mut self, subject: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>(SendTemplate::VT_SUBJECT, subject); - } - #[inline] - pub fn add_body(&mut self, body: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>(SendTemplate::VT_BODY, body); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> SendTemplateBuilder<'a, 'b> { - let start = _fbb.start_table(); - SendTemplateBuilder { - 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 SendTemplate<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("SendTemplate"); - ds.field("id", &self.id()); - ds.field("title", &self.title()); - ds.field("address", &self.address()); - ds.field("amount", &self.amount()); - ds.field("fiat_amount", &self.fiat_amount()); - ds.field("fee_included", &self.fee_included()); - ds.field("fiat", &self.fiat()); - ds.field("include_reply_to", &self.include_reply_to()); - ds.field("subject", &self.subject()); - ds.field("body", &self.body()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct SendTemplateT { - pub id: u32, - pub title: Option, - pub address: Option, - pub amount: u64, - pub fiat_amount: f64, - pub fee_included: bool, - pub fiat: Option, - pub include_reply_to: bool, - pub subject: Option, - pub body: Option, -} -impl Default for SendTemplateT { - fn default() -> Self { - Self { - id: 0, - title: None, - address: None, - amount: 0, - fiat_amount: 0.0, - fee_included: false, - fiat: None, - include_reply_to: false, - subject: None, - body: None, - } - } -} -impl SendTemplateT { - pub fn pack<'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b> - ) -> flatbuffers::WIPOffset> { - let id = self.id; - let title = self.title.as_ref().map(|x|{ - _fbb.create_string(x) - }); - let address = self.address.as_ref().map(|x|{ - _fbb.create_string(x) - }); - let amount = self.amount; - let fiat_amount = self.fiat_amount; - let fee_included = self.fee_included; - let fiat = self.fiat.as_ref().map(|x|{ - _fbb.create_string(x) - }); - let include_reply_to = self.include_reply_to; - let subject = self.subject.as_ref().map(|x|{ - _fbb.create_string(x) - }); - let body = self.body.as_ref().map(|x|{ - _fbb.create_string(x) - }); - SendTemplate::create(_fbb, &SendTemplateArgs{ - id, - title, - address, - amount, - fiat_amount, - fee_included, - fiat, - include_reply_to, - subject, - body, - }) - } -} -pub enum SendTemplateVecOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct SendTemplateVec<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for SendTemplateVec<'a> { - type Inner = SendTemplateVec<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } - } -} - -impl<'a> SendTemplateVec<'a> { - pub const VT_TEMPLATES: flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - SendTemplateVec { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args SendTemplateVecArgs<'args> - ) -> flatbuffers::WIPOffset> { - let mut builder = SendTemplateVecBuilder::new(_fbb); - if let Some(x) = args.templates { builder.add_templates(x); } - builder.finish() - } - - pub fn unpack(&self) -> SendTemplateVecT { - let templates = self.templates().map(|x| { - x.iter().map(|t| t.unpack()).collect() - }); - SendTemplateVecT { - templates, - } - } - - #[inline] - pub fn templates(&self) -> Option>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>>>(SendTemplateVec::VT_TEMPLATES, None)} - } -} - -impl flatbuffers::Verifiable for SendTemplateVec<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, pos: usize - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>>>("templates", Self::VT_TEMPLATES, false)? - .finish(); - Ok(()) - } -} -pub struct SendTemplateVecArgs<'a> { - pub templates: Option>>>>, -} -impl<'a> Default for SendTemplateVecArgs<'a> { - #[inline] - fn default() -> Self { - SendTemplateVecArgs { - templates: None, - } - } -} - -pub struct SendTemplateVecBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, -} -impl<'a: 'b, 'b> SendTemplateVecBuilder<'a, 'b> { - #[inline] - pub fn add_templates(&mut self, templates: flatbuffers::WIPOffset>>>) { - self.fbb_.push_slot_always::>(SendTemplateVec::VT_TEMPLATES, templates); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> SendTemplateVecBuilder<'a, 'b> { - let start = _fbb.start_table(); - SendTemplateVecBuilder { - 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 SendTemplateVec<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("SendTemplateVec"); - ds.field("templates", &self.templates()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct SendTemplateVecT { - pub templates: Option>, -} -impl Default for SendTemplateVecT { - fn default() -> Self { - Self { - templates: None, - } - } -} -impl SendTemplateVecT { - pub fn pack<'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b> - ) -> flatbuffers::WIPOffset> { - let templates = self.templates.as_ref().map(|x|{ - let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) - }); - SendTemplateVec::create(_fbb, &SendTemplateVecArgs{ - templates, - }) - } -} -pub enum ContactOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct Contact<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for Contact<'a> { - type Inner = Contact<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } - } -} - -impl<'a> Contact<'a> { - pub const VT_ID: flatbuffers::VOffsetT = 4; - pub const VT_NAME: flatbuffers::VOffsetT = 6; - pub const VT_ADDRESS: flatbuffers::VOffsetT = 8; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - Contact { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args ContactArgs<'args> - ) -> flatbuffers::WIPOffset> { - let mut builder = ContactBuilder::new(_fbb); - if let Some(x) = args.address { builder.add_address(x); } - if let Some(x) = args.name { builder.add_name(x); } - builder.add_id(args.id); - builder.finish() - } - - pub fn unpack(&self) -> ContactT { - let id = self.id(); - let name = self.name().map(|x| { - x.to_string() - }); - let address = self.address().map(|x| { - x.to_string() - }); - ContactT { - id, - name, - address, - } - } - - #[inline] - pub fn id(&self) -> u32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Contact::VT_ID, Some(0)).unwrap()} - } - #[inline] - pub fn name(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>(Contact::VT_NAME, None)} - } - #[inline] - pub fn address(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>(Contact::VT_ADDRESS, None)} - } -} - -impl flatbuffers::Verifiable for Contact<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, pos: usize - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("id", Self::VT_ID, false)? - .visit_field::>("name", Self::VT_NAME, false)? - .visit_field::>("address", Self::VT_ADDRESS, false)? - .finish(); - Ok(()) - } -} -pub struct ContactArgs<'a> { - pub id: u32, - pub name: Option>, - pub address: Option>, -} -impl<'a> Default for ContactArgs<'a> { - #[inline] - fn default() -> Self { - ContactArgs { - id: 0, - name: None, - address: None, - } - } -} - -pub struct ContactBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, -} -impl<'a: 'b, 'b> ContactBuilder<'a, 'b> { - #[inline] - pub fn add_id(&mut self, id: u32) { - self.fbb_.push_slot::(Contact::VT_ID, id, 0); - } - #[inline] - pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>(Contact::VT_NAME, name); - } - #[inline] - pub fn add_address(&mut self, address: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>(Contact::VT_ADDRESS, address); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> ContactBuilder<'a, 'b> { - let start = _fbb.start_table(); - ContactBuilder { - 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 Contact<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("Contact"); - ds.field("id", &self.id()); - ds.field("name", &self.name()); - ds.field("address", &self.address()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct ContactT { - pub id: u32, - pub name: Option, - pub address: Option, -} -impl Default for ContactT { - fn default() -> Self { - Self { - id: 0, - name: None, - address: None, - } - } -} -impl ContactT { - pub fn pack<'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b> - ) -> flatbuffers::WIPOffset> { - let id = self.id; - let name = self.name.as_ref().map(|x|{ - _fbb.create_string(x) - }); - let address = self.address.as_ref().map(|x|{ - _fbb.create_string(x) - }); - Contact::create(_fbb, &ContactArgs{ - id, - name, - address, - }) - } -} -pub enum ContactVecOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct ContactVec<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for ContactVec<'a> { - type Inner = ContactVec<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } - } -} - -impl<'a> ContactVec<'a> { - pub const VT_CONTACTS: flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - ContactVec { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args ContactVecArgs<'args> - ) -> flatbuffers::WIPOffset> { - let mut builder = ContactVecBuilder::new(_fbb); - if let Some(x) = args.contacts { builder.add_contacts(x); } - builder.finish() - } - - pub fn unpack(&self) -> ContactVecT { - let contacts = self.contacts().map(|x| { - x.iter().map(|t| t.unpack()).collect() - }); - ContactVecT { - contacts, - } - } - - #[inline] - pub fn contacts(&self) -> Option>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>>>(ContactVec::VT_CONTACTS, None)} - } -} - -impl flatbuffers::Verifiable for ContactVec<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, pos: usize - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>>>("contacts", Self::VT_CONTACTS, false)? - .finish(); - Ok(()) - } -} -pub struct ContactVecArgs<'a> { - pub contacts: Option>>>>, -} -impl<'a> Default for ContactVecArgs<'a> { - #[inline] - fn default() -> Self { - ContactVecArgs { - contacts: None, - } - } -} - -pub struct ContactVecBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, -} -impl<'a: 'b, 'b> ContactVecBuilder<'a, 'b> { - #[inline] - pub fn add_contacts(&mut self, contacts: flatbuffers::WIPOffset>>>) { - self.fbb_.push_slot_always::>(ContactVec::VT_CONTACTS, contacts); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> ContactVecBuilder<'a, 'b> { - let start = _fbb.start_table(); - ContactVecBuilder { - 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 ContactVec<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("ContactVec"); - ds.field("contacts", &self.contacts()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct ContactVecT { - pub contacts: Option>, -} -impl Default for ContactVecT { - fn default() -> Self { - Self { - contacts: None, - } - } -} -impl ContactVecT { - pub fn pack<'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b> - ) -> flatbuffers::WIPOffset> { - let contacts = self.contacts.as_ref().map(|x|{ - let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) - }); - ContactVec::create(_fbb, &ContactVecArgs{ - contacts, - }) - } -} -pub enum TxTimeValueOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct TxTimeValue<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for TxTimeValue<'a> { - type Inner = TxTimeValue<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } - } -} - -impl<'a> TxTimeValue<'a> { - pub const VT_TIMESTAMP: flatbuffers::VOffsetT = 4; - pub const VT_VALUE: flatbuffers::VOffsetT = 6; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - TxTimeValue { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args TxTimeValueArgs - ) -> flatbuffers::WIPOffset> { - let mut builder = TxTimeValueBuilder::new(_fbb); - builder.add_value(args.value); - builder.add_timestamp(args.timestamp); - builder.finish() - } - - pub fn unpack(&self) -> TxTimeValueT { - let timestamp = self.timestamp(); - let value = self.value(); - TxTimeValueT { - timestamp, - value, - } - } - - #[inline] - pub fn timestamp(&self) -> u32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(TxTimeValue::VT_TIMESTAMP, Some(0)).unwrap()} - } - #[inline] - pub fn value(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(TxTimeValue::VT_VALUE, Some(0)).unwrap()} - } -} - -impl flatbuffers::Verifiable for TxTimeValue<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, pos: usize - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("timestamp", Self::VT_TIMESTAMP, false)? - .visit_field::("value", Self::VT_VALUE, false)? - .finish(); - Ok(()) - } -} -pub struct TxTimeValueArgs { - pub timestamp: u32, - pub value: u64, -} -impl<'a> Default for TxTimeValueArgs { - #[inline] - fn default() -> Self { - TxTimeValueArgs { - timestamp: 0, - value: 0, - } - } -} - -pub struct TxTimeValueBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, -} -impl<'a: 'b, 'b> TxTimeValueBuilder<'a, 'b> { - #[inline] - pub fn add_timestamp(&mut self, timestamp: u32) { - self.fbb_.push_slot::(TxTimeValue::VT_TIMESTAMP, timestamp, 0); - } - #[inline] - pub fn add_value(&mut self, value: u64) { - self.fbb_.push_slot::(TxTimeValue::VT_VALUE, value, 0); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> TxTimeValueBuilder<'a, 'b> { - let start = _fbb.start_table(); - TxTimeValueBuilder { - 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 TxTimeValue<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("TxTimeValue"); - ds.field("timestamp", &self.timestamp()); - ds.field("value", &self.value()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct TxTimeValueT { - pub timestamp: u32, - pub value: u64, -} -impl Default for TxTimeValueT { - fn default() -> Self { - Self { - timestamp: 0, - value: 0, - } - } -} -impl TxTimeValueT { - pub fn pack<'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b> - ) -> flatbuffers::WIPOffset> { - let timestamp = self.timestamp; - let value = self.value; - TxTimeValue::create(_fbb, &TxTimeValueArgs{ - timestamp, - value, - }) - } -} -pub enum TxTimeValueVecOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct TxTimeValueVec<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for TxTimeValueVec<'a> { - type Inner = TxTimeValueVec<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } - } -} - -impl<'a> TxTimeValueVec<'a> { - pub const VT_VALUES: flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - TxTimeValueVec { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args TxTimeValueVecArgs<'args> - ) -> flatbuffers::WIPOffset> { - let mut builder = TxTimeValueVecBuilder::new(_fbb); - if let Some(x) = args.values { builder.add_values(x); } - builder.finish() - } - - pub fn unpack(&self) -> TxTimeValueVecT { - let values = self.values().map(|x| { - x.iter().map(|t| t.unpack()).collect() - }); - TxTimeValueVecT { - values, - } - } - - #[inline] - pub fn values(&self) -> Option>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>>>(TxTimeValueVec::VT_VALUES, None)} - } -} - -impl flatbuffers::Verifiable for TxTimeValueVec<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, pos: usize - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>>>("values", Self::VT_VALUES, false)? - .finish(); - Ok(()) - } -} -pub struct TxTimeValueVecArgs<'a> { - pub values: Option>>>>, -} -impl<'a> Default for TxTimeValueVecArgs<'a> { - #[inline] - fn default() -> Self { - TxTimeValueVecArgs { - values: None, - } - } -} - -pub struct TxTimeValueVecBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, -} -impl<'a: 'b, 'b> TxTimeValueVecBuilder<'a, 'b> { - #[inline] - pub fn add_values(&mut self, values: flatbuffers::WIPOffset>>>) { - self.fbb_.push_slot_always::>(TxTimeValueVec::VT_VALUES, values); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> TxTimeValueVecBuilder<'a, 'b> { - let start = _fbb.start_table(); - TxTimeValueVecBuilder { - 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 TxTimeValueVec<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("TxTimeValueVec"); - ds.field("values", &self.values()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct TxTimeValueVecT { - pub values: Option>, -} -impl Default for TxTimeValueVecT { - fn default() -> Self { - Self { - values: None, - } - } -} -impl TxTimeValueVecT { - pub fn pack<'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b> - ) -> flatbuffers::WIPOffset> { - let values = self.values.as_ref().map(|x|{ - let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) - }); - TxTimeValueVec::create(_fbb, &TxTimeValueVecArgs{ - values, - }) - } -} -pub enum QuoteOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct Quote<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for Quote<'a> { - type Inner = Quote<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } - } -} - -impl<'a> Quote<'a> { - pub const VT_TIMESTAMP: flatbuffers::VOffsetT = 4; - pub const VT_PRICE: flatbuffers::VOffsetT = 6; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - Quote { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args QuoteArgs - ) -> flatbuffers::WIPOffset> { - let mut builder = QuoteBuilder::new(_fbb); - builder.add_price(args.price); - builder.add_timestamp(args.timestamp); - builder.finish() - } - - pub fn unpack(&self) -> QuoteT { - let timestamp = self.timestamp(); - let price = self.price(); - QuoteT { - timestamp, - price, - } - } - - #[inline] - pub fn timestamp(&self) -> u32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Quote::VT_TIMESTAMP, Some(0)).unwrap()} - } - #[inline] - pub fn price(&self) -> f64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Quote::VT_PRICE, Some(0.0)).unwrap()} - } -} - -impl flatbuffers::Verifiable for Quote<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, pos: usize - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("timestamp", Self::VT_TIMESTAMP, false)? - .visit_field::("price", Self::VT_PRICE, false)? - .finish(); - Ok(()) - } -} -pub struct QuoteArgs { - pub timestamp: u32, - pub price: f64, -} -impl<'a> Default for QuoteArgs { - #[inline] - fn default() -> Self { - QuoteArgs { - timestamp: 0, - price: 0.0, - } - } -} - -pub struct QuoteBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, -} -impl<'a: 'b, 'b> QuoteBuilder<'a, 'b> { - #[inline] - pub fn add_timestamp(&mut self, timestamp: u32) { - self.fbb_.push_slot::(Quote::VT_TIMESTAMP, timestamp, 0); - } - #[inline] - pub fn add_price(&mut self, price: f64) { - self.fbb_.push_slot::(Quote::VT_PRICE, price, 0.0); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> QuoteBuilder<'a, 'b> { - let start = _fbb.start_table(); - QuoteBuilder { - 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 Quote<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("Quote"); - ds.field("timestamp", &self.timestamp()); - ds.field("price", &self.price()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct QuoteT { - pub timestamp: u32, - pub price: f64, -} -impl Default for QuoteT { - fn default() -> Self { - Self { - timestamp: 0, - price: 0.0, - } - } -} -impl QuoteT { - pub fn pack<'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b> - ) -> flatbuffers::WIPOffset> { - let timestamp = self.timestamp; - let price = self.price; - Quote::create(_fbb, &QuoteArgs{ - timestamp, - price, - }) - } -} -pub enum QuoteVecOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct QuoteVec<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for QuoteVec<'a> { - type Inner = QuoteVec<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } - } -} - -impl<'a> QuoteVec<'a> { - pub const VT_VALUES: flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - QuoteVec { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args QuoteVecArgs<'args> - ) -> flatbuffers::WIPOffset> { - let mut builder = QuoteVecBuilder::new(_fbb); - if let Some(x) = args.values { builder.add_values(x); } - builder.finish() - } - - pub fn unpack(&self) -> QuoteVecT { - let values = self.values().map(|x| { - x.iter().map(|t| t.unpack()).collect() - }); - QuoteVecT { - values, - } - } - - #[inline] - pub fn values(&self) -> Option>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>>>(QuoteVec::VT_VALUES, None)} - } -} - -impl flatbuffers::Verifiable for QuoteVec<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, pos: usize - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>>>("values", Self::VT_VALUES, false)? - .finish(); - Ok(()) - } -} -pub struct QuoteVecArgs<'a> { - pub values: Option>>>>, -} -impl<'a> Default for QuoteVecArgs<'a> { - #[inline] - fn default() -> Self { - QuoteVecArgs { - values: None, - } - } -} - -pub struct QuoteVecBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, -} -impl<'a: 'b, 'b> QuoteVecBuilder<'a, 'b> { - #[inline] - pub fn add_values(&mut self, values: flatbuffers::WIPOffset>>>) { - self.fbb_.push_slot_always::>(QuoteVec::VT_VALUES, values); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> QuoteVecBuilder<'a, 'b> { - let start = _fbb.start_table(); - QuoteVecBuilder { - 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 QuoteVec<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("QuoteVec"); - ds.field("values", &self.values()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct QuoteVecT { - pub values: Option>, -} -impl Default for QuoteVecT { - fn default() -> Self { - Self { - values: None, - } - } -} -impl QuoteVecT { - pub fn pack<'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b> - ) -> flatbuffers::WIPOffset> { - let values = self.values.as_ref().map(|x|{ - let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) - }); - QuoteVec::create(_fbb, &QuoteVecArgs{ - values, - }) - } -} -pub enum SpendingOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct Spending<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for Spending<'a> { - type Inner = Spending<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } - } -} - -impl<'a> Spending<'a> { - pub const VT_RECIPIENT: flatbuffers::VOffsetT = 4; - pub const VT_AMOUNT: flatbuffers::VOffsetT = 6; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - Spending { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args SpendingArgs<'args> - ) -> flatbuffers::WIPOffset> { - let mut builder = SpendingBuilder::new(_fbb); - builder.add_amount(args.amount); - if let Some(x) = args.recipient { builder.add_recipient(x); } - builder.finish() - } - - pub fn unpack(&self) -> SpendingT { - let recipient = self.recipient().map(|x| { - x.to_string() - }); - let amount = self.amount(); - SpendingT { - recipient, - amount, - } - } - - #[inline] - pub fn recipient(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>(Spending::VT_RECIPIENT, None)} - } - #[inline] - pub fn amount(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Spending::VT_AMOUNT, Some(0)).unwrap()} - } -} - -impl flatbuffers::Verifiable for Spending<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, pos: usize - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>("recipient", Self::VT_RECIPIENT, false)? - .visit_field::("amount", Self::VT_AMOUNT, false)? - .finish(); - Ok(()) - } -} -pub struct SpendingArgs<'a> { - pub recipient: Option>, - pub amount: u64, -} -impl<'a> Default for SpendingArgs<'a> { - #[inline] - fn default() -> Self { - SpendingArgs { - recipient: None, - amount: 0, - } - } -} - -pub struct SpendingBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, -} -impl<'a: 'b, 'b> SpendingBuilder<'a, 'b> { - #[inline] - pub fn add_recipient(&mut self, recipient: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>(Spending::VT_RECIPIENT, recipient); - } - #[inline] - pub fn add_amount(&mut self, amount: u64) { - self.fbb_.push_slot::(Spending::VT_AMOUNT, amount, 0); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> SpendingBuilder<'a, 'b> { - let start = _fbb.start_table(); - SpendingBuilder { - 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 Spending<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("Spending"); - ds.field("recipient", &self.recipient()); - ds.field("amount", &self.amount()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct SpendingT { - pub recipient: Option, - pub amount: u64, -} -impl Default for SpendingT { - fn default() -> Self { - Self { - recipient: None, - amount: 0, - } - } -} -impl SpendingT { - pub fn pack<'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b> - ) -> flatbuffers::WIPOffset> { - let recipient = self.recipient.as_ref().map(|x|{ - _fbb.create_string(x) - }); - let amount = self.amount; - Spending::create(_fbb, &SpendingArgs{ - recipient, - amount, - }) - } -} -pub enum SpendingVecOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct SpendingVec<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for SpendingVec<'a> { - type Inner = SpendingVec<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } - } -} - -impl<'a> SpendingVec<'a> { - pub const VT_VALUES: flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - SpendingVec { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args SpendingVecArgs<'args> - ) -> flatbuffers::WIPOffset> { - let mut builder = SpendingVecBuilder::new(_fbb); - if let Some(x) = args.values { builder.add_values(x); } - builder.finish() - } - - pub fn unpack(&self) -> SpendingVecT { - let values = self.values().map(|x| { - x.iter().map(|t| t.unpack()).collect() - }); - SpendingVecT { - values, - } - } - - #[inline] - pub fn values(&self) -> Option>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>>>(SpendingVec::VT_VALUES, None)} - } -} - -impl flatbuffers::Verifiable for SpendingVec<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, pos: usize - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>>>("values", Self::VT_VALUES, false)? - .finish(); - Ok(()) - } -} -pub struct SpendingVecArgs<'a> { - pub values: Option>>>>, -} -impl<'a> Default for SpendingVecArgs<'a> { - #[inline] - fn default() -> Self { - SpendingVecArgs { - values: None, - } - } -} - -pub struct SpendingVecBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, -} -impl<'a: 'b, 'b> SpendingVecBuilder<'a, 'b> { - #[inline] - pub fn add_values(&mut self, values: flatbuffers::WIPOffset>>>) { - self.fbb_.push_slot_always::>(SpendingVec::VT_VALUES, values); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> SpendingVecBuilder<'a, 'b> { - let start = _fbb.start_table(); - SpendingVecBuilder { - 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 SpendingVec<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("SpendingVec"); - ds.field("values", &self.values()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct SpendingVecT { - pub values: Option>, -} -impl Default for SpendingVecT { - fn default() -> Self { - Self { - values: None, - } - } -} -impl SpendingVecT { - pub fn pack<'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b> - ) -> flatbuffers::WIPOffset> { - let values = self.values.as_ref().map(|x|{ - let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) - }); - SpendingVec::create(_fbb, &SpendingVecArgs{ - values, - }) - } -} -pub enum AddressBalanceOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct AddressBalance<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for AddressBalance<'a> { - type Inner = AddressBalance<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } - } -} - -impl<'a> AddressBalance<'a> { - pub const VT_INDEX: flatbuffers::VOffsetT = 4; - pub const VT_ADDRESS: flatbuffers::VOffsetT = 6; - pub const VT_BALANCE: flatbuffers::VOffsetT = 8; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - AddressBalance { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args AddressBalanceArgs<'args> - ) -> flatbuffers::WIPOffset> { - let mut builder = AddressBalanceBuilder::new(_fbb); - builder.add_balance(args.balance); - if let Some(x) = args.address { builder.add_address(x); } - builder.add_index(args.index); - builder.finish() - } - - pub fn unpack(&self) -> AddressBalanceT { - let index = self.index(); - let address = self.address().map(|x| { - x.to_string() - }); - let balance = self.balance(); - AddressBalanceT { - index, - address, - balance, - } - } - - #[inline] - pub fn index(&self) -> u32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(AddressBalance::VT_INDEX, Some(0)).unwrap()} - } - #[inline] - pub fn address(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>(AddressBalance::VT_ADDRESS, None)} - } - #[inline] - pub fn balance(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(AddressBalance::VT_BALANCE, Some(0)).unwrap()} - } -} - -impl flatbuffers::Verifiable for AddressBalance<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, pos: usize - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("index", Self::VT_INDEX, false)? - .visit_field::>("address", Self::VT_ADDRESS, false)? - .visit_field::("balance", Self::VT_BALANCE, false)? - .finish(); - Ok(()) - } -} -pub struct AddressBalanceArgs<'a> { - pub index: u32, - pub address: Option>, - pub balance: u64, -} -impl<'a> Default for AddressBalanceArgs<'a> { - #[inline] - fn default() -> Self { - AddressBalanceArgs { - index: 0, - address: None, - balance: 0, - } - } -} - -pub struct AddressBalanceBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, -} -impl<'a: 'b, 'b> AddressBalanceBuilder<'a, 'b> { - #[inline] - pub fn add_index(&mut self, index: u32) { - self.fbb_.push_slot::(AddressBalance::VT_INDEX, index, 0); - } - #[inline] - pub fn add_address(&mut self, address: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>(AddressBalance::VT_ADDRESS, address); - } - #[inline] - pub fn add_balance(&mut self, balance: u64) { - self.fbb_.push_slot::(AddressBalance::VT_BALANCE, balance, 0); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> AddressBalanceBuilder<'a, 'b> { - let start = _fbb.start_table(); - AddressBalanceBuilder { - 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 AddressBalance<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("AddressBalance"); - ds.field("index", &self.index()); - ds.field("address", &self.address()); - ds.field("balance", &self.balance()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct AddressBalanceT { - pub index: u32, - pub address: Option, - pub balance: u64, -} -impl Default for AddressBalanceT { - fn default() -> Self { - Self { - index: 0, - address: None, - balance: 0, - } - } -} -impl AddressBalanceT { - pub fn pack<'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b> - ) -> flatbuffers::WIPOffset> { - let index = self.index; - let address = self.address.as_ref().map(|x|{ - _fbb.create_string(x) - }); - let balance = self.balance; - AddressBalance::create(_fbb, &AddressBalanceArgs{ - index, - address, - balance, - }) - } -} -pub enum AddressBalanceVecOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct AddressBalanceVec<'a> { - pub _tab: flatbuffers::Table<'a>, -} - -impl<'a> flatbuffers::Follow<'a> for AddressBalanceVec<'a> { - type Inner = AddressBalanceVec<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } - } -} - -impl<'a> AddressBalanceVec<'a> { - pub const VT_VALUES: flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - AddressBalanceVec { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args AddressBalanceVecArgs<'args> - ) -> flatbuffers::WIPOffset> { - let mut builder = AddressBalanceVecBuilder::new(_fbb); - if let Some(x) = args.values { builder.add_values(x); } - builder.finish() - } - - pub fn unpack(&self) -> AddressBalanceVecT { - let values = self.values().map(|x| { - x.iter().map(|t| t.unpack()).collect() - }); - AddressBalanceVecT { - values, - } - } - - #[inline] - pub fn values(&self) -> Option>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>>>(AddressBalanceVec::VT_VALUES, None)} - } -} - -impl flatbuffers::Verifiable for AddressBalanceVec<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, pos: usize - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>>>("values", Self::VT_VALUES, false)? - .finish(); - Ok(()) - } -} -pub struct AddressBalanceVecArgs<'a> { - pub values: Option>>>>, -} -impl<'a> Default for AddressBalanceVecArgs<'a> { - #[inline] - fn default() -> Self { - AddressBalanceVecArgs { - values: None, - } - } -} - -pub struct AddressBalanceVecBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, -} -impl<'a: 'b, 'b> AddressBalanceVecBuilder<'a, 'b> { - #[inline] - pub fn add_values(&mut self, values: flatbuffers::WIPOffset>>>) { - self.fbb_.push_slot_always::>(AddressBalanceVec::VT_VALUES, values); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> AddressBalanceVecBuilder<'a, 'b> { - let start = _fbb.start_table(); - AddressBalanceVecBuilder { - 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 AddressBalanceVec<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("AddressBalanceVec"); - ds.field("values", &self.values()); - ds.finish() - } -} -#[non_exhaustive] -#[derive(Debug, Clone, PartialEq)] -pub struct AddressBalanceVecT { - pub values: Option>, -} -impl Default for AddressBalanceVecT { - fn default() -> Self { - Self { - values: None, - } - } -} -impl AddressBalanceVecT { - pub fn pack<'b>( - &self, - _fbb: &mut flatbuffers::FlatBufferBuilder<'b> - ) -> flatbuffers::WIPOffset> { - let values = self.values.as_ref().map(|x|{ - let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) - }); - AddressBalanceVec::create(_fbb, &AddressBalanceVecArgs{ - values, - }) - } -} -} // pub mod fb + use core::cmp::Ordering; + use core::mem; + extern crate flatbuffers; + use self::flatbuffers::{EndianScalar, Follow}; + + pub enum AccountOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct Account<'a> { + pub _tab: flatbuffers::Table<'a>, + } + + impl<'a> flatbuffers::Follow<'a> for Account<'a> { + type Inner = Account<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } + } + } + + impl<'a> Account<'a> { + pub const VT_ID: flatbuffers::VOffsetT = 4; + pub const VT_NAME: flatbuffers::VOffsetT = 6; + pub const VT_BALANCE: flatbuffers::VOffsetT = 8; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + Account { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args AccountArgs<'args>, + ) -> flatbuffers::WIPOffset> { + let mut builder = AccountBuilder::new(_fbb); + builder.add_balance(args.balance); + if let Some(x) = args.name { + builder.add_name(x); + } + builder.add_id(args.id); + builder.finish() + } + + pub fn unpack(&self) -> AccountT { + let id = self.id(); + let name = self.name().map(|x| x.to_string()); + let balance = self.balance(); + AccountT { id, name, balance } + } + + #[inline] + pub fn id(&self) -> u32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Account::VT_ID, Some(0)).unwrap() } + } + #[inline] + pub fn name(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::>(Account::VT_NAME, None) + } + } + #[inline] + pub fn balance(&self) -> u64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Account::VT_BALANCE, Some(0)).unwrap() } + } + } + + impl flatbuffers::Verifiable for Account<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, + pos: usize, + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::("id", Self::VT_ID, false)? + .visit_field::>("name", Self::VT_NAME, false)? + .visit_field::("balance", Self::VT_BALANCE, false)? + .finish(); + Ok(()) + } + } + pub struct AccountArgs<'a> { + pub id: u32, + pub name: Option>, + pub balance: u64, + } + impl<'a> Default for AccountArgs<'a> { + #[inline] + fn default() -> Self { + AccountArgs { + id: 0, + name: None, + balance: 0, + } + } + } + + pub struct AccountBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, + } + impl<'a: 'b, 'b> AccountBuilder<'a, 'b> { + #[inline] + pub fn add_id(&mut self, id: u32) { + self.fbb_.push_slot::(Account::VT_ID, id, 0); + } + #[inline] + pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { + self.fbb_ + .push_slot_always::>(Account::VT_NAME, name); + } + #[inline] + pub fn add_balance(&mut self, balance: u64) { + self.fbb_.push_slot::(Account::VT_BALANCE, balance, 0); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> AccountBuilder<'a, 'b> { + let start = _fbb.start_table(); + AccountBuilder { + 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 Account<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("Account"); + ds.field("id", &self.id()); + ds.field("name", &self.name()); + ds.field("balance", &self.balance()); + ds.finish() + } + } + #[non_exhaustive] + #[derive(Debug, Clone, PartialEq)] + pub struct AccountT { + pub id: u32, + pub name: Option, + pub balance: u64, + } + impl Default for AccountT { + fn default() -> Self { + Self { + id: 0, + name: None, + balance: 0, + } + } + } + impl AccountT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b>, + ) -> flatbuffers::WIPOffset> { + let id = self.id; + let name = self.name.as_ref().map(|x| _fbb.create_string(x)); + let balance = self.balance; + Account::create(_fbb, &AccountArgs { id, name, balance }) + } + } + pub enum AccountVecOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct AccountVec<'a> { + pub _tab: flatbuffers::Table<'a>, + } + + impl<'a> flatbuffers::Follow<'a> for AccountVec<'a> { + type Inner = AccountVec<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } + } + } + + impl<'a> AccountVec<'a> { + pub const VT_ACCOUNTS: flatbuffers::VOffsetT = 4; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + AccountVec { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args AccountVecArgs<'args>, + ) -> flatbuffers::WIPOffset> { + let mut builder = AccountVecBuilder::new(_fbb); + if let Some(x) = args.accounts { + builder.add_accounts(x); + } + builder.finish() + } + + pub fn unpack(&self) -> AccountVecT { + let accounts = self + .accounts() + .map(|x| x.iter().map(|t| t.unpack()).collect()); + AccountVecT { accounts } + } + + #[inline] + pub fn accounts( + &self, + ) -> Option>>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab.get::>, + >>(AccountVec::VT_ACCOUNTS, None) + } + } + } + + impl flatbuffers::Verifiable for AccountVec<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, + pos: usize, + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>, + >>("accounts", Self::VT_ACCOUNTS, false)? + .finish(); + Ok(()) + } + } + pub struct AccountVecArgs<'a> { + pub accounts: Option< + flatbuffers::WIPOffset< + flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>>, + >, + >, + } + impl<'a> Default for AccountVecArgs<'a> { + #[inline] + fn default() -> Self { + AccountVecArgs { accounts: None } + } + } + + pub struct AccountVecBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, + } + impl<'a: 'b, 'b> AccountVecBuilder<'a, 'b> { + #[inline] + pub fn add_accounts( + &mut self, + accounts: flatbuffers::WIPOffset< + flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, + >, + ) { + self.fbb_ + .push_slot_always::>(AccountVec::VT_ACCOUNTS, accounts); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> AccountVecBuilder<'a, 'b> { + let start = _fbb.start_table(); + AccountVecBuilder { + 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 AccountVec<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("AccountVec"); + ds.field("accounts", &self.accounts()); + ds.finish() + } + } + #[non_exhaustive] + #[derive(Debug, Clone, PartialEq)] + pub struct AccountVecT { + pub accounts: Option>, + } + impl Default for AccountVecT { + fn default() -> Self { + Self { accounts: None } + } + } + impl AccountVecT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b>, + ) -> flatbuffers::WIPOffset> { + let accounts = self.accounts.as_ref().map(|x| { + let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect(); + _fbb.create_vector(&w) + }); + AccountVec::create(_fbb, &AccountVecArgs { accounts }) + } + } + pub enum BalanceOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct Balance<'a> { + pub _tab: flatbuffers::Table<'a>, + } + + impl<'a> flatbuffers::Follow<'a> for Balance<'a> { + type Inner = Balance<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } + } + } + + impl<'a> Balance<'a> { + pub const VT_SHIELDED: flatbuffers::VOffsetT = 4; + pub const VT_UNCONFIRMED_SPENT: flatbuffers::VOffsetT = 6; + pub const VT_BALANCE: flatbuffers::VOffsetT = 8; + pub const VT_UNDER_CONFIRMED: flatbuffers::VOffsetT = 10; + pub const VT_EXCLUDED: flatbuffers::VOffsetT = 12; + pub const VT_SAPLING: flatbuffers::VOffsetT = 14; + pub const VT_ORCHARD: flatbuffers::VOffsetT = 16; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + Balance { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args BalanceArgs, + ) -> flatbuffers::WIPOffset> { + let mut builder = BalanceBuilder::new(_fbb); + builder.add_orchard(args.orchard); + builder.add_sapling(args.sapling); + builder.add_excluded(args.excluded); + builder.add_under_confirmed(args.under_confirmed); + builder.add_balance(args.balance); + builder.add_unconfirmed_spent(args.unconfirmed_spent); + builder.add_shielded(args.shielded); + builder.finish() + } + + pub fn unpack(&self) -> BalanceT { + let shielded = self.shielded(); + let unconfirmed_spent = self.unconfirmed_spent(); + let balance = self.balance(); + let under_confirmed = self.under_confirmed(); + let excluded = self.excluded(); + let sapling = self.sapling(); + let orchard = self.orchard(); + BalanceT { + shielded, + unconfirmed_spent, + balance, + under_confirmed, + excluded, + sapling, + orchard, + } + } + + #[inline] + pub fn shielded(&self) -> u64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Balance::VT_SHIELDED, Some(0)).unwrap() } + } + #[inline] + pub fn unconfirmed_spent(&self) -> u64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(Balance::VT_UNCONFIRMED_SPENT, Some(0)) + .unwrap() + } + } + #[inline] + pub fn balance(&self) -> u64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Balance::VT_BALANCE, Some(0)).unwrap() } + } + #[inline] + pub fn under_confirmed(&self) -> u64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(Balance::VT_UNDER_CONFIRMED, Some(0)) + .unwrap() + } + } + #[inline] + pub fn excluded(&self) -> u64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Balance::VT_EXCLUDED, Some(0)).unwrap() } + } + #[inline] + pub fn sapling(&self) -> u64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Balance::VT_SAPLING, Some(0)).unwrap() } + } + #[inline] + pub fn orchard(&self) -> u64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Balance::VT_ORCHARD, Some(0)).unwrap() } + } + } + + impl flatbuffers::Verifiable for Balance<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, + pos: usize, + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::("shielded", Self::VT_SHIELDED, false)? + .visit_field::("unconfirmed_spent", Self::VT_UNCONFIRMED_SPENT, false)? + .visit_field::("balance", Self::VT_BALANCE, false)? + .visit_field::("under_confirmed", Self::VT_UNDER_CONFIRMED, false)? + .visit_field::("excluded", Self::VT_EXCLUDED, false)? + .visit_field::("sapling", Self::VT_SAPLING, false)? + .visit_field::("orchard", Self::VT_ORCHARD, false)? + .finish(); + Ok(()) + } + } + pub struct BalanceArgs { + pub shielded: u64, + pub unconfirmed_spent: u64, + pub balance: u64, + pub under_confirmed: u64, + pub excluded: u64, + pub sapling: u64, + pub orchard: u64, + } + impl<'a> Default for BalanceArgs { + #[inline] + fn default() -> Self { + BalanceArgs { + shielded: 0, + unconfirmed_spent: 0, + balance: 0, + under_confirmed: 0, + excluded: 0, + sapling: 0, + orchard: 0, + } + } + } + + pub struct BalanceBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, + } + impl<'a: 'b, 'b> BalanceBuilder<'a, 'b> { + #[inline] + pub fn add_shielded(&mut self, shielded: u64) { + self.fbb_ + .push_slot::(Balance::VT_SHIELDED, shielded, 0); + } + #[inline] + pub fn add_unconfirmed_spent(&mut self, unconfirmed_spent: u64) { + self.fbb_ + .push_slot::(Balance::VT_UNCONFIRMED_SPENT, unconfirmed_spent, 0); + } + #[inline] + pub fn add_balance(&mut self, balance: u64) { + self.fbb_.push_slot::(Balance::VT_BALANCE, balance, 0); + } + #[inline] + pub fn add_under_confirmed(&mut self, under_confirmed: u64) { + self.fbb_ + .push_slot::(Balance::VT_UNDER_CONFIRMED, under_confirmed, 0); + } + #[inline] + pub fn add_excluded(&mut self, excluded: u64) { + self.fbb_ + .push_slot::(Balance::VT_EXCLUDED, excluded, 0); + } + #[inline] + pub fn add_sapling(&mut self, sapling: u64) { + self.fbb_.push_slot::(Balance::VT_SAPLING, sapling, 0); + } + #[inline] + pub fn add_orchard(&mut self, orchard: u64) { + self.fbb_.push_slot::(Balance::VT_ORCHARD, orchard, 0); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> BalanceBuilder<'a, 'b> { + let start = _fbb.start_table(); + BalanceBuilder { + 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 Balance<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("Balance"); + ds.field("shielded", &self.shielded()); + ds.field("unconfirmed_spent", &self.unconfirmed_spent()); + ds.field("balance", &self.balance()); + ds.field("under_confirmed", &self.under_confirmed()); + ds.field("excluded", &self.excluded()); + ds.field("sapling", &self.sapling()); + ds.field("orchard", &self.orchard()); + ds.finish() + } + } + #[non_exhaustive] + #[derive(Debug, Clone, PartialEq)] + pub struct BalanceT { + pub shielded: u64, + pub unconfirmed_spent: u64, + pub balance: u64, + pub under_confirmed: u64, + pub excluded: u64, + pub sapling: u64, + pub orchard: u64, + } + impl Default for BalanceT { + fn default() -> Self { + Self { + shielded: 0, + unconfirmed_spent: 0, + balance: 0, + under_confirmed: 0, + excluded: 0, + sapling: 0, + orchard: 0, + } + } + } + impl BalanceT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b>, + ) -> flatbuffers::WIPOffset> { + let shielded = self.shielded; + let unconfirmed_spent = self.unconfirmed_spent; + let balance = self.balance; + let under_confirmed = self.under_confirmed; + let excluded = self.excluded; + let sapling = self.sapling; + let orchard = self.orchard; + Balance::create( + _fbb, + &BalanceArgs { + shielded, + unconfirmed_spent, + balance, + under_confirmed, + excluded, + sapling, + orchard, + }, + ) + } + } + pub enum HeightOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct Height<'a> { + pub _tab: flatbuffers::Table<'a>, + } + + impl<'a> flatbuffers::Follow<'a> for Height<'a> { + type Inner = Height<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } + } + } + + impl<'a> Height<'a> { + pub const VT_HEIGHT: flatbuffers::VOffsetT = 4; + pub const VT_TIMESTAMP: flatbuffers::VOffsetT = 6; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + Height { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args HeightArgs, + ) -> flatbuffers::WIPOffset> { + let mut builder = HeightBuilder::new(_fbb); + builder.add_timestamp(args.timestamp); + builder.add_height(args.height); + builder.finish() + } + + pub fn unpack(&self) -> HeightT { + let height = self.height(); + let timestamp = self.timestamp(); + HeightT { height, timestamp } + } + + #[inline] + pub fn height(&self) -> u32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Height::VT_HEIGHT, Some(0)).unwrap() } + } + #[inline] + pub fn timestamp(&self) -> u32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Height::VT_TIMESTAMP, Some(0)).unwrap() } + } + } + + impl flatbuffers::Verifiable for Height<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, + pos: usize, + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::("height", Self::VT_HEIGHT, false)? + .visit_field::("timestamp", Self::VT_TIMESTAMP, false)? + .finish(); + Ok(()) + } + } + pub struct HeightArgs { + pub height: u32, + pub timestamp: u32, + } + impl<'a> Default for HeightArgs { + #[inline] + fn default() -> Self { + HeightArgs { + height: 0, + timestamp: 0, + } + } + } + + pub struct HeightBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, + } + impl<'a: 'b, 'b> HeightBuilder<'a, 'b> { + #[inline] + pub fn add_height(&mut self, height: u32) { + self.fbb_.push_slot::(Height::VT_HEIGHT, height, 0); + } + #[inline] + pub fn add_timestamp(&mut self, timestamp: u32) { + self.fbb_ + .push_slot::(Height::VT_TIMESTAMP, timestamp, 0); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> HeightBuilder<'a, 'b> { + let start = _fbb.start_table(); + HeightBuilder { + 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 Height<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("Height"); + ds.field("height", &self.height()); + ds.field("timestamp", &self.timestamp()); + ds.finish() + } + } + #[non_exhaustive] + #[derive(Debug, Clone, PartialEq)] + pub struct HeightT { + pub height: u32, + pub timestamp: u32, + } + impl Default for HeightT { + fn default() -> Self { + Self { + height: 0, + timestamp: 0, + } + } + } + impl HeightT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b>, + ) -> flatbuffers::WIPOffset> { + let height = self.height; + let timestamp = self.timestamp; + Height::create(_fbb, &HeightArgs { height, timestamp }) + } + } + pub enum ShieldedNoteOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct ShieldedNote<'a> { + pub _tab: flatbuffers::Table<'a>, + } + + impl<'a> flatbuffers::Follow<'a> for ShieldedNote<'a> { + type Inner = ShieldedNote<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } + } + } + + impl<'a> ShieldedNote<'a> { + pub const VT_ID: flatbuffers::VOffsetT = 4; + pub const VT_HEIGHT: flatbuffers::VOffsetT = 6; + pub const VT_VALUE: flatbuffers::VOffsetT = 8; + pub const VT_TIMESTAMP: flatbuffers::VOffsetT = 10; + pub const VT_ORCHARD: flatbuffers::VOffsetT = 12; + pub const VT_EXCLUDED: flatbuffers::VOffsetT = 14; + pub const VT_SPENT: flatbuffers::VOffsetT = 16; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + ShieldedNote { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args ShieldedNoteArgs, + ) -> flatbuffers::WIPOffset> { + let mut builder = ShieldedNoteBuilder::new(_fbb); + builder.add_value(args.value); + builder.add_timestamp(args.timestamp); + builder.add_height(args.height); + builder.add_id(args.id); + builder.add_spent(args.spent); + builder.add_excluded(args.excluded); + builder.add_orchard(args.orchard); + builder.finish() + } + + pub fn unpack(&self) -> ShieldedNoteT { + let id = self.id(); + let height = self.height(); + let value = self.value(); + let timestamp = self.timestamp(); + let orchard = self.orchard(); + let excluded = self.excluded(); + let spent = self.spent(); + ShieldedNoteT { + id, + height, + value, + timestamp, + orchard, + excluded, + spent, + } + } + + #[inline] + pub fn id(&self) -> u32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(ShieldedNote::VT_ID, Some(0)).unwrap() } + } + #[inline] + pub fn height(&self) -> u32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(ShieldedNote::VT_HEIGHT, Some(0)) + .unwrap() + } + } + #[inline] + pub fn value(&self) -> u64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(ShieldedNote::VT_VALUE, Some(0)) + .unwrap() + } + } + #[inline] + pub fn timestamp(&self) -> u32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(ShieldedNote::VT_TIMESTAMP, Some(0)) + .unwrap() + } + } + #[inline] + pub fn orchard(&self) -> bool { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(ShieldedNote::VT_ORCHARD, Some(false)) + .unwrap() + } + } + #[inline] + pub fn excluded(&self) -> bool { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(ShieldedNote::VT_EXCLUDED, Some(false)) + .unwrap() + } + } + #[inline] + pub fn spent(&self) -> bool { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(ShieldedNote::VT_SPENT, Some(false)) + .unwrap() + } + } + } + + impl flatbuffers::Verifiable for ShieldedNote<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, + pos: usize, + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::("id", Self::VT_ID, false)? + .visit_field::("height", Self::VT_HEIGHT, false)? + .visit_field::("value", Self::VT_VALUE, false)? + .visit_field::("timestamp", Self::VT_TIMESTAMP, false)? + .visit_field::("orchard", Self::VT_ORCHARD, false)? + .visit_field::("excluded", Self::VT_EXCLUDED, false)? + .visit_field::("spent", Self::VT_SPENT, false)? + .finish(); + Ok(()) + } + } + pub struct ShieldedNoteArgs { + pub id: u32, + pub height: u32, + pub value: u64, + pub timestamp: u32, + pub orchard: bool, + pub excluded: bool, + pub spent: bool, + } + impl<'a> Default for ShieldedNoteArgs { + #[inline] + fn default() -> Self { + ShieldedNoteArgs { + id: 0, + height: 0, + value: 0, + timestamp: 0, + orchard: false, + excluded: false, + spent: false, + } + } + } + + pub struct ShieldedNoteBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, + } + impl<'a: 'b, 'b> ShieldedNoteBuilder<'a, 'b> { + #[inline] + pub fn add_id(&mut self, id: u32) { + self.fbb_.push_slot::(ShieldedNote::VT_ID, id, 0); + } + #[inline] + pub fn add_height(&mut self, height: u32) { + self.fbb_ + .push_slot::(ShieldedNote::VT_HEIGHT, height, 0); + } + #[inline] + pub fn add_value(&mut self, value: u64) { + self.fbb_.push_slot::(ShieldedNote::VT_VALUE, value, 0); + } + #[inline] + pub fn add_timestamp(&mut self, timestamp: u32) { + self.fbb_ + .push_slot::(ShieldedNote::VT_TIMESTAMP, timestamp, 0); + } + #[inline] + pub fn add_orchard(&mut self, orchard: bool) { + self.fbb_ + .push_slot::(ShieldedNote::VT_ORCHARD, orchard, false); + } + #[inline] + pub fn add_excluded(&mut self, excluded: bool) { + self.fbb_ + .push_slot::(ShieldedNote::VT_EXCLUDED, excluded, false); + } + #[inline] + pub fn add_spent(&mut self, spent: bool) { + self.fbb_ + .push_slot::(ShieldedNote::VT_SPENT, spent, false); + } + #[inline] + pub fn new( + _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, + ) -> ShieldedNoteBuilder<'a, 'b> { + let start = _fbb.start_table(); + ShieldedNoteBuilder { + 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 ShieldedNote<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("ShieldedNote"); + ds.field("id", &self.id()); + ds.field("height", &self.height()); + ds.field("value", &self.value()); + ds.field("timestamp", &self.timestamp()); + ds.field("orchard", &self.orchard()); + ds.field("excluded", &self.excluded()); + ds.field("spent", &self.spent()); + ds.finish() + } + } + #[non_exhaustive] + #[derive(Debug, Clone, PartialEq)] + pub struct ShieldedNoteT { + pub id: u32, + pub height: u32, + pub value: u64, + pub timestamp: u32, + pub orchard: bool, + pub excluded: bool, + pub spent: bool, + } + impl Default for ShieldedNoteT { + fn default() -> Self { + Self { + id: 0, + height: 0, + value: 0, + timestamp: 0, + orchard: false, + excluded: false, + spent: false, + } + } + } + impl ShieldedNoteT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b>, + ) -> flatbuffers::WIPOffset> { + let id = self.id; + let height = self.height; + let value = self.value; + let timestamp = self.timestamp; + let orchard = self.orchard; + let excluded = self.excluded; + let spent = self.spent; + ShieldedNote::create( + _fbb, + &ShieldedNoteArgs { + id, + height, + value, + timestamp, + orchard, + excluded, + spent, + }, + ) + } + } + pub enum ShieldedNoteVecOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct ShieldedNoteVec<'a> { + pub _tab: flatbuffers::Table<'a>, + } + + impl<'a> flatbuffers::Follow<'a> for ShieldedNoteVec<'a> { + type Inner = ShieldedNoteVec<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } + } + } + + impl<'a> ShieldedNoteVec<'a> { + pub const VT_NOTES: flatbuffers::VOffsetT = 4; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + ShieldedNoteVec { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args ShieldedNoteVecArgs<'args>, + ) -> flatbuffers::WIPOffset> { + let mut builder = ShieldedNoteVecBuilder::new(_fbb); + if let Some(x) = args.notes { + builder.add_notes(x); + } + builder.finish() + } + + pub fn unpack(&self) -> ShieldedNoteVecT { + let notes = self.notes().map(|x| x.iter().map(|t| t.unpack()).collect()); + ShieldedNoteVecT { notes } + } + + #[inline] + pub fn notes( + &self, + ) -> Option>>> + { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab.get::>, + >>(ShieldedNoteVec::VT_NOTES, None) + } + } + } + + impl flatbuffers::Verifiable for ShieldedNoteVec<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, + pos: usize, + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>, + >>("notes", Self::VT_NOTES, false)? + .finish(); + Ok(()) + } + } + pub struct ShieldedNoteVecArgs<'a> { + pub notes: Option< + flatbuffers::WIPOffset< + flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>>, + >, + >, + } + impl<'a> Default for ShieldedNoteVecArgs<'a> { + #[inline] + fn default() -> Self { + ShieldedNoteVecArgs { notes: None } + } + } + + pub struct ShieldedNoteVecBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, + } + impl<'a: 'b, 'b> ShieldedNoteVecBuilder<'a, 'b> { + #[inline] + pub fn add_notes( + &mut self, + notes: flatbuffers::WIPOffset< + flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, + >, + ) { + self.fbb_ + .push_slot_always::>(ShieldedNoteVec::VT_NOTES, notes); + } + #[inline] + pub fn new( + _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, + ) -> ShieldedNoteVecBuilder<'a, 'b> { + let start = _fbb.start_table(); + ShieldedNoteVecBuilder { + 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 ShieldedNoteVec<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("ShieldedNoteVec"); + ds.field("notes", &self.notes()); + ds.finish() + } + } + #[non_exhaustive] + #[derive(Debug, Clone, PartialEq)] + pub struct ShieldedNoteVecT { + pub notes: Option>, + } + impl Default for ShieldedNoteVecT { + fn default() -> Self { + Self { notes: None } + } + } + impl ShieldedNoteVecT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b>, + ) -> flatbuffers::WIPOffset> { + let notes = self.notes.as_ref().map(|x| { + let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect(); + _fbb.create_vector(&w) + }); + ShieldedNoteVec::create(_fbb, &ShieldedNoteVecArgs { notes }) + } + } + pub enum ShieldedTxOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct ShieldedTx<'a> { + pub _tab: flatbuffers::Table<'a>, + } + + impl<'a> flatbuffers::Follow<'a> for ShieldedTx<'a> { + type Inner = ShieldedTx<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } + } + } + + impl<'a> ShieldedTx<'a> { + pub const VT_ID: flatbuffers::VOffsetT = 4; + pub const VT_TX_ID: flatbuffers::VOffsetT = 6; + pub const VT_HEIGHT: flatbuffers::VOffsetT = 8; + pub const VT_SHORT_TX_ID: flatbuffers::VOffsetT = 10; + pub const VT_TIMESTAMP: flatbuffers::VOffsetT = 12; + pub const VT_NAME: flatbuffers::VOffsetT = 14; + pub const VT_VALUE: flatbuffers::VOffsetT = 16; + pub const VT_ADDRESS: flatbuffers::VOffsetT = 18; + pub const VT_MEMO: flatbuffers::VOffsetT = 20; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + ShieldedTx { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args ShieldedTxArgs<'args>, + ) -> flatbuffers::WIPOffset> { + let mut builder = ShieldedTxBuilder::new(_fbb); + builder.add_value(args.value); + if let Some(x) = args.memo { + builder.add_memo(x); + } + if let Some(x) = args.address { + builder.add_address(x); + } + if let Some(x) = args.name { + builder.add_name(x); + } + builder.add_timestamp(args.timestamp); + if let Some(x) = args.short_tx_id { + builder.add_short_tx_id(x); + } + builder.add_height(args.height); + if let Some(x) = args.tx_id { + builder.add_tx_id(x); + } + builder.add_id(args.id); + builder.finish() + } + + pub fn unpack(&self) -> ShieldedTxT { + let id = self.id(); + let tx_id = self.tx_id().map(|x| x.to_string()); + let height = self.height(); + let short_tx_id = self.short_tx_id().map(|x| x.to_string()); + let timestamp = self.timestamp(); + let name = self.name().map(|x| x.to_string()); + let value = self.value(); + let address = self.address().map(|x| x.to_string()); + let memo = self.memo().map(|x| x.to_string()); + ShieldedTxT { + id, + tx_id, + height, + short_tx_id, + timestamp, + name, + value, + address, + memo, + } + } + + #[inline] + pub fn id(&self) -> u32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(ShieldedTx::VT_ID, Some(0)).unwrap() } + } + #[inline] + pub fn tx_id(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::>(ShieldedTx::VT_TX_ID, None) + } + } + #[inline] + pub fn height(&self) -> u32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(ShieldedTx::VT_HEIGHT, Some(0)) + .unwrap() + } + } + #[inline] + pub fn short_tx_id(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::>(ShieldedTx::VT_SHORT_TX_ID, None) + } + } + #[inline] + pub fn timestamp(&self) -> u32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(ShieldedTx::VT_TIMESTAMP, Some(0)) + .unwrap() + } + } + #[inline] + pub fn name(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::>(ShieldedTx::VT_NAME, None) + } + } + #[inline] + pub fn value(&self) -> u64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(ShieldedTx::VT_VALUE, Some(0)).unwrap() } + } + #[inline] + pub fn address(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::>(ShieldedTx::VT_ADDRESS, None) + } + } + #[inline] + pub fn memo(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::>(ShieldedTx::VT_MEMO, None) + } + } + } + + impl flatbuffers::Verifiable for ShieldedTx<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, + pos: usize, + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::("id", Self::VT_ID, false)? + .visit_field::>("tx_id", Self::VT_TX_ID, false)? + .visit_field::("height", Self::VT_HEIGHT, false)? + .visit_field::>( + "short_tx_id", + Self::VT_SHORT_TX_ID, + false, + )? + .visit_field::("timestamp", Self::VT_TIMESTAMP, false)? + .visit_field::>("name", Self::VT_NAME, false)? + .visit_field::("value", Self::VT_VALUE, false)? + .visit_field::>( + "address", + Self::VT_ADDRESS, + false, + )? + .visit_field::>("memo", Self::VT_MEMO, false)? + .finish(); + Ok(()) + } + } + pub struct ShieldedTxArgs<'a> { + pub id: u32, + pub tx_id: Option>, + pub height: u32, + pub short_tx_id: Option>, + pub timestamp: u32, + pub name: Option>, + pub value: u64, + pub address: Option>, + pub memo: Option>, + } + impl<'a> Default for ShieldedTxArgs<'a> { + #[inline] + fn default() -> Self { + ShieldedTxArgs { + id: 0, + tx_id: None, + height: 0, + short_tx_id: None, + timestamp: 0, + name: None, + value: 0, + address: None, + memo: None, + } + } + } + + pub struct ShieldedTxBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, + } + impl<'a: 'b, 'b> ShieldedTxBuilder<'a, 'b> { + #[inline] + pub fn add_id(&mut self, id: u32) { + self.fbb_.push_slot::(ShieldedTx::VT_ID, id, 0); + } + #[inline] + pub fn add_tx_id(&mut self, tx_id: flatbuffers::WIPOffset<&'b str>) { + self.fbb_ + .push_slot_always::>(ShieldedTx::VT_TX_ID, tx_id); + } + #[inline] + pub fn add_height(&mut self, height: u32) { + self.fbb_.push_slot::(ShieldedTx::VT_HEIGHT, height, 0); + } + #[inline] + pub fn add_short_tx_id(&mut self, short_tx_id: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>( + ShieldedTx::VT_SHORT_TX_ID, + short_tx_id, + ); + } + #[inline] + pub fn add_timestamp(&mut self, timestamp: u32) { + self.fbb_ + .push_slot::(ShieldedTx::VT_TIMESTAMP, timestamp, 0); + } + #[inline] + pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { + self.fbb_ + .push_slot_always::>(ShieldedTx::VT_NAME, name); + } + #[inline] + pub fn add_value(&mut self, value: u64) { + self.fbb_.push_slot::(ShieldedTx::VT_VALUE, value, 0); + } + #[inline] + pub fn add_address(&mut self, address: flatbuffers::WIPOffset<&'b str>) { + self.fbb_ + .push_slot_always::>(ShieldedTx::VT_ADDRESS, address); + } + #[inline] + pub fn add_memo(&mut self, memo: flatbuffers::WIPOffset<&'b str>) { + self.fbb_ + .push_slot_always::>(ShieldedTx::VT_MEMO, memo); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> ShieldedTxBuilder<'a, 'b> { + let start = _fbb.start_table(); + ShieldedTxBuilder { + 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 ShieldedTx<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("ShieldedTx"); + ds.field("id", &self.id()); + ds.field("tx_id", &self.tx_id()); + ds.field("height", &self.height()); + ds.field("short_tx_id", &self.short_tx_id()); + ds.field("timestamp", &self.timestamp()); + ds.field("name", &self.name()); + ds.field("value", &self.value()); + ds.field("address", &self.address()); + ds.field("memo", &self.memo()); + ds.finish() + } + } + #[non_exhaustive] + #[derive(Debug, Clone, PartialEq)] + pub struct ShieldedTxT { + pub id: u32, + pub tx_id: Option, + pub height: u32, + pub short_tx_id: Option, + pub timestamp: u32, + pub name: Option, + pub value: u64, + pub address: Option, + pub memo: Option, + } + impl Default for ShieldedTxT { + fn default() -> Self { + Self { + id: 0, + tx_id: None, + height: 0, + short_tx_id: None, + timestamp: 0, + name: None, + value: 0, + address: None, + memo: None, + } + } + } + impl ShieldedTxT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b>, + ) -> flatbuffers::WIPOffset> { + let id = self.id; + let tx_id = self.tx_id.as_ref().map(|x| _fbb.create_string(x)); + let height = self.height; + let short_tx_id = self.short_tx_id.as_ref().map(|x| _fbb.create_string(x)); + let timestamp = self.timestamp; + let name = self.name.as_ref().map(|x| _fbb.create_string(x)); + let value = self.value; + let address = self.address.as_ref().map(|x| _fbb.create_string(x)); + let memo = self.memo.as_ref().map(|x| _fbb.create_string(x)); + ShieldedTx::create( + _fbb, + &ShieldedTxArgs { + id, + tx_id, + height, + short_tx_id, + timestamp, + name, + value, + address, + memo, + }, + ) + } + } + pub enum ShieldedTxVecOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct ShieldedTxVec<'a> { + pub _tab: flatbuffers::Table<'a>, + } + + impl<'a> flatbuffers::Follow<'a> for ShieldedTxVec<'a> { + type Inner = ShieldedTxVec<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } + } + } + + impl<'a> ShieldedTxVec<'a> { + pub const VT_TXS: flatbuffers::VOffsetT = 4; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + ShieldedTxVec { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args ShieldedTxVecArgs<'args>, + ) -> flatbuffers::WIPOffset> { + let mut builder = ShieldedTxVecBuilder::new(_fbb); + if let Some(x) = args.txs { + builder.add_txs(x); + } + builder.finish() + } + + pub fn unpack(&self) -> ShieldedTxVecT { + let txs = self.txs().map(|x| x.iter().map(|t| t.unpack()).collect()); + ShieldedTxVecT { txs } + } + + #[inline] + pub fn txs( + &self, + ) -> Option>>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab.get::>, + >>(ShieldedTxVec::VT_TXS, None) + } + } + } + + impl flatbuffers::Verifiable for ShieldedTxVec<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, + pos: usize, + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>, + >>("txs", Self::VT_TXS, false)? + .finish(); + Ok(()) + } + } + pub struct ShieldedTxVecArgs<'a> { + pub txs: Option< + flatbuffers::WIPOffset< + flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>>, + >, + >, + } + impl<'a> Default for ShieldedTxVecArgs<'a> { + #[inline] + fn default() -> Self { + ShieldedTxVecArgs { txs: None } + } + } + + pub struct ShieldedTxVecBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, + } + impl<'a: 'b, 'b> ShieldedTxVecBuilder<'a, 'b> { + #[inline] + pub fn add_txs( + &mut self, + txs: flatbuffers::WIPOffset< + flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, + >, + ) { + self.fbb_ + .push_slot_always::>(ShieldedTxVec::VT_TXS, txs); + } + #[inline] + pub fn new( + _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, + ) -> ShieldedTxVecBuilder<'a, 'b> { + let start = _fbb.start_table(); + ShieldedTxVecBuilder { + 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 ShieldedTxVec<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("ShieldedTxVec"); + ds.field("txs", &self.txs()); + ds.finish() + } + } + #[non_exhaustive] + #[derive(Debug, Clone, PartialEq)] + pub struct ShieldedTxVecT { + pub txs: Option>, + } + impl Default for ShieldedTxVecT { + fn default() -> Self { + Self { txs: None } + } + } + impl ShieldedTxVecT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b>, + ) -> flatbuffers::WIPOffset> { + let txs = self.txs.as_ref().map(|x| { + let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect(); + _fbb.create_vector(&w) + }); + ShieldedTxVec::create(_fbb, &ShieldedTxVecArgs { txs }) + } + } + pub enum MessageOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct Message<'a> { + pub _tab: flatbuffers::Table<'a>, + } + + impl<'a> flatbuffers::Follow<'a> for Message<'a> { + type Inner = Message<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } + } + } + + impl<'a> Message<'a> { + pub const VT_ID_MSG: flatbuffers::VOffsetT = 4; + pub const VT_ID_TX: flatbuffers::VOffsetT = 6; + pub const VT_HEIGHT: flatbuffers::VOffsetT = 8; + pub const VT_TIMESTAMP: flatbuffers::VOffsetT = 10; + pub const VT_FROM: flatbuffers::VOffsetT = 12; + pub const VT_TO: flatbuffers::VOffsetT = 14; + pub const VT_SUBJECT: flatbuffers::VOffsetT = 16; + pub const VT_BODY: flatbuffers::VOffsetT = 18; + pub const VT_READ: flatbuffers::VOffsetT = 20; + pub const VT_INCOMING: flatbuffers::VOffsetT = 22; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + Message { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args MessageArgs<'args>, + ) -> flatbuffers::WIPOffset> { + let mut builder = MessageBuilder::new(_fbb); + if let Some(x) = args.body { + builder.add_body(x); + } + if let Some(x) = args.subject { + builder.add_subject(x); + } + if let Some(x) = args.to { + builder.add_to(x); + } + if let Some(x) = args.from { + builder.add_from(x); + } + builder.add_timestamp(args.timestamp); + builder.add_height(args.height); + builder.add_id_tx(args.id_tx); + builder.add_id_msg(args.id_msg); + builder.add_incoming(args.incoming); + builder.add_read(args.read); + builder.finish() + } + + pub fn unpack(&self) -> MessageT { + let id_msg = self.id_msg(); + let id_tx = self.id_tx(); + let height = self.height(); + let timestamp = self.timestamp(); + let from = self.from().map(|x| x.to_string()); + let to = self.to().map(|x| x.to_string()); + let subject = self.subject().map(|x| x.to_string()); + let body = self.body().map(|x| x.to_string()); + let read = self.read(); + let incoming = self.incoming(); + MessageT { + id_msg, + id_tx, + height, + timestamp, + from, + to, + subject, + body, + read, + incoming, + } + } + + #[inline] + pub fn id_msg(&self) -> u32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Message::VT_ID_MSG, Some(0)).unwrap() } + } + #[inline] + pub fn id_tx(&self) -> u32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Message::VT_ID_TX, Some(0)).unwrap() } + } + #[inline] + pub fn height(&self) -> u32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Message::VT_HEIGHT, Some(0)).unwrap() } + } + #[inline] + pub fn timestamp(&self) -> u32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(Message::VT_TIMESTAMP, Some(0)) + .unwrap() + } + } + #[inline] + pub fn from(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::>(Message::VT_FROM, None) + } + } + #[inline] + pub fn to(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::>(Message::VT_TO, None) + } + } + #[inline] + pub fn subject(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::>(Message::VT_SUBJECT, None) + } + } + #[inline] + pub fn body(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::>(Message::VT_BODY, None) + } + } + #[inline] + pub fn read(&self) -> bool { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(Message::VT_READ, Some(false)) + .unwrap() + } + } + #[inline] + pub fn incoming(&self) -> bool { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(Message::VT_INCOMING, Some(false)) + .unwrap() + } + } + } + + impl flatbuffers::Verifiable for Message<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, + pos: usize, + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::("id_msg", Self::VT_ID_MSG, false)? + .visit_field::("id_tx", Self::VT_ID_TX, false)? + .visit_field::("height", Self::VT_HEIGHT, false)? + .visit_field::("timestamp", Self::VT_TIMESTAMP, false)? + .visit_field::>("from", Self::VT_FROM, false)? + .visit_field::>("to", Self::VT_TO, false)? + .visit_field::>( + "subject", + Self::VT_SUBJECT, + false, + )? + .visit_field::>("body", Self::VT_BODY, false)? + .visit_field::("read", Self::VT_READ, false)? + .visit_field::("incoming", Self::VT_INCOMING, false)? + .finish(); + Ok(()) + } + } + pub struct MessageArgs<'a> { + pub id_msg: u32, + pub id_tx: u32, + pub height: u32, + pub timestamp: u32, + pub from: Option>, + pub to: Option>, + pub subject: Option>, + pub body: Option>, + pub read: bool, + pub incoming: bool, + } + impl<'a> Default for MessageArgs<'a> { + #[inline] + fn default() -> Self { + MessageArgs { + id_msg: 0, + id_tx: 0, + height: 0, + timestamp: 0, + from: None, + to: None, + subject: None, + body: None, + read: false, + incoming: false, + } + } + } + + pub struct MessageBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, + } + impl<'a: 'b, 'b> MessageBuilder<'a, 'b> { + #[inline] + pub fn add_id_msg(&mut self, id_msg: u32) { + self.fbb_.push_slot::(Message::VT_ID_MSG, id_msg, 0); + } + #[inline] + pub fn add_id_tx(&mut self, id_tx: u32) { + self.fbb_.push_slot::(Message::VT_ID_TX, id_tx, 0); + } + #[inline] + pub fn add_height(&mut self, height: u32) { + self.fbb_.push_slot::(Message::VT_HEIGHT, height, 0); + } + #[inline] + pub fn add_timestamp(&mut self, timestamp: u32) { + self.fbb_ + .push_slot::(Message::VT_TIMESTAMP, timestamp, 0); + } + #[inline] + pub fn add_from(&mut self, from: flatbuffers::WIPOffset<&'b str>) { + self.fbb_ + .push_slot_always::>(Message::VT_FROM, from); + } + #[inline] + pub fn add_to(&mut self, to: flatbuffers::WIPOffset<&'b str>) { + self.fbb_ + .push_slot_always::>(Message::VT_TO, to); + } + #[inline] + pub fn add_subject(&mut self, subject: flatbuffers::WIPOffset<&'b str>) { + self.fbb_ + .push_slot_always::>(Message::VT_SUBJECT, subject); + } + #[inline] + pub fn add_body(&mut self, body: flatbuffers::WIPOffset<&'b str>) { + self.fbb_ + .push_slot_always::>(Message::VT_BODY, body); + } + #[inline] + pub fn add_read(&mut self, read: bool) { + self.fbb_.push_slot::(Message::VT_READ, read, false); + } + #[inline] + pub fn add_incoming(&mut self, incoming: bool) { + self.fbb_ + .push_slot::(Message::VT_INCOMING, incoming, false); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> MessageBuilder<'a, 'b> { + let start = _fbb.start_table(); + MessageBuilder { + 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 Message<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("Message"); + ds.field("id_msg", &self.id_msg()); + ds.field("id_tx", &self.id_tx()); + ds.field("height", &self.height()); + ds.field("timestamp", &self.timestamp()); + ds.field("from", &self.from()); + ds.field("to", &self.to()); + ds.field("subject", &self.subject()); + ds.field("body", &self.body()); + ds.field("read", &self.read()); + ds.field("incoming", &self.incoming()); + ds.finish() + } + } + #[non_exhaustive] + #[derive(Debug, Clone, PartialEq)] + pub struct MessageT { + pub id_msg: u32, + pub id_tx: u32, + pub height: u32, + pub timestamp: u32, + pub from: Option, + pub to: Option, + pub subject: Option, + pub body: Option, + pub read: bool, + pub incoming: bool, + } + impl Default for MessageT { + fn default() -> Self { + Self { + id_msg: 0, + id_tx: 0, + height: 0, + timestamp: 0, + from: None, + to: None, + subject: None, + body: None, + read: false, + incoming: false, + } + } + } + impl MessageT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b>, + ) -> flatbuffers::WIPOffset> { + let id_msg = self.id_msg; + let id_tx = self.id_tx; + let height = self.height; + let timestamp = self.timestamp; + let from = self.from.as_ref().map(|x| _fbb.create_string(x)); + let to = self.to.as_ref().map(|x| _fbb.create_string(x)); + let subject = self.subject.as_ref().map(|x| _fbb.create_string(x)); + let body = self.body.as_ref().map(|x| _fbb.create_string(x)); + let read = self.read; + let incoming = self.incoming; + Message::create( + _fbb, + &MessageArgs { + id_msg, + id_tx, + height, + timestamp, + from, + to, + subject, + body, + read, + incoming, + }, + ) + } + } + pub enum MessageVecOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct MessageVec<'a> { + pub _tab: flatbuffers::Table<'a>, + } + + impl<'a> flatbuffers::Follow<'a> for MessageVec<'a> { + type Inner = MessageVec<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } + } + } + + impl<'a> MessageVec<'a> { + pub const VT_MESSAGES: flatbuffers::VOffsetT = 4; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + MessageVec { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args MessageVecArgs<'args>, + ) -> flatbuffers::WIPOffset> { + let mut builder = MessageVecBuilder::new(_fbb); + if let Some(x) = args.messages { + builder.add_messages(x); + } + builder.finish() + } + + pub fn unpack(&self) -> MessageVecT { + let messages = self + .messages() + .map(|x| x.iter().map(|t| t.unpack()).collect()); + MessageVecT { messages } + } + + #[inline] + pub fn messages( + &self, + ) -> Option>>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab.get::>, + >>(MessageVec::VT_MESSAGES, None) + } + } + } + + impl flatbuffers::Verifiable for MessageVec<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, + pos: usize, + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>, + >>("messages", Self::VT_MESSAGES, false)? + .finish(); + Ok(()) + } + } + pub struct MessageVecArgs<'a> { + pub messages: Option< + flatbuffers::WIPOffset< + flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>>, + >, + >, + } + impl<'a> Default for MessageVecArgs<'a> { + #[inline] + fn default() -> Self { + MessageVecArgs { messages: None } + } + } + + pub struct MessageVecBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, + } + impl<'a: 'b, 'b> MessageVecBuilder<'a, 'b> { + #[inline] + pub fn add_messages( + &mut self, + messages: flatbuffers::WIPOffset< + flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, + >, + ) { + self.fbb_ + .push_slot_always::>(MessageVec::VT_MESSAGES, messages); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> MessageVecBuilder<'a, 'b> { + let start = _fbb.start_table(); + MessageVecBuilder { + 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 MessageVec<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("MessageVec"); + ds.field("messages", &self.messages()); + ds.finish() + } + } + #[non_exhaustive] + #[derive(Debug, Clone, PartialEq)] + pub struct MessageVecT { + pub messages: Option>, + } + impl Default for MessageVecT { + fn default() -> Self { + Self { messages: None } + } + } + impl MessageVecT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b>, + ) -> flatbuffers::WIPOffset> { + let messages = self.messages.as_ref().map(|x| { + let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect(); + _fbb.create_vector(&w) + }); + MessageVec::create(_fbb, &MessageVecArgs { messages }) + } + } + pub enum PrevNextOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct PrevNext<'a> { + pub _tab: flatbuffers::Table<'a>, + } + + impl<'a> flatbuffers::Follow<'a> for PrevNext<'a> { + type Inner = PrevNext<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } + } + } + + impl<'a> PrevNext<'a> { + pub const VT_PREV: flatbuffers::VOffsetT = 4; + pub const VT_NEXT: flatbuffers::VOffsetT = 6; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + PrevNext { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args PrevNextArgs, + ) -> flatbuffers::WIPOffset> { + let mut builder = PrevNextBuilder::new(_fbb); + builder.add_next(args.next); + builder.add_prev(args.prev); + builder.finish() + } + + pub fn unpack(&self) -> PrevNextT { + let prev = self.prev(); + let next = self.next(); + PrevNextT { prev, next } + } + + #[inline] + pub fn prev(&self) -> u32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(PrevNext::VT_PREV, Some(0)).unwrap() } + } + #[inline] + pub fn next(&self) -> u32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(PrevNext::VT_NEXT, Some(0)).unwrap() } + } + } + + impl flatbuffers::Verifiable for PrevNext<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, + pos: usize, + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::("prev", Self::VT_PREV, false)? + .visit_field::("next", Self::VT_NEXT, false)? + .finish(); + Ok(()) + } + } + pub struct PrevNextArgs { + pub prev: u32, + pub next: u32, + } + impl<'a> Default for PrevNextArgs { + #[inline] + fn default() -> Self { + PrevNextArgs { prev: 0, next: 0 } + } + } + + pub struct PrevNextBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, + } + impl<'a: 'b, 'b> PrevNextBuilder<'a, 'b> { + #[inline] + pub fn add_prev(&mut self, prev: u32) { + self.fbb_.push_slot::(PrevNext::VT_PREV, prev, 0); + } + #[inline] + pub fn add_next(&mut self, next: u32) { + self.fbb_.push_slot::(PrevNext::VT_NEXT, next, 0); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> PrevNextBuilder<'a, 'b> { + let start = _fbb.start_table(); + PrevNextBuilder { + 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 PrevNext<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("PrevNext"); + ds.field("prev", &self.prev()); + ds.field("next", &self.next()); + ds.finish() + } + } + #[non_exhaustive] + #[derive(Debug, Clone, PartialEq)] + pub struct PrevNextT { + pub prev: u32, + pub next: u32, + } + impl Default for PrevNextT { + fn default() -> Self { + Self { prev: 0, next: 0 } + } + } + impl PrevNextT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b>, + ) -> flatbuffers::WIPOffset> { + let prev = self.prev; + let next = self.next; + PrevNext::create(_fbb, &PrevNextArgs { prev, next }) + } + } + pub enum SendTemplateOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct SendTemplate<'a> { + pub _tab: flatbuffers::Table<'a>, + } + + impl<'a> flatbuffers::Follow<'a> for SendTemplate<'a> { + type Inner = SendTemplate<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } + } + } + + impl<'a> SendTemplate<'a> { + pub const VT_ID: flatbuffers::VOffsetT = 4; + pub const VT_TITLE: flatbuffers::VOffsetT = 6; + pub const VT_ADDRESS: flatbuffers::VOffsetT = 8; + pub const VT_AMOUNT: flatbuffers::VOffsetT = 10; + pub const VT_FIAT_AMOUNT: flatbuffers::VOffsetT = 12; + pub const VT_FEE_INCLUDED: flatbuffers::VOffsetT = 14; + pub const VT_FIAT: flatbuffers::VOffsetT = 16; + pub const VT_INCLUDE_REPLY_TO: flatbuffers::VOffsetT = 18; + pub const VT_SUBJECT: flatbuffers::VOffsetT = 20; + pub const VT_BODY: flatbuffers::VOffsetT = 22; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + SendTemplate { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args SendTemplateArgs<'args>, + ) -> flatbuffers::WIPOffset> { + let mut builder = SendTemplateBuilder::new(_fbb); + builder.add_fiat_amount(args.fiat_amount); + builder.add_amount(args.amount); + if let Some(x) = args.body { + builder.add_body(x); + } + if let Some(x) = args.subject { + builder.add_subject(x); + } + if let Some(x) = args.fiat { + builder.add_fiat(x); + } + if let Some(x) = args.address { + builder.add_address(x); + } + if let Some(x) = args.title { + builder.add_title(x); + } + builder.add_id(args.id); + builder.add_include_reply_to(args.include_reply_to); + builder.add_fee_included(args.fee_included); + builder.finish() + } + + pub fn unpack(&self) -> SendTemplateT { + let id = self.id(); + let title = self.title().map(|x| x.to_string()); + let address = self.address().map(|x| x.to_string()); + let amount = self.amount(); + let fiat_amount = self.fiat_amount(); + let fee_included = self.fee_included(); + let fiat = self.fiat().map(|x| x.to_string()); + let include_reply_to = self.include_reply_to(); + let subject = self.subject().map(|x| x.to_string()); + let body = self.body().map(|x| x.to_string()); + SendTemplateT { + id, + title, + address, + amount, + fiat_amount, + fee_included, + fiat, + include_reply_to, + subject, + body, + } + } + + #[inline] + pub fn id(&self) -> u32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(SendTemplate::VT_ID, Some(0)).unwrap() } + } + #[inline] + pub fn title(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::>(SendTemplate::VT_TITLE, None) + } + } + #[inline] + pub fn address(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::>(SendTemplate::VT_ADDRESS, None) + } + } + #[inline] + pub fn amount(&self) -> u64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(SendTemplate::VT_AMOUNT, Some(0)) + .unwrap() + } + } + #[inline] + pub fn fiat_amount(&self) -> f64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(SendTemplate::VT_FIAT_AMOUNT, Some(0.0)) + .unwrap() + } + } + #[inline] + pub fn fee_included(&self) -> bool { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(SendTemplate::VT_FEE_INCLUDED, Some(false)) + .unwrap() + } + } + #[inline] + pub fn fiat(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::>(SendTemplate::VT_FIAT, None) + } + } + #[inline] + pub fn include_reply_to(&self) -> bool { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(SendTemplate::VT_INCLUDE_REPLY_TO, Some(false)) + .unwrap() + } + } + #[inline] + pub fn subject(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::>(SendTemplate::VT_SUBJECT, None) + } + } + #[inline] + pub fn body(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::>(SendTemplate::VT_BODY, None) + } + } + } + + impl flatbuffers::Verifiable for SendTemplate<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, + pos: usize, + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::("id", Self::VT_ID, false)? + .visit_field::>("title", Self::VT_TITLE, false)? + .visit_field::>( + "address", + Self::VT_ADDRESS, + false, + )? + .visit_field::("amount", Self::VT_AMOUNT, false)? + .visit_field::("fiat_amount", Self::VT_FIAT_AMOUNT, false)? + .visit_field::("fee_included", Self::VT_FEE_INCLUDED, false)? + .visit_field::>("fiat", Self::VT_FIAT, false)? + .visit_field::("include_reply_to", Self::VT_INCLUDE_REPLY_TO, false)? + .visit_field::>( + "subject", + Self::VT_SUBJECT, + false, + )? + .visit_field::>("body", Self::VT_BODY, false)? + .finish(); + Ok(()) + } + } + pub struct SendTemplateArgs<'a> { + pub id: u32, + pub title: Option>, + pub address: Option>, + pub amount: u64, + pub fiat_amount: f64, + pub fee_included: bool, + pub fiat: Option>, + pub include_reply_to: bool, + pub subject: Option>, + pub body: Option>, + } + impl<'a> Default for SendTemplateArgs<'a> { + #[inline] + fn default() -> Self { + SendTemplateArgs { + id: 0, + title: None, + address: None, + amount: 0, + fiat_amount: 0.0, + fee_included: false, + fiat: None, + include_reply_to: false, + subject: None, + body: None, + } + } + } + + pub struct SendTemplateBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, + } + impl<'a: 'b, 'b> SendTemplateBuilder<'a, 'b> { + #[inline] + pub fn add_id(&mut self, id: u32) { + self.fbb_.push_slot::(SendTemplate::VT_ID, id, 0); + } + #[inline] + pub fn add_title(&mut self, title: flatbuffers::WIPOffset<&'b str>) { + self.fbb_ + .push_slot_always::>(SendTemplate::VT_TITLE, title); + } + #[inline] + pub fn add_address(&mut self, address: flatbuffers::WIPOffset<&'b str>) { + self.fbb_ + .push_slot_always::>(SendTemplate::VT_ADDRESS, address); + } + #[inline] + pub fn add_amount(&mut self, amount: u64) { + self.fbb_ + .push_slot::(SendTemplate::VT_AMOUNT, amount, 0); + } + #[inline] + pub fn add_fiat_amount(&mut self, fiat_amount: f64) { + self.fbb_ + .push_slot::(SendTemplate::VT_FIAT_AMOUNT, fiat_amount, 0.0); + } + #[inline] + pub fn add_fee_included(&mut self, fee_included: bool) { + self.fbb_ + .push_slot::(SendTemplate::VT_FEE_INCLUDED, fee_included, false); + } + #[inline] + pub fn add_fiat(&mut self, fiat: flatbuffers::WIPOffset<&'b str>) { + self.fbb_ + .push_slot_always::>(SendTemplate::VT_FIAT, fiat); + } + #[inline] + pub fn add_include_reply_to(&mut self, include_reply_to: bool) { + self.fbb_ + .push_slot::(SendTemplate::VT_INCLUDE_REPLY_TO, include_reply_to, false); + } + #[inline] + pub fn add_subject(&mut self, subject: flatbuffers::WIPOffset<&'b str>) { + self.fbb_ + .push_slot_always::>(SendTemplate::VT_SUBJECT, subject); + } + #[inline] + pub fn add_body(&mut self, body: flatbuffers::WIPOffset<&'b str>) { + self.fbb_ + .push_slot_always::>(SendTemplate::VT_BODY, body); + } + #[inline] + pub fn new( + _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, + ) -> SendTemplateBuilder<'a, 'b> { + let start = _fbb.start_table(); + SendTemplateBuilder { + 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 SendTemplate<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("SendTemplate"); + ds.field("id", &self.id()); + ds.field("title", &self.title()); + ds.field("address", &self.address()); + ds.field("amount", &self.amount()); + ds.field("fiat_amount", &self.fiat_amount()); + ds.field("fee_included", &self.fee_included()); + ds.field("fiat", &self.fiat()); + ds.field("include_reply_to", &self.include_reply_to()); + ds.field("subject", &self.subject()); + ds.field("body", &self.body()); + ds.finish() + } + } + #[non_exhaustive] + #[derive(Debug, Clone, PartialEq)] + pub struct SendTemplateT { + pub id: u32, + pub title: Option, + pub address: Option, + pub amount: u64, + pub fiat_amount: f64, + pub fee_included: bool, + pub fiat: Option, + pub include_reply_to: bool, + pub subject: Option, + pub body: Option, + } + impl Default for SendTemplateT { + fn default() -> Self { + Self { + id: 0, + title: None, + address: None, + amount: 0, + fiat_amount: 0.0, + fee_included: false, + fiat: None, + include_reply_to: false, + subject: None, + body: None, + } + } + } + impl SendTemplateT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b>, + ) -> flatbuffers::WIPOffset> { + let id = self.id; + let title = self.title.as_ref().map(|x| _fbb.create_string(x)); + let address = self.address.as_ref().map(|x| _fbb.create_string(x)); + let amount = self.amount; + let fiat_amount = self.fiat_amount; + let fee_included = self.fee_included; + let fiat = self.fiat.as_ref().map(|x| _fbb.create_string(x)); + let include_reply_to = self.include_reply_to; + let subject = self.subject.as_ref().map(|x| _fbb.create_string(x)); + let body = self.body.as_ref().map(|x| _fbb.create_string(x)); + SendTemplate::create( + _fbb, + &SendTemplateArgs { + id, + title, + address, + amount, + fiat_amount, + fee_included, + fiat, + include_reply_to, + subject, + body, + }, + ) + } + } + pub enum SendTemplateVecOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct SendTemplateVec<'a> { + pub _tab: flatbuffers::Table<'a>, + } + + impl<'a> flatbuffers::Follow<'a> for SendTemplateVec<'a> { + type Inner = SendTemplateVec<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } + } + } + + impl<'a> SendTemplateVec<'a> { + pub const VT_TEMPLATES: flatbuffers::VOffsetT = 4; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + SendTemplateVec { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args SendTemplateVecArgs<'args>, + ) -> flatbuffers::WIPOffset> { + let mut builder = SendTemplateVecBuilder::new(_fbb); + if let Some(x) = args.templates { + builder.add_templates(x); + } + builder.finish() + } + + pub fn unpack(&self) -> SendTemplateVecT { + let templates = self + .templates() + .map(|x| x.iter().map(|t| t.unpack()).collect()); + SendTemplateVecT { templates } + } + + #[inline] + pub fn templates( + &self, + ) -> Option>>> + { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab.get::>, + >>(SendTemplateVec::VT_TEMPLATES, None) + } + } + } + + impl flatbuffers::Verifiable for SendTemplateVec<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, + pos: usize, + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>, + >>("templates", Self::VT_TEMPLATES, false)? + .finish(); + Ok(()) + } + } + pub struct SendTemplateVecArgs<'a> { + pub templates: Option< + flatbuffers::WIPOffset< + flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>>, + >, + >, + } + impl<'a> Default for SendTemplateVecArgs<'a> { + #[inline] + fn default() -> Self { + SendTemplateVecArgs { templates: None } + } + } + + pub struct SendTemplateVecBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, + } + impl<'a: 'b, 'b> SendTemplateVecBuilder<'a, 'b> { + #[inline] + pub fn add_templates( + &mut self, + templates: flatbuffers::WIPOffset< + flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, + >, + ) { + self.fbb_.push_slot_always::>( + SendTemplateVec::VT_TEMPLATES, + templates, + ); + } + #[inline] + pub fn new( + _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, + ) -> SendTemplateVecBuilder<'a, 'b> { + let start = _fbb.start_table(); + SendTemplateVecBuilder { + 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 SendTemplateVec<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("SendTemplateVec"); + ds.field("templates", &self.templates()); + ds.finish() + } + } + #[non_exhaustive] + #[derive(Debug, Clone, PartialEq)] + pub struct SendTemplateVecT { + pub templates: Option>, + } + impl Default for SendTemplateVecT { + fn default() -> Self { + Self { templates: None } + } + } + impl SendTemplateVecT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b>, + ) -> flatbuffers::WIPOffset> { + let templates = self.templates.as_ref().map(|x| { + let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect(); + _fbb.create_vector(&w) + }); + SendTemplateVec::create(_fbb, &SendTemplateVecArgs { templates }) + } + } + pub enum ContactOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct Contact<'a> { + pub _tab: flatbuffers::Table<'a>, + } + + impl<'a> flatbuffers::Follow<'a> for Contact<'a> { + type Inner = Contact<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } + } + } + + impl<'a> Contact<'a> { + pub const VT_ID: flatbuffers::VOffsetT = 4; + pub const VT_NAME: flatbuffers::VOffsetT = 6; + pub const VT_ADDRESS: flatbuffers::VOffsetT = 8; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + Contact { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args ContactArgs<'args>, + ) -> flatbuffers::WIPOffset> { + let mut builder = ContactBuilder::new(_fbb); + if let Some(x) = args.address { + builder.add_address(x); + } + if let Some(x) = args.name { + builder.add_name(x); + } + builder.add_id(args.id); + builder.finish() + } + + pub fn unpack(&self) -> ContactT { + let id = self.id(); + let name = self.name().map(|x| x.to_string()); + let address = self.address().map(|x| x.to_string()); + ContactT { id, name, address } + } + + #[inline] + pub fn id(&self) -> u32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Contact::VT_ID, Some(0)).unwrap() } + } + #[inline] + pub fn name(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::>(Contact::VT_NAME, None) + } + } + #[inline] + pub fn address(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::>(Contact::VT_ADDRESS, None) + } + } + } + + impl flatbuffers::Verifiable for Contact<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, + pos: usize, + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::("id", Self::VT_ID, false)? + .visit_field::>("name", Self::VT_NAME, false)? + .visit_field::>( + "address", + Self::VT_ADDRESS, + false, + )? + .finish(); + Ok(()) + } + } + pub struct ContactArgs<'a> { + pub id: u32, + pub name: Option>, + pub address: Option>, + } + impl<'a> Default for ContactArgs<'a> { + #[inline] + fn default() -> Self { + ContactArgs { + id: 0, + name: None, + address: None, + } + } + } + + pub struct ContactBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, + } + impl<'a: 'b, 'b> ContactBuilder<'a, 'b> { + #[inline] + pub fn add_id(&mut self, id: u32) { + self.fbb_.push_slot::(Contact::VT_ID, id, 0); + } + #[inline] + pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { + self.fbb_ + .push_slot_always::>(Contact::VT_NAME, name); + } + #[inline] + pub fn add_address(&mut self, address: flatbuffers::WIPOffset<&'b str>) { + self.fbb_ + .push_slot_always::>(Contact::VT_ADDRESS, address); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> ContactBuilder<'a, 'b> { + let start = _fbb.start_table(); + ContactBuilder { + 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 Contact<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("Contact"); + ds.field("id", &self.id()); + ds.field("name", &self.name()); + ds.field("address", &self.address()); + ds.finish() + } + } + #[non_exhaustive] + #[derive(Debug, Clone, PartialEq)] + pub struct ContactT { + pub id: u32, + pub name: Option, + pub address: Option, + } + impl Default for ContactT { + fn default() -> Self { + Self { + id: 0, + name: None, + address: None, + } + } + } + impl ContactT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b>, + ) -> flatbuffers::WIPOffset> { + let id = self.id; + let name = self.name.as_ref().map(|x| _fbb.create_string(x)); + let address = self.address.as_ref().map(|x| _fbb.create_string(x)); + Contact::create(_fbb, &ContactArgs { id, name, address }) + } + } + pub enum ContactVecOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct ContactVec<'a> { + pub _tab: flatbuffers::Table<'a>, + } + + impl<'a> flatbuffers::Follow<'a> for ContactVec<'a> { + type Inner = ContactVec<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } + } + } + + impl<'a> ContactVec<'a> { + pub const VT_CONTACTS: flatbuffers::VOffsetT = 4; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + ContactVec { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args ContactVecArgs<'args>, + ) -> flatbuffers::WIPOffset> { + let mut builder = ContactVecBuilder::new(_fbb); + if let Some(x) = args.contacts { + builder.add_contacts(x); + } + builder.finish() + } + + pub fn unpack(&self) -> ContactVecT { + let contacts = self + .contacts() + .map(|x| x.iter().map(|t| t.unpack()).collect()); + ContactVecT { contacts } + } + + #[inline] + pub fn contacts( + &self, + ) -> Option>>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab.get::>, + >>(ContactVec::VT_CONTACTS, None) + } + } + } + + impl flatbuffers::Verifiable for ContactVec<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, + pos: usize, + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>, + >>("contacts", Self::VT_CONTACTS, false)? + .finish(); + Ok(()) + } + } + pub struct ContactVecArgs<'a> { + pub contacts: Option< + flatbuffers::WIPOffset< + flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>>, + >, + >, + } + impl<'a> Default for ContactVecArgs<'a> { + #[inline] + fn default() -> Self { + ContactVecArgs { contacts: None } + } + } + + pub struct ContactVecBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, + } + impl<'a: 'b, 'b> ContactVecBuilder<'a, 'b> { + #[inline] + pub fn add_contacts( + &mut self, + contacts: flatbuffers::WIPOffset< + flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, + >, + ) { + self.fbb_ + .push_slot_always::>(ContactVec::VT_CONTACTS, contacts); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> ContactVecBuilder<'a, 'b> { + let start = _fbb.start_table(); + ContactVecBuilder { + 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 ContactVec<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("ContactVec"); + ds.field("contacts", &self.contacts()); + ds.finish() + } + } + #[non_exhaustive] + #[derive(Debug, Clone, PartialEq)] + pub struct ContactVecT { + pub contacts: Option>, + } + impl Default for ContactVecT { + fn default() -> Self { + Self { contacts: None } + } + } + impl ContactVecT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b>, + ) -> flatbuffers::WIPOffset> { + let contacts = self.contacts.as_ref().map(|x| { + let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect(); + _fbb.create_vector(&w) + }); + ContactVec::create(_fbb, &ContactVecArgs { contacts }) + } + } + pub enum TxTimeValueOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct TxTimeValue<'a> { + pub _tab: flatbuffers::Table<'a>, + } + + impl<'a> flatbuffers::Follow<'a> for TxTimeValue<'a> { + type Inner = TxTimeValue<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } + } + } + + impl<'a> TxTimeValue<'a> { + pub const VT_TIMESTAMP: flatbuffers::VOffsetT = 4; + pub const VT_VALUE: flatbuffers::VOffsetT = 6; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + TxTimeValue { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args TxTimeValueArgs, + ) -> flatbuffers::WIPOffset> { + let mut builder = TxTimeValueBuilder::new(_fbb); + builder.add_value(args.value); + builder.add_timestamp(args.timestamp); + builder.finish() + } + + pub fn unpack(&self) -> TxTimeValueT { + let timestamp = self.timestamp(); + let value = self.value(); + TxTimeValueT { timestamp, value } + } + + #[inline] + pub fn timestamp(&self) -> u32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(TxTimeValue::VT_TIMESTAMP, Some(0)) + .unwrap() + } + } + #[inline] + pub fn value(&self) -> u64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(TxTimeValue::VT_VALUE, Some(0)) + .unwrap() + } + } + } + + impl flatbuffers::Verifiable for TxTimeValue<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, + pos: usize, + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::("timestamp", Self::VT_TIMESTAMP, false)? + .visit_field::("value", Self::VT_VALUE, false)? + .finish(); + Ok(()) + } + } + pub struct TxTimeValueArgs { + pub timestamp: u32, + pub value: u64, + } + impl<'a> Default for TxTimeValueArgs { + #[inline] + fn default() -> Self { + TxTimeValueArgs { + timestamp: 0, + value: 0, + } + } + } + + pub struct TxTimeValueBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, + } + impl<'a: 'b, 'b> TxTimeValueBuilder<'a, 'b> { + #[inline] + pub fn add_timestamp(&mut self, timestamp: u32) { + self.fbb_ + .push_slot::(TxTimeValue::VT_TIMESTAMP, timestamp, 0); + } + #[inline] + pub fn add_value(&mut self, value: u64) { + self.fbb_.push_slot::(TxTimeValue::VT_VALUE, value, 0); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> TxTimeValueBuilder<'a, 'b> { + let start = _fbb.start_table(); + TxTimeValueBuilder { + 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 TxTimeValue<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("TxTimeValue"); + ds.field("timestamp", &self.timestamp()); + ds.field("value", &self.value()); + ds.finish() + } + } + #[non_exhaustive] + #[derive(Debug, Clone, PartialEq)] + pub struct TxTimeValueT { + pub timestamp: u32, + pub value: u64, + } + impl Default for TxTimeValueT { + fn default() -> Self { + Self { + timestamp: 0, + value: 0, + } + } + } + impl TxTimeValueT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b>, + ) -> flatbuffers::WIPOffset> { + let timestamp = self.timestamp; + let value = self.value; + TxTimeValue::create(_fbb, &TxTimeValueArgs { timestamp, value }) + } + } + pub enum TxTimeValueVecOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct TxTimeValueVec<'a> { + pub _tab: flatbuffers::Table<'a>, + } + + impl<'a> flatbuffers::Follow<'a> for TxTimeValueVec<'a> { + type Inner = TxTimeValueVec<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } + } + } + + impl<'a> TxTimeValueVec<'a> { + pub const VT_VALUES: flatbuffers::VOffsetT = 4; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + TxTimeValueVec { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args TxTimeValueVecArgs<'args>, + ) -> flatbuffers::WIPOffset> { + let mut builder = TxTimeValueVecBuilder::new(_fbb); + if let Some(x) = args.values { + builder.add_values(x); + } + builder.finish() + } + + pub fn unpack(&self) -> TxTimeValueVecT { + let values = self + .values() + .map(|x| x.iter().map(|t| t.unpack()).collect()); + TxTimeValueVecT { values } + } + + #[inline] + pub fn values( + &self, + ) -> Option>>> + { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab.get::>, + >>(TxTimeValueVec::VT_VALUES, None) + } + } + } + + impl flatbuffers::Verifiable for TxTimeValueVec<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, + pos: usize, + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>, + >>("values", Self::VT_VALUES, false)? + .finish(); + Ok(()) + } + } + pub struct TxTimeValueVecArgs<'a> { + pub values: Option< + flatbuffers::WIPOffset< + flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>>, + >, + >, + } + impl<'a> Default for TxTimeValueVecArgs<'a> { + #[inline] + fn default() -> Self { + TxTimeValueVecArgs { values: None } + } + } + + pub struct TxTimeValueVecBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, + } + impl<'a: 'b, 'b> TxTimeValueVecBuilder<'a, 'b> { + #[inline] + pub fn add_values( + &mut self, + values: flatbuffers::WIPOffset< + flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, + >, + ) { + self.fbb_ + .push_slot_always::>(TxTimeValueVec::VT_VALUES, values); + } + #[inline] + pub fn new( + _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, + ) -> TxTimeValueVecBuilder<'a, 'b> { + let start = _fbb.start_table(); + TxTimeValueVecBuilder { + 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 TxTimeValueVec<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("TxTimeValueVec"); + ds.field("values", &self.values()); + ds.finish() + } + } + #[non_exhaustive] + #[derive(Debug, Clone, PartialEq)] + pub struct TxTimeValueVecT { + pub values: Option>, + } + impl Default for TxTimeValueVecT { + fn default() -> Self { + Self { values: None } + } + } + impl TxTimeValueVecT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b>, + ) -> flatbuffers::WIPOffset> { + let values = self.values.as_ref().map(|x| { + let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect(); + _fbb.create_vector(&w) + }); + TxTimeValueVec::create(_fbb, &TxTimeValueVecArgs { values }) + } + } + pub enum QuoteOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct Quote<'a> { + pub _tab: flatbuffers::Table<'a>, + } + + impl<'a> flatbuffers::Follow<'a> for Quote<'a> { + type Inner = Quote<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } + } + } + + impl<'a> Quote<'a> { + pub const VT_TIMESTAMP: flatbuffers::VOffsetT = 4; + pub const VT_PRICE: flatbuffers::VOffsetT = 6; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + Quote { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args QuoteArgs, + ) -> flatbuffers::WIPOffset> { + let mut builder = QuoteBuilder::new(_fbb); + builder.add_price(args.price); + builder.add_timestamp(args.timestamp); + builder.finish() + } + + pub fn unpack(&self) -> QuoteT { + let timestamp = self.timestamp(); + let price = self.price(); + QuoteT { timestamp, price } + } + + #[inline] + pub fn timestamp(&self) -> u32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Quote::VT_TIMESTAMP, Some(0)).unwrap() } + } + #[inline] + pub fn price(&self) -> f64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Quote::VT_PRICE, Some(0.0)).unwrap() } + } + } + + impl flatbuffers::Verifiable for Quote<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, + pos: usize, + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::("timestamp", Self::VT_TIMESTAMP, false)? + .visit_field::("price", Self::VT_PRICE, false)? + .finish(); + Ok(()) + } + } + pub struct QuoteArgs { + pub timestamp: u32, + pub price: f64, + } + impl<'a> Default for QuoteArgs { + #[inline] + fn default() -> Self { + QuoteArgs { + timestamp: 0, + price: 0.0, + } + } + } + + pub struct QuoteBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, + } + impl<'a: 'b, 'b> QuoteBuilder<'a, 'b> { + #[inline] + pub fn add_timestamp(&mut self, timestamp: u32) { + self.fbb_ + .push_slot::(Quote::VT_TIMESTAMP, timestamp, 0); + } + #[inline] + pub fn add_price(&mut self, price: f64) { + self.fbb_.push_slot::(Quote::VT_PRICE, price, 0.0); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> QuoteBuilder<'a, 'b> { + let start = _fbb.start_table(); + QuoteBuilder { + 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 Quote<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("Quote"); + ds.field("timestamp", &self.timestamp()); + ds.field("price", &self.price()); + ds.finish() + } + } + #[non_exhaustive] + #[derive(Debug, Clone, PartialEq)] + pub struct QuoteT { + pub timestamp: u32, + pub price: f64, + } + impl Default for QuoteT { + fn default() -> Self { + Self { + timestamp: 0, + price: 0.0, + } + } + } + impl QuoteT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b>, + ) -> flatbuffers::WIPOffset> { + let timestamp = self.timestamp; + let price = self.price; + Quote::create(_fbb, &QuoteArgs { timestamp, price }) + } + } + pub enum QuoteVecOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct QuoteVec<'a> { + pub _tab: flatbuffers::Table<'a>, + } + + impl<'a> flatbuffers::Follow<'a> for QuoteVec<'a> { + type Inner = QuoteVec<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } + } + } + + impl<'a> QuoteVec<'a> { + pub const VT_VALUES: flatbuffers::VOffsetT = 4; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + QuoteVec { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args QuoteVecArgs<'args>, + ) -> flatbuffers::WIPOffset> { + let mut builder = QuoteVecBuilder::new(_fbb); + if let Some(x) = args.values { + builder.add_values(x); + } + builder.finish() + } + + pub fn unpack(&self) -> QuoteVecT { + let values = self + .values() + .map(|x| x.iter().map(|t| t.unpack()).collect()); + QuoteVecT { values } + } + + #[inline] + pub fn values( + &self, + ) -> Option>>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab.get::>, + >>(QuoteVec::VT_VALUES, None) + } + } + } + + impl flatbuffers::Verifiable for QuoteVec<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, + pos: usize, + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>, + >>("values", Self::VT_VALUES, false)? + .finish(); + Ok(()) + } + } + pub struct QuoteVecArgs<'a> { + pub values: Option< + flatbuffers::WIPOffset< + flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>>, + >, + >, + } + impl<'a> Default for QuoteVecArgs<'a> { + #[inline] + fn default() -> Self { + QuoteVecArgs { values: None } + } + } + + pub struct QuoteVecBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, + } + impl<'a: 'b, 'b> QuoteVecBuilder<'a, 'b> { + #[inline] + pub fn add_values( + &mut self, + values: flatbuffers::WIPOffset< + flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, + >, + ) { + self.fbb_ + .push_slot_always::>(QuoteVec::VT_VALUES, values); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> QuoteVecBuilder<'a, 'b> { + let start = _fbb.start_table(); + QuoteVecBuilder { + 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 QuoteVec<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("QuoteVec"); + ds.field("values", &self.values()); + ds.finish() + } + } + #[non_exhaustive] + #[derive(Debug, Clone, PartialEq)] + pub struct QuoteVecT { + pub values: Option>, + } + impl Default for QuoteVecT { + fn default() -> Self { + Self { values: None } + } + } + impl QuoteVecT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b>, + ) -> flatbuffers::WIPOffset> { + let values = self.values.as_ref().map(|x| { + let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect(); + _fbb.create_vector(&w) + }); + QuoteVec::create(_fbb, &QuoteVecArgs { values }) + } + } + pub enum SpendingOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct Spending<'a> { + pub _tab: flatbuffers::Table<'a>, + } + + impl<'a> flatbuffers::Follow<'a> for Spending<'a> { + type Inner = Spending<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } + } + } + + impl<'a> Spending<'a> { + pub const VT_RECIPIENT: flatbuffers::VOffsetT = 4; + pub const VT_AMOUNT: flatbuffers::VOffsetT = 6; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + Spending { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args SpendingArgs<'args>, + ) -> flatbuffers::WIPOffset> { + let mut builder = SpendingBuilder::new(_fbb); + builder.add_amount(args.amount); + if let Some(x) = args.recipient { + builder.add_recipient(x); + } + builder.finish() + } + + pub fn unpack(&self) -> SpendingT { + let recipient = self.recipient().map(|x| x.to_string()); + let amount = self.amount(); + SpendingT { recipient, amount } + } + + #[inline] + pub fn recipient(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::>(Spending::VT_RECIPIENT, None) + } + } + #[inline] + pub fn amount(&self) -> u64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Spending::VT_AMOUNT, Some(0)).unwrap() } + } + } + + impl flatbuffers::Verifiable for Spending<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, + pos: usize, + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>( + "recipient", + Self::VT_RECIPIENT, + false, + )? + .visit_field::("amount", Self::VT_AMOUNT, false)? + .finish(); + Ok(()) + } + } + pub struct SpendingArgs<'a> { + pub recipient: Option>, + pub amount: u64, + } + impl<'a> Default for SpendingArgs<'a> { + #[inline] + fn default() -> Self { + SpendingArgs { + recipient: None, + amount: 0, + } + } + } + + pub struct SpendingBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, + } + impl<'a: 'b, 'b> SpendingBuilder<'a, 'b> { + #[inline] + pub fn add_recipient(&mut self, recipient: flatbuffers::WIPOffset<&'b str>) { + self.fbb_ + .push_slot_always::>(Spending::VT_RECIPIENT, recipient); + } + #[inline] + pub fn add_amount(&mut self, amount: u64) { + self.fbb_.push_slot::(Spending::VT_AMOUNT, amount, 0); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> SpendingBuilder<'a, 'b> { + let start = _fbb.start_table(); + SpendingBuilder { + 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 Spending<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("Spending"); + ds.field("recipient", &self.recipient()); + ds.field("amount", &self.amount()); + ds.finish() + } + } + #[non_exhaustive] + #[derive(Debug, Clone, PartialEq)] + pub struct SpendingT { + pub recipient: Option, + pub amount: u64, + } + impl Default for SpendingT { + fn default() -> Self { + Self { + recipient: None, + amount: 0, + } + } + } + impl SpendingT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b>, + ) -> flatbuffers::WIPOffset> { + let recipient = self.recipient.as_ref().map(|x| _fbb.create_string(x)); + let amount = self.amount; + Spending::create(_fbb, &SpendingArgs { recipient, amount }) + } + } + pub enum SpendingVecOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct SpendingVec<'a> { + pub _tab: flatbuffers::Table<'a>, + } + + impl<'a> flatbuffers::Follow<'a> for SpendingVec<'a> { + type Inner = SpendingVec<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } + } + } + + impl<'a> SpendingVec<'a> { + pub const VT_VALUES: flatbuffers::VOffsetT = 4; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + SpendingVec { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args SpendingVecArgs<'args>, + ) -> flatbuffers::WIPOffset> { + let mut builder = SpendingVecBuilder::new(_fbb); + if let Some(x) = args.values { + builder.add_values(x); + } + builder.finish() + } + + pub fn unpack(&self) -> SpendingVecT { + let values = self + .values() + .map(|x| x.iter().map(|t| t.unpack()).collect()); + SpendingVecT { values } + } + + #[inline] + pub fn values( + &self, + ) -> Option>>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab.get::>, + >>(SpendingVec::VT_VALUES, None) + } + } + } + + impl flatbuffers::Verifiable for SpendingVec<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, + pos: usize, + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>, + >>("values", Self::VT_VALUES, false)? + .finish(); + Ok(()) + } + } + pub struct SpendingVecArgs<'a> { + pub values: Option< + flatbuffers::WIPOffset< + flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>>, + >, + >, + } + impl<'a> Default for SpendingVecArgs<'a> { + #[inline] + fn default() -> Self { + SpendingVecArgs { values: None } + } + } + + pub struct SpendingVecBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, + } + impl<'a: 'b, 'b> SpendingVecBuilder<'a, 'b> { + #[inline] + pub fn add_values( + &mut self, + values: flatbuffers::WIPOffset< + flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, + >, + ) { + self.fbb_ + .push_slot_always::>(SpendingVec::VT_VALUES, values); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> SpendingVecBuilder<'a, 'b> { + let start = _fbb.start_table(); + SpendingVecBuilder { + 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 SpendingVec<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("SpendingVec"); + ds.field("values", &self.values()); + ds.finish() + } + } + #[non_exhaustive] + #[derive(Debug, Clone, PartialEq)] + pub struct SpendingVecT { + pub values: Option>, + } + impl Default for SpendingVecT { + fn default() -> Self { + Self { values: None } + } + } + impl SpendingVecT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b>, + ) -> flatbuffers::WIPOffset> { + let values = self.values.as_ref().map(|x| { + let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect(); + _fbb.create_vector(&w) + }); + SpendingVec::create(_fbb, &SpendingVecArgs { values }) + } + } + pub enum AddressBalanceOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct AddressBalance<'a> { + pub _tab: flatbuffers::Table<'a>, + } + + impl<'a> flatbuffers::Follow<'a> for AddressBalance<'a> { + type Inner = AddressBalance<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } + } + } + + impl<'a> AddressBalance<'a> { + pub const VT_INDEX: flatbuffers::VOffsetT = 4; + pub const VT_ADDRESS: flatbuffers::VOffsetT = 6; + pub const VT_BALANCE: flatbuffers::VOffsetT = 8; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + AddressBalance { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args AddressBalanceArgs<'args>, + ) -> flatbuffers::WIPOffset> { + let mut builder = AddressBalanceBuilder::new(_fbb); + builder.add_balance(args.balance); + if let Some(x) = args.address { + builder.add_address(x); + } + builder.add_index(args.index); + builder.finish() + } + + pub fn unpack(&self) -> AddressBalanceT { + let index = self.index(); + let address = self.address().map(|x| x.to_string()); + let balance = self.balance(); + AddressBalanceT { + index, + address, + balance, + } + } + + #[inline] + pub fn index(&self) -> u32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(AddressBalance::VT_INDEX, Some(0)) + .unwrap() + } + } + #[inline] + pub fn address(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::>(AddressBalance::VT_ADDRESS, None) + } + } + #[inline] + pub fn balance(&self) -> u64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::(AddressBalance::VT_BALANCE, Some(0)) + .unwrap() + } + } + } + + impl flatbuffers::Verifiable for AddressBalance<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, + pos: usize, + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::("index", Self::VT_INDEX, false)? + .visit_field::>( + "address", + Self::VT_ADDRESS, + false, + )? + .visit_field::("balance", Self::VT_BALANCE, false)? + .finish(); + Ok(()) + } + } + pub struct AddressBalanceArgs<'a> { + pub index: u32, + pub address: Option>, + pub balance: u64, + } + impl<'a> Default for AddressBalanceArgs<'a> { + #[inline] + fn default() -> Self { + AddressBalanceArgs { + index: 0, + address: None, + balance: 0, + } + } + } + + pub struct AddressBalanceBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, + } + impl<'a: 'b, 'b> AddressBalanceBuilder<'a, 'b> { + #[inline] + pub fn add_index(&mut self, index: u32) { + self.fbb_ + .push_slot::(AddressBalance::VT_INDEX, index, 0); + } + #[inline] + pub fn add_address(&mut self, address: flatbuffers::WIPOffset<&'b str>) { + self.fbb_ + .push_slot_always::>(AddressBalance::VT_ADDRESS, address); + } + #[inline] + pub fn add_balance(&mut self, balance: u64) { + self.fbb_ + .push_slot::(AddressBalance::VT_BALANCE, balance, 0); + } + #[inline] + pub fn new( + _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, + ) -> AddressBalanceBuilder<'a, 'b> { + let start = _fbb.start_table(); + AddressBalanceBuilder { + 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 AddressBalance<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("AddressBalance"); + ds.field("index", &self.index()); + ds.field("address", &self.address()); + ds.field("balance", &self.balance()); + ds.finish() + } + } + #[non_exhaustive] + #[derive(Debug, Clone, PartialEq)] + pub struct AddressBalanceT { + pub index: u32, + pub address: Option, + pub balance: u64, + } + impl Default for AddressBalanceT { + fn default() -> Self { + Self { + index: 0, + address: None, + balance: 0, + } + } + } + impl AddressBalanceT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b>, + ) -> flatbuffers::WIPOffset> { + let index = self.index; + let address = self.address.as_ref().map(|x| _fbb.create_string(x)); + let balance = self.balance; + AddressBalance::create( + _fbb, + &AddressBalanceArgs { + index, + address, + balance, + }, + ) + } + } + pub enum AddressBalanceVecOffset {} + #[derive(Copy, Clone, PartialEq)] + + pub struct AddressBalanceVec<'a> { + pub _tab: flatbuffers::Table<'a>, + } + + impl<'a> flatbuffers::Follow<'a> for AddressBalanceVec<'a> { + type Inner = AddressBalanceVec<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { + _tab: flatbuffers::Table::new(buf, loc), + } + } + } + + impl<'a> AddressBalanceVec<'a> { + pub const VT_VALUES: flatbuffers::VOffsetT = 4; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + AddressBalanceVec { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args AddressBalanceVecArgs<'args>, + ) -> flatbuffers::WIPOffset> { + let mut builder = AddressBalanceVecBuilder::new(_fbb); + if let Some(x) = args.values { + builder.add_values(x); + } + builder.finish() + } + + pub fn unpack(&self) -> AddressBalanceVecT { + let values = self + .values() + .map(|x| x.iter().map(|t| t.unpack()).collect()); + AddressBalanceVecT { values } + } + + #[inline] + pub fn values( + &self, + ) -> Option>>> + { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab.get::>, + >>(AddressBalanceVec::VT_VALUES, None) + } + } + } + + impl flatbuffers::Verifiable for AddressBalanceVec<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, + pos: usize, + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>, + >>("values", Self::VT_VALUES, false)? + .finish(); + Ok(()) + } + } + pub struct AddressBalanceVecArgs<'a> { + pub values: Option< + flatbuffers::WIPOffset< + flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>>, + >, + >, + } + impl<'a> Default for AddressBalanceVecArgs<'a> { + #[inline] + fn default() -> Self { + AddressBalanceVecArgs { values: None } + } + } + + pub struct AddressBalanceVecBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, + } + impl<'a: 'b, 'b> AddressBalanceVecBuilder<'a, 'b> { + #[inline] + pub fn add_values( + &mut self, + values: flatbuffers::WIPOffset< + flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, + >, + ) { + self.fbb_.push_slot_always::>( + AddressBalanceVec::VT_VALUES, + values, + ); + } + #[inline] + pub fn new( + _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, + ) -> AddressBalanceVecBuilder<'a, 'b> { + let start = _fbb.start_table(); + AddressBalanceVecBuilder { + 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 AddressBalanceVec<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("AddressBalanceVec"); + ds.field("values", &self.values()); + ds.finish() + } + } + #[non_exhaustive] + #[derive(Debug, Clone, PartialEq)] + pub struct AddressBalanceVecT { + pub values: Option>, + } + impl Default for AddressBalanceVecT { + fn default() -> Self { + Self { values: None } + } + } + impl AddressBalanceVecT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b>, + ) -> flatbuffers::WIPOffset> { + let values = self.values.as_ref().map(|x| { + let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect(); + _fbb.create_vector(&w) + }); + AddressBalanceVec::create(_fbb, &AddressBalanceVecArgs { values }) + } + } +} // pub mod fb diff --git a/src/db/migration.rs b/src/db/migration.rs index a8c79a1..02df06a 100644 --- a/src/db/migration.rs +++ b/src/db/migration.rs @@ -279,7 +279,9 @@ pub fn init_db(connection: &Connection, network: &Network, has_ua: bool) -> anyh fiat TEXT, include_reply_to BOOL NOT NULL, subject TEXT NOT NULL, - body TEXT NOT NULL)", [])?; + body TEXT NOT NULL)", + [], + )?; } if version != LATEST_VERSION { diff --git a/src/db/read.rs b/src/db/read.rs index 43bfd55..ca9929b 100644 --- a/src/db/read.rs +++ b/src/db/read.rs @@ -1,10 +1,12 @@ -use rusqlite::{Connection, OptionalExtension, params}; -use anyhow::Result; use crate::db::data_generated::fb::*; use crate::DbAdapter; +use anyhow::Result; +use rusqlite::{params, Connection, OptionalExtension}; pub fn has_account(connection: &Connection) -> Result { - let res = connection.query_row("SELECT 1 FROM accounts", [], |_| { Ok(()) }).optional()?; + let res = connection + .query_row("SELECT 1 FROM accounts", [], |_| Ok(())) + .optional()?; Ok(res.is_some()) } @@ -18,11 +20,14 @@ pub fn get_account_list(connection: &Connection) -> Result> { let name: String = row.get("name")?; let balance: i64 = row.get("balance")?; let name = builder.create_string(&name); - let account = Account::create(&mut builder, &AccountArgs { - id, - name: Some(name), - balance: balance as u64, - }); + let account = Account::create( + &mut builder, + &AccountArgs { + id, + name: Some(name), + balance: balance as u64, + }, + ); Ok(account) })?; let mut accounts = vec![]; @@ -30,40 +35,64 @@ pub fn get_account_list(connection: &Connection) -> Result> { accounts.push(r?); } let accounts = builder.create_vector(&accounts); - let accounts = AccountVec::create(&mut builder, &AccountVecArgs { accounts: Some(accounts) }); + let accounts = AccountVec::create( + &mut builder, + &AccountVecArgs { + accounts: Some(accounts), + }, + ); builder.finish(accounts, None); let data = builder.finished_data().to_vec(); Ok(data) } pub fn get_available_account_id(connection: &Connection, id: u32) -> Result { - let r = connection.query_row("SELECT 1 FROM accounts WHERE id_account = ?1", [id], |_| { Ok(()) }).optional()?; - if r.is_some() { return Ok(id) } - let r = connection.query_row("SELECT MAX(id_account) FROM accounts", [], |row| { - let id: Option = row.get(0)?; - Ok(id) - })?.unwrap_or(0); + let r = connection + .query_row("SELECT 1 FROM accounts WHERE id_account = ?1", [id], |_| { + Ok(()) + }) + .optional()?; + if r.is_some() { + return Ok(id); + } + let r = connection + .query_row("SELECT MAX(id_account) FROM accounts", [], |row| { + let id: Option = row.get(0)?; + Ok(id) + })? + .unwrap_or(0); Ok(r) } pub fn get_t_addr(connection: &Connection, id: u32) -> Result { - let address = connection.query_row("SELECT address FROM taddrs WHERE account = ?1", [id], |row| { - let address: String = row.get(0)?; - Ok(address) - })?; + let address = connection.query_row( + "SELECT address FROM taddrs WHERE account = ?1", + [id], + |row| { + let address: String = row.get(0)?; + Ok(address) + }, + )?; Ok(address) } pub fn get_sk(connection: &Connection, id: u32) -> Result { - let sk = connection.query_row("SELECT sk FROM accounts WHERE id_account = ?1", [id], |row| { - let sk: Option = row.get(0)?; - Ok(sk.unwrap_or(String::new())) - })?; + let sk = connection.query_row( + "SELECT sk FROM accounts WHERE id_account = ?1", + [id], + |row| { + let sk: Option = row.get(0)?; + Ok(sk.unwrap_or(String::new())) + }, + )?; Ok(sk) } pub fn update_account_name(connection: &Connection, id: u32, name: &str) -> Result<()> { - connection.execute("UPDATE accounts SET name = ?2 WHERE id_account = ?1", params![id, name])?; + connection.execute( + "UPDATE accounts SET name = ?2 WHERE id_account = ?1", + params![id, name], + )?; Ok(()) } @@ -71,16 +100,20 @@ pub fn get_balances(connection: &Connection, id: u32, confirmed_height: u32) -> let mut builder = flatbuffers::FlatBufferBuilder::new(); let shielded = connection.query_row( "SELECT SUM(value) AS value FROM received_notes WHERE account = ?1 AND spent IS NULL", - params![id], |row| { + params![id], + |row| { let value: Option = row.get(0)?; Ok(value.unwrap_or(0) as u64) - })?; // funds not spent yet + }, + )?; // funds not spent yet let unconfirmed_spent = connection.query_row( "SELECT SUM(value) AS value FROM received_notes WHERE account = ?1 AND spent = 0", - params![id], |row| { + params![id], + |row| { let value: Option = row.get(0)?; Ok(value.unwrap_or(0) as u64) - })?; // funds used in unconfirmed tx + }, + )?; // funds used in unconfirmed tx let balance = shielded + unconfirmed_spent; let under_confirmed = connection.query_row( "SELECT SUM(value) AS value FROM received_notes WHERE account = ?1 AND spent IS NULL AND height > ?2", @@ -91,10 +124,12 @@ pub fn get_balances(connection: &Connection, id: u32, confirmed_height: u32) -> let excluded = connection.query_row( "SELECT SUM(value) FROM received_notes WHERE account = ?1 AND spent IS NULL \ AND height <= ?2 AND excluded", - params![id, confirmed_height], |row| { + params![id, confirmed_height], + |row| { let value: Option = row.get(0)?; Ok(value.unwrap_or(0) as u64) - })?; // funds excluded from spending + }, + )?; // funds excluded from spending let sapling = connection.query_row( "SELECT SUM(value) FROM received_notes WHERE account = ?1 AND spent IS NULL AND orchard = 0 AND height <= ?2", params![id, confirmed_height], |row| { @@ -108,15 +143,18 @@ pub fn get_balances(connection: &Connection, id: u32, confirmed_height: u32) -> Ok(value.unwrap_or(0) as u64) })?; - let balance = Balance::create(&mut builder, &BalanceArgs { - shielded, - unconfirmed_spent, - balance, - under_confirmed, - excluded, - sapling, - orchard - }); + let balance = Balance::create( + &mut builder, + &BalanceArgs { + shielded, + unconfirmed_spent, + balance, + under_confirmed, + excluded, + sapling, + orchard, + }, + ); builder.finish(balance, None); let data = builder.finished_data().to_vec(); Ok(data) @@ -124,21 +162,24 @@ pub fn get_balances(connection: &Connection, id: u32, confirmed_height: u32) -> pub fn get_db_height(connection: &Connection) -> Result> { let mut builder = flatbuffers::FlatBufferBuilder::new(); - let height = connection.query_row( - "SELECT height, timestamp FROM blocks WHERE height = (SELECT MAX(height) FROM blocks)", - [], |row| { - let height: u32 = row.get(0)?; - let timestamp: u32 = row.get(1)?; - let height = Height::create(&mut builder, &HeightArgs { - height, - timestamp, - }); - Ok(height) - }).optional()?; - let data = height.map(|h| { - builder.finish(h, None); - builder.finished_data().to_vec() - }).unwrap_or(vec![]); + let height = connection + .query_row( + "SELECT height, timestamp FROM blocks WHERE height = (SELECT MAX(height) FROM blocks)", + [], + |row| { + let height: u32 = row.get(0)?; + let timestamp: u32 = row.get(1)?; + let height = Height::create(&mut builder, &HeightArgs { height, timestamp }); + Ok(height) + }, + ) + .optional()?; + let data = height + .map(|h| { + builder.finish(h, None); + builder.finished_data().to_vec() + }) + .unwrap_or(vec![]); Ok(data) } @@ -156,15 +197,18 @@ pub fn get_notes(connection: &Connection, id: u32) -> Result> { let orchard: u8 = row.get("orchard")?; let excluded: Option = row.get("excluded")?; let spent: Option = row.get("spent")?; - let note = ShieldedNote::create(&mut builder, &ShieldedNoteArgs { - id, - height, - value: value as u64, - timestamp, - orchard: orchard == 1, - excluded: excluded.unwrap_or(false), - spent: spent.is_some() - }); + let note = ShieldedNote::create( + &mut builder, + &ShieldedNoteArgs { + id, + height, + value: value as u64, + timestamp, + orchard: orchard == 1, + excluded: excluded.unwrap_or(false), + spent: spent.is_some(), + }, + ); Ok(note) })?; let mut notes = vec![]; @@ -206,17 +250,20 @@ pub fn get_txs(connection: &Connection, id: u32) -> Result> { let name = builder.create_string(&name); let address = builder.create_string(&address); let memo = builder.create_string(&memo); - let tx = ShieldedTx::create(&mut builder, &ShieldedTxArgs { - id: id_tx, - height, - tx_id: Some(tx_id), - short_tx_id: Some(short_tx_id), - timestamp, - name: Some(name), - value: value as u64, - address: Some(address), - memo: Some(memo), - }); + let tx = ShieldedTx::create( + &mut builder, + &ShieldedTxArgs { + id: id_tx, + height, + tx_id: Some(tx_id), + short_tx_id: Some(short_tx_id), + timestamp, + name: Some(name), + value: value as u64, + address: Some(address), + memo: Some(memo), + }, + ); Ok(tx) })?; let mut txs = vec![]; @@ -265,18 +312,21 @@ pub fn get_messages(connection: &Connection, id: u32) -> Result> { let subject = builder.create_string(&subject); let body = builder.create_string(&body); - let message = Message::create(&mut builder, &MessageArgs { - id_msg, - id_tx, - height, - timestamp, - from: Some(from), - to: Some(to), - subject: Some(subject), - body: Some(body), - read, - incoming - }); + let message = Message::create( + &mut builder, + &MessageArgs { + id_msg, + id_tx, + height, + timestamp, + from: Some(from), + to: Some(to), + subject: Some(subject), + body: Some(body), + read, + incoming, + }, + ); Ok(message) })?; let mut messages = vec![]; @@ -284,24 +334,44 @@ pub fn get_messages(connection: &Connection, id: u32) -> Result> { messages.push(r?); } let messages = builder.create_vector(&messages); - let messages = MessageVec::create(&mut builder, &MessageVecArgs { messages: Some(messages) }); + let messages = MessageVec::create( + &mut builder, + &MessageVecArgs { + messages: Some(messages), + }, + ); builder.finish(messages, None); let data = builder.finished_data().to_vec(); Ok(data) } -pub fn get_prev_next_message(connection: &Connection, subject: &str, height: u32, account: u32) -> Result> { +pub fn get_prev_next_message( + connection: &Connection, + subject: &str, + height: u32, + account: u32, +) -> Result> { let mut builder = flatbuffers::FlatBufferBuilder::new(); - let prev = connection.query_row("SELECT MAX(id) FROM messages WHERE subject = ?1 AND height < ?2 and account = ?3", - params![subject, height, account], |row| { - let id: Option = row.get(0)?; - Ok(id) - })?.unwrap_or(0); - let next = connection.query_row("SELECT MIN(id) FROM messages WHERE subject = ?1 AND height > ?2 and account = ?3", - params![subject, height, account], |row| { - let id: Option = row.get(0)?; - Ok(id) - })?.unwrap_or(0); + let prev = connection + .query_row( + "SELECT MAX(id) FROM messages WHERE subject = ?1 AND height < ?2 and account = ?3", + params![subject, height, account], + |row| { + let id: Option = row.get(0)?; + Ok(id) + }, + )? + .unwrap_or(0); + let next = connection + .query_row( + "SELECT MIN(id) FROM messages WHERE subject = ?1 AND height > ?2 and account = ?3", + params![subject, height, account], + |row| { + let id: Option = row.get(0)?; + Ok(id) + }, + )? + .unwrap_or(0); let prev_next = PrevNext::create(&mut builder, &PrevNextArgs { prev, next }); builder.finish(prev_next, None); let data = builder.finished_data().to_vec(); @@ -319,30 +389,32 @@ pub fn get_templates(connection: &Connection) -> Result> { let amount: i64 = row.get("amount")?; let fiat_amount: f64 = row.get("fiat_amount")?; let fee_included: bool = row.get("fee_included")?; - let fiat: String = row.get("fiat")?; + let fiat: Option = row.get("fiat")?; let include_reply_to: bool = row.get("include_reply_to")?; let subject: String = row.get("subject")?; let body: String = row.get("body")?; let title = builder.create_string(&title); let address = builder.create_string(&address); - let fiat = builder.create_string(&fiat); + let fiat = fiat.map(|fiat| builder.create_string(&fiat)); let subject = builder.create_string(&subject); let body = builder.create_string(&body); - - let template = SendTemplate::create(&mut builder, &SendTemplateArgs { - id: id_msg, - title: Some(title), - address: Some(address), - amount: amount as u64, - fiat_amount, - fee_included, - fiat: Some(fiat), - include_reply_to, - subject: Some(subject), - body: Some(body), - }); + let template = SendTemplate::create( + &mut builder, + &SendTemplateArgs { + id: id_msg, + title: Some(title), + address: Some(address), + amount: amount as u64, + fiat_amount, + fee_included, + fiat, + include_reply_to, + subject: Some(subject), + body: Some(body), + }, + ); Ok(template) })?; let mut templates = vec![]; @@ -350,7 +422,12 @@ pub fn get_templates(connection: &Connection) -> Result> { templates.push(r?); } let templates = builder.create_vector(&templates); - let templates = SendTemplateVec::create(&mut builder, &SendTemplateVecArgs { templates: Some(templates) }); + let templates = SendTemplateVec::create( + &mut builder, + &SendTemplateVecArgs { + templates: Some(templates), + }, + ); builder.finish(templates, None); let data = builder.finished_data().to_vec(); Ok(data) @@ -358,19 +435,22 @@ pub fn get_templates(connection: &Connection) -> Result> { pub fn get_contacts(connection: &Connection) -> Result> { let mut builder = flatbuffers::FlatBufferBuilder::new(); - let mut stmt = connection.prepare( - "SELECT id, name, address FROM contacts WHERE address <> '' ORDER BY name")?; + let mut stmt = connection + .prepare("SELECT id, name, address FROM contacts WHERE address <> '' ORDER BY name")?; let rows = stmt.query_map([], |row| { let id: u32 = row.get("id")?; let name: String = row.get("name")?; let address: String = row.get("address")?; let name = builder.create_string(&name); let address = builder.create_string(&address); - let contact = Contact::create(&mut builder, &ContactArgs { - id, - name: Some(name), - address: Some(address), - }); + let contact = Contact::create( + &mut builder, + &ContactArgs { + id, + name: Some(name), + address: Some(address), + }, + ); Ok(contact) })?; let mut contacts = vec![]; @@ -378,7 +458,12 @@ pub fn get_contacts(connection: &Connection) -> Result> { contacts.push(r?); } let contacts = builder.create_vector(&contacts); - let contacts = ContactVec::create(&mut builder, &ContactVecArgs { contacts: Some(contacts) }); + let contacts = ContactVec::create( + &mut builder, + &ContactVecArgs { + contacts: Some(contacts), + }, + ); builder.finish(contacts, None); let data = builder.finished_data().to_vec(); Ok(data) @@ -391,8 +476,13 @@ pub fn get_pnl_txs(connection: &Connection, id: u32, timestamp: u32) -> Result Result Result> { +pub fn get_historical_prices( + connection: &Connection, + timestamp: u32, + currency: &str, +) -> Result> { let mut builder = flatbuffers::FlatBufferBuilder::new(); let mut stmt = connection.prepare( - "SELECT timestamp, price FROM historical_prices WHERE timestamp >= ?2 AND currency = ?1")?; + "SELECT timestamp, price FROM historical_prices WHERE timestamp >= ?2 AND currency = ?1", + )?; let rows = stmt.query_map(params![currency, timestamp], |row| { let timestamp: u32 = row.get(0)?; let price: f64 = row.get(1)?; - let quote = Quote::create(&mut builder, &QuoteArgs { - timestamp, price }); + let quote = Quote::create(&mut builder, &QuoteArgs { timestamp, price }); Ok(quote) })?; let mut quotes = vec![]; @@ -422,7 +516,12 @@ pub fn get_historical_prices(connection: &Connection, timestamp: u32, currency: quotes.push(r?); } let quotes = builder.create_vector("es); - let quotes = QuoteVec::create(&mut builder, &QuoteVecArgs { values: Some(quotes) }); + let quotes = QuoteVec::create( + &mut builder, + &QuoteVecArgs { + values: Some(quotes), + }, + ); builder.finish(quotes, None); let data = builder.finished_data().to_vec(); Ok(data) @@ -442,10 +541,13 @@ pub fn get_spendings(connection: &Connection, id: u32, timestamp: u32) -> Result let recipient = recipient.unwrap_or(String::new()); let recipient = builder.create_string(&recipient); - let spending = Spending::create(&mut builder, &SpendingArgs { - recipient: Some(recipient), - amount: (-value) as u64, - }); + let spending = Spending::create( + &mut builder, + &SpendingArgs { + recipient: Some(recipient), + amount: (-value) as u64, + }, + ); Ok(spending) })?; let mut spendings = vec![]; @@ -453,80 +555,91 @@ pub fn get_spendings(connection: &Connection, id: u32, timestamp: u32) -> Result spendings.push(r?); } let spendings = builder.create_vector(&spendings); - let spendings = SpendingVec::create(&mut builder, &SpendingVecArgs { values: Some(spendings) }); + let spendings = SpendingVec::create( + &mut builder, + &SpendingVecArgs { + values: Some(spendings), + }, + ); builder.finish(spendings, None); let data = builder.finished_data().to_vec(); Ok(data) } pub fn update_excluded(connection: &Connection, id: u32, excluded: bool) -> Result<()> { - connection.execute("UPDATE received_notes SET excluded = ?2 WHERE id_note = ?1", params![id, excluded])?; + connection.execute( + "UPDATE received_notes SET excluded = ?2 WHERE id_note = ?1", + params![id, excluded], + )?; Ok(()) } pub fn invert_excluded(connection: &Connection, id: u32) -> Result<()> { - connection.execute("UPDATE received_notes SET excluded = NOT(COALESCE(excluded, 0)) WHERE account = ?1", [id])?; + connection.execute( + "UPDATE received_notes SET excluded = NOT(COALESCE(excluded, 0)) WHERE account = ?1", + [id], + )?; Ok(()) } /* - , + , - "SELECT timestamp, value FROM transactions WHERE account = ?1 AND timestamp >= ?2 ORDER BY timestamp DESC", + "SELECT timestamp, value FROM transactions WHERE account = ?1 AND timestamp >= ?2 ORDER BY timestamp DESC", - final List res = await db.rawQuery( - "SELECT SUM(value) as v, t.address, c.name FROM transactions t LEFT JOIN contacts c ON t.address = c.address " - "WHERE account = ?1 AND timestamp >= ?2 AND value < 0 GROUP BY t.address ORDER BY v ASC LIMIT 5", - [accountId, range.start ~/ 1000]); - final spendings = res.map((row) { - final address = row['address'] ?? ""; - final value = -row['v'] / ZECUNIT; - final contact = row['name']; - return Spending(address, value, contact); - }).toList(); + final List res = await db.rawQuery( + "SELECT SUM(value) as v, t.address, c.name FROM transactions t LEFT JOIN contacts c ON t.address = c.address " + "WHERE account = ?1 AND timestamp >= ?2 AND value < 0 GROUP BY t.address ORDER BY v ASC LIMIT 5", + [accountId, range.start ~/ 1000]); + final spendings = res.map((row) { + final address = row['address'] ?? ""; + final value = -row['v'] / ZECUNIT; + final contact = row['name']; + return Spending(address, value, contact); + }).toList(); - "SELECT timestamp, price FROM historical_prices WHERE timestamp >= ?2 AND currency = ?1", + "SELECT timestamp, price FROM historical_prices WHERE timestamp >= ?2 AND currency = ?1", - final List res1 = await db.rawQuery( - "SELECT timestamp, value FROM transactions WHERE timestamp >= ?2 AND account = ?1", - [accountId, range.start ~/ 1000]); + final List res1 = await db.rawQuery( + "SELECT timestamp, value FROM transactions WHERE timestamp >= ?2 AND account = ?1", + [accountId, range.start ~/ 1000]); - List res = await db.rawQuery( - "SELECT id, name, address FROM contacts WHERE address <> '' ORDER BY name"); - for (var c in res) { - final contact = Contact(c['id'], c['name'], c['address']); - contacts.add(contact); - } + List res = await db.rawQuery( + "SELECT id, name, address FROM contacts WHERE address <> '' ORDER BY name"); + for (var c in res) { + final contact = Contact(c['id'], c['name'], c['address']); + contacts.add(contact); + } - Future getPrevMessage(String subject, int height, int account) async { - final id = await Sqflite.firstIntValue(await db.rawQuery( - "SELECT MAX(id) FROM messages WHERE subject = ?1 AND height < ?2 and account = ?3", - [subject, height, account])); - return id; - } + Future getPrevMessage(String subject, int height, int account) async { + final id = await Sqflite.firstIntValue(await db.rawQuery( + "SELECT MAX(id) FROM messages WHERE subject = ?1 AND height < ?2 and account = ?3", + [subject, height, account])); + return id; + } - Future getNextMessage(String subject, int height, int account) async { - final id = await Sqflite.firstIntValue(await db.rawQuery( - "SELECT MIN(id) FROM messages WHERE subject = ?1 AND height > ?2 and account = ?3", - [subject, height, account])); - return id; - } + Future getNextMessage(String subject, int height, int account) async { + final id = await Sqflite.firstIntValue(await db.rawQuery( + "SELECT MIN(id) FROM messages WHERE subject = ?1 AND height > ?2 and account = ?3", + [subject, height, account])); + return id; + } - final id = row['id']; - final txId = row['id_tx'] ?? 0; - final timestamp = DateTime.fromMillisecondsSinceEpoch(row['timestamp'] * 1000); - final height = row['height']; - final sender = row['sender']; - final from = row['scontact'] ?? row['saccount'] ?? sender; - final recipient = row['recipient']; - final to = row['rcontact'] ?? row['raccount'] ?? recipient; - final subject = row['subject']; - final body = row['body']; - final read = row['read'] == 1; - final incoming = row['incoming'] == 1; - */ \ No newline at end of file + final id = row['id']; + final txId = row['id_tx'] ?? 0; + final timestamp = DateTime.fromMillisecondsSinceEpoch(row['timestamp'] * 1000); + final height = row['height']; + final sender = row['sender']; + final from = row['scontact'] ?? row['saccount'] ?? sender; + final recipient = row['recipient']; + final to = row['rcontact'] ?? row['raccount'] ?? recipient; + final subject = row['subject']; + final body = row['body']; + final read = row['read'] == 1; + final incoming = row['incoming'] == 1; +*/ diff --git a/src/transaction.rs b/src/transaction.rs index 411e19f..c7ec49e 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -158,7 +158,7 @@ pub fn decode_transaction( Ok(memo) if memo != Memo::Empty => { tx_memo = memo; } - _ => () + _ => (), } } if let Some((_note, pa, memo, ..)) = @@ -175,7 +175,7 @@ pub fn decode_transaction( tx_memo = memo; incoming = false; } - _ => () + _ => (), } } } @@ -197,7 +197,7 @@ pub fn decode_transaction( Ok(memo) if memo != Memo::Empty => { tx_memo = memo; } - _ => () + _ => (), } } if let Some((_note, pa, memo, ..)) = try_output_recovery_with_ovk( @@ -216,7 +216,7 @@ pub fn decode_transaction( tx_memo = memo; incoming = false; } - _ => () + _ => (), } } }