Files
damus/nostrdb/bindings/rust/ndb_meta.rs
2025-08-11 16:39:43 -07:00

265 lines
9.0 KiB
Rust

// automatically generated by the FlatBuffers compiler, do not modify
// @generated
use core::mem;
use core::cmp::Ordering;
extern crate flatbuffers;
use self::flatbuffers::{EndianScalar, Follow};
pub enum NdbEventMetaOffset {}
#[derive(Copy, Clone, PartialEq)]
pub struct NdbEventMeta<'a> {
pub _tab: flatbuffers::Table<'a>,
}
impl<'a> flatbuffers::Follow<'a> for NdbEventMeta<'a> {
type Inner = NdbEventMeta<'a>;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: flatbuffers::Table::new(buf, loc) }
}
}
impl<'a> NdbEventMeta<'a> {
pub const VT_RECEIVED_AT: flatbuffers::VOffsetT = 4;
pub const VT_REACTIONS: flatbuffers::VOffsetT = 6;
pub const VT_QUOTES: flatbuffers::VOffsetT = 8;
pub const VT_REPOSTS: flatbuffers::VOffsetT = 10;
pub const VT_ZAPS: flatbuffers::VOffsetT = 12;
pub const VT_ZAP_TOTAL: flatbuffers::VOffsetT = 14;
#[inline]
pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
NdbEventMeta { _tab: table }
}
#[allow(unused_mut)]
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
args: &'args NdbEventMetaArgs
) -> flatbuffers::WIPOffset<NdbEventMeta<'bldr>> {
let mut builder = NdbEventMetaBuilder::new(_fbb);
builder.add_zap_total(args.zap_total);
builder.add_zaps(args.zaps);
builder.add_reposts(args.reposts);
builder.add_quotes(args.quotes);
builder.add_reactions(args.reactions);
builder.add_received_at(args.received_at);
builder.finish()
}
#[inline]
pub fn received_at(&self) -> i32 {
// Safety:
// Created from valid Table for this object
// which contains a valid value in this slot
unsafe { self._tab.get::<i32>(NdbEventMeta::VT_RECEIVED_AT, Some(0)).unwrap()}
}
#[inline]
pub fn reactions(&self) -> i32 {
// Safety:
// Created from valid Table for this object
// which contains a valid value in this slot
unsafe { self._tab.get::<i32>(NdbEventMeta::VT_REACTIONS, Some(0)).unwrap()}
}
#[inline]
pub fn quotes(&self) -> i32 {
// Safety:
// Created from valid Table for this object
// which contains a valid value in this slot
unsafe { self._tab.get::<i32>(NdbEventMeta::VT_QUOTES, Some(0)).unwrap()}
}
#[inline]
pub fn reposts(&self) -> i32 {
// Safety:
// Created from valid Table for this object
// which contains a valid value in this slot
unsafe { self._tab.get::<i32>(NdbEventMeta::VT_REPOSTS, Some(0)).unwrap()}
}
#[inline]
pub fn zaps(&self) -> i32 {
// Safety:
// Created from valid Table for this object
// which contains a valid value in this slot
unsafe { self._tab.get::<i32>(NdbEventMeta::VT_ZAPS, Some(0)).unwrap()}
}
#[inline]
pub fn zap_total(&self) -> i64 {
// Safety:
// Created from valid Table for this object
// which contains a valid value in this slot
unsafe { self._tab.get::<i64>(NdbEventMeta::VT_ZAP_TOTAL, Some(0)).unwrap()}
}
}
impl flatbuffers::Verifiable for NdbEventMeta<'_> {
#[inline]
fn run_verifier(
v: &mut flatbuffers::Verifier, pos: usize
) -> Result<(), flatbuffers::InvalidFlatbuffer> {
use self::flatbuffers::Verifiable;
v.visit_table(pos)?
.visit_field::<i32>("received_at", Self::VT_RECEIVED_AT, false)?
.visit_field::<i32>("reactions", Self::VT_REACTIONS, false)?
.visit_field::<i32>("quotes", Self::VT_QUOTES, false)?
.visit_field::<i32>("reposts", Self::VT_REPOSTS, false)?
.visit_field::<i32>("zaps", Self::VT_ZAPS, false)?
.visit_field::<i64>("zap_total", Self::VT_ZAP_TOTAL, false)?
.finish();
Ok(())
}
}
pub struct NdbEventMetaArgs {
pub received_at: i32,
pub reactions: i32,
pub quotes: i32,
pub reposts: i32,
pub zaps: i32,
pub zap_total: i64,
}
impl<'a> Default for NdbEventMetaArgs {
#[inline]
fn default() -> Self {
NdbEventMetaArgs {
received_at: 0,
reactions: 0,
quotes: 0,
reposts: 0,
zaps: 0,
zap_total: 0,
}
}
}
pub struct NdbEventMetaBuilder<'a: 'b, 'b> {
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b> NdbEventMetaBuilder<'a, 'b> {
#[inline]
pub fn add_received_at(&mut self, received_at: i32) {
self.fbb_.push_slot::<i32>(NdbEventMeta::VT_RECEIVED_AT, received_at, 0);
}
#[inline]
pub fn add_reactions(&mut self, reactions: i32) {
self.fbb_.push_slot::<i32>(NdbEventMeta::VT_REACTIONS, reactions, 0);
}
#[inline]
pub fn add_quotes(&mut self, quotes: i32) {
self.fbb_.push_slot::<i32>(NdbEventMeta::VT_QUOTES, quotes, 0);
}
#[inline]
pub fn add_reposts(&mut self, reposts: i32) {
self.fbb_.push_slot::<i32>(NdbEventMeta::VT_REPOSTS, reposts, 0);
}
#[inline]
pub fn add_zaps(&mut self, zaps: i32) {
self.fbb_.push_slot::<i32>(NdbEventMeta::VT_ZAPS, zaps, 0);
}
#[inline]
pub fn add_zap_total(&mut self, zap_total: i64) {
self.fbb_.push_slot::<i64>(NdbEventMeta::VT_ZAP_TOTAL, zap_total, 0);
}
#[inline]
pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> NdbEventMetaBuilder<'a, 'b> {
let start = _fbb.start_table();
NdbEventMetaBuilder {
fbb_: _fbb,
start_: start,
}
}
#[inline]
pub fn finish(self) -> flatbuffers::WIPOffset<NdbEventMeta<'a>> {
let o = self.fbb_.end_table(self.start_);
flatbuffers::WIPOffset::new(o.value())
}
}
impl core::fmt::Debug for NdbEventMeta<'_> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("NdbEventMeta");
ds.field("received_at", &self.received_at());
ds.field("reactions", &self.reactions());
ds.field("quotes", &self.quotes());
ds.field("reposts", &self.reposts());
ds.field("zaps", &self.zaps());
ds.field("zap_total", &self.zap_total());
ds.finish()
}
}
#[inline]
/// Verifies that a buffer of bytes contains a `NdbEventMeta`
/// and returns it.
/// Note that verification is still experimental and may not
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `root_as_ndb_event_meta_unchecked`.
pub fn root_as_ndb_event_meta(buf: &[u8]) -> Result<NdbEventMeta, flatbuffers::InvalidFlatbuffer> {
flatbuffers::root::<NdbEventMeta>(buf)
}
#[inline]
/// Verifies that a buffer of bytes contains a size prefixed
/// `NdbEventMeta` and returns it.
/// Note that verification is still experimental and may not
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `size_prefixed_root_as_ndb_event_meta_unchecked`.
pub fn size_prefixed_root_as_ndb_event_meta(buf: &[u8]) -> Result<NdbEventMeta, flatbuffers::InvalidFlatbuffer> {
flatbuffers::size_prefixed_root::<NdbEventMeta>(buf)
}
#[inline]
/// Verifies, with the given options, that a buffer of bytes
/// contains a `NdbEventMeta` and returns it.
/// Note that verification is still experimental and may not
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `root_as_ndb_event_meta_unchecked`.
pub fn root_as_ndb_event_meta_with_opts<'b, 'o>(
opts: &'o flatbuffers::VerifierOptions,
buf: &'b [u8],
) -> Result<NdbEventMeta<'b>, flatbuffers::InvalidFlatbuffer> {
flatbuffers::root_with_opts::<NdbEventMeta<'b>>(opts, buf)
}
#[inline]
/// Verifies, with the given verifier options, that a buffer of
/// bytes contains a size prefixed `NdbEventMeta` and returns
/// it. Note that verification is still experimental and may not
/// catch every error, or be maximally performant. For the
/// previous, unchecked, behavior use
/// `root_as_ndb_event_meta_unchecked`.
pub fn size_prefixed_root_as_ndb_event_meta_with_opts<'b, 'o>(
opts: &'o flatbuffers::VerifierOptions,
buf: &'b [u8],
) -> Result<NdbEventMeta<'b>, flatbuffers::InvalidFlatbuffer> {
flatbuffers::size_prefixed_root_with_opts::<NdbEventMeta<'b>>(opts, buf)
}
#[inline]
/// Assumes, without verification, that a buffer of bytes contains a NdbEventMeta and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid `NdbEventMeta`.
pub unsafe fn root_as_ndb_event_meta_unchecked(buf: &[u8]) -> NdbEventMeta {
flatbuffers::root_unchecked::<NdbEventMeta>(buf)
}
#[inline]
/// Assumes, without verification, that a buffer of bytes contains a size prefixed NdbEventMeta and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid size prefixed `NdbEventMeta`.
pub unsafe fn size_prefixed_root_as_ndb_event_meta_unchecked(buf: &[u8]) -> NdbEventMeta {
flatbuffers::size_prefixed_root_unchecked::<NdbEventMeta>(buf)
}
#[inline]
pub fn finish_ndb_event_meta_buffer<'a, 'b>(
fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
root: flatbuffers::WIPOffset<NdbEventMeta<'a>>) {
fbb.finish(root, None);
}
#[inline]
pub fn finish_size_prefixed_ndb_event_meta_buffer<'a, 'b>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, root: flatbuffers::WIPOffset<NdbEventMeta<'a>>) {
fbb.finish_size_prefixed(root, None);
}