nostrdb

an unfairly fast embedded nostr database backed by lmdb
git clone git://jb55.com/nostrdb
Log | Files | Refs | Submodules | README | LICENSE

ndb_meta.rs (9173B)


      1 // automatically generated by the FlatBuffers compiler, do not modify
      2 
      3 
      4 // @generated
      5 
      6 use core::mem;
      7 use core::cmp::Ordering;
      8 
      9 extern crate flatbuffers;
     10 use self::flatbuffers::{EndianScalar, Follow};
     11 
     12 pub enum NdbEventMetaOffset {}
     13 #[derive(Copy, Clone, PartialEq)]
     14 
     15 pub struct NdbEventMeta<'a> {
     16   pub _tab: flatbuffers::Table<'a>,
     17 }
     18 
     19 impl<'a> flatbuffers::Follow<'a> for NdbEventMeta<'a> {
     20   type Inner = NdbEventMeta<'a>;
     21   #[inline]
     22   unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
     23     Self { _tab: flatbuffers::Table::new(buf, loc) }
     24   }
     25 }
     26 
     27 impl<'a> NdbEventMeta<'a> {
     28   pub const VT_RECEIVED_AT: flatbuffers::VOffsetT = 4;
     29   pub const VT_REACTIONS: flatbuffers::VOffsetT = 6;
     30   pub const VT_QUOTES: flatbuffers::VOffsetT = 8;
     31   pub const VT_REPOSTS: flatbuffers::VOffsetT = 10;
     32   pub const VT_ZAPS: flatbuffers::VOffsetT = 12;
     33   pub const VT_ZAP_TOTAL: flatbuffers::VOffsetT = 14;
     34 
     35   #[inline]
     36   pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
     37     NdbEventMeta { _tab: table }
     38   }
     39   #[allow(unused_mut)]
     40   pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
     41     _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
     42     args: &'args NdbEventMetaArgs
     43   ) -> flatbuffers::WIPOffset<NdbEventMeta<'bldr>> {
     44     let mut builder = NdbEventMetaBuilder::new(_fbb);
     45     builder.add_zap_total(args.zap_total);
     46     builder.add_zaps(args.zaps);
     47     builder.add_reposts(args.reposts);
     48     builder.add_quotes(args.quotes);
     49     builder.add_reactions(args.reactions);
     50     builder.add_received_at(args.received_at);
     51     builder.finish()
     52   }
     53 
     54 
     55   #[inline]
     56   pub fn received_at(&self) -> i32 {
     57     // Safety:
     58     // Created from valid Table for this object
     59     // which contains a valid value in this slot
     60     unsafe { self._tab.get::<i32>(NdbEventMeta::VT_RECEIVED_AT, Some(0)).unwrap()}
     61   }
     62   #[inline]
     63   pub fn reactions(&self) -> i32 {
     64     // Safety:
     65     // Created from valid Table for this object
     66     // which contains a valid value in this slot
     67     unsafe { self._tab.get::<i32>(NdbEventMeta::VT_REACTIONS, Some(0)).unwrap()}
     68   }
     69   #[inline]
     70   pub fn quotes(&self) -> i32 {
     71     // Safety:
     72     // Created from valid Table for this object
     73     // which contains a valid value in this slot
     74     unsafe { self._tab.get::<i32>(NdbEventMeta::VT_QUOTES, Some(0)).unwrap()}
     75   }
     76   #[inline]
     77   pub fn reposts(&self) -> i32 {
     78     // Safety:
     79     // Created from valid Table for this object
     80     // which contains a valid value in this slot
     81     unsafe { self._tab.get::<i32>(NdbEventMeta::VT_REPOSTS, Some(0)).unwrap()}
     82   }
     83   #[inline]
     84   pub fn zaps(&self) -> i32 {
     85     // Safety:
     86     // Created from valid Table for this object
     87     // which contains a valid value in this slot
     88     unsafe { self._tab.get::<i32>(NdbEventMeta::VT_ZAPS, Some(0)).unwrap()}
     89   }
     90   #[inline]
     91   pub fn zap_total(&self) -> i64 {
     92     // Safety:
     93     // Created from valid Table for this object
     94     // which contains a valid value in this slot
     95     unsafe { self._tab.get::<i64>(NdbEventMeta::VT_ZAP_TOTAL, Some(0)).unwrap()}
     96   }
     97 }
     98 
     99 impl flatbuffers::Verifiable for NdbEventMeta<'_> {
    100   #[inline]
    101   fn run_verifier(
    102     v: &mut flatbuffers::Verifier, pos: usize
    103   ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
    104     use self::flatbuffers::Verifiable;
    105     v.visit_table(pos)?
    106      .visit_field::<i32>("received_at", Self::VT_RECEIVED_AT, false)?
    107      .visit_field::<i32>("reactions", Self::VT_REACTIONS, false)?
    108      .visit_field::<i32>("quotes", Self::VT_QUOTES, false)?
    109      .visit_field::<i32>("reposts", Self::VT_REPOSTS, false)?
    110      .visit_field::<i32>("zaps", Self::VT_ZAPS, false)?
    111      .visit_field::<i64>("zap_total", Self::VT_ZAP_TOTAL, false)?
    112      .finish();
    113     Ok(())
    114   }
    115 }
    116 pub struct NdbEventMetaArgs {
    117     pub received_at: i32,
    118     pub reactions: i32,
    119     pub quotes: i32,
    120     pub reposts: i32,
    121     pub zaps: i32,
    122     pub zap_total: i64,
    123 }
    124 impl<'a> Default for NdbEventMetaArgs {
    125   #[inline]
    126   fn default() -> Self {
    127     NdbEventMetaArgs {
    128       received_at: 0,
    129       reactions: 0,
    130       quotes: 0,
    131       reposts: 0,
    132       zaps: 0,
    133       zap_total: 0,
    134     }
    135   }
    136 }
    137 
    138 pub struct NdbEventMetaBuilder<'a: 'b, 'b> {
    139   fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
    140   start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
    141 }
    142 impl<'a: 'b, 'b> NdbEventMetaBuilder<'a, 'b> {
    143   #[inline]
    144   pub fn add_received_at(&mut self, received_at: i32) {
    145     self.fbb_.push_slot::<i32>(NdbEventMeta::VT_RECEIVED_AT, received_at, 0);
    146   }
    147   #[inline]
    148   pub fn add_reactions(&mut self, reactions: i32) {
    149     self.fbb_.push_slot::<i32>(NdbEventMeta::VT_REACTIONS, reactions, 0);
    150   }
    151   #[inline]
    152   pub fn add_quotes(&mut self, quotes: i32) {
    153     self.fbb_.push_slot::<i32>(NdbEventMeta::VT_QUOTES, quotes, 0);
    154   }
    155   #[inline]
    156   pub fn add_reposts(&mut self, reposts: i32) {
    157     self.fbb_.push_slot::<i32>(NdbEventMeta::VT_REPOSTS, reposts, 0);
    158   }
    159   #[inline]
    160   pub fn add_zaps(&mut self, zaps: i32) {
    161     self.fbb_.push_slot::<i32>(NdbEventMeta::VT_ZAPS, zaps, 0);
    162   }
    163   #[inline]
    164   pub fn add_zap_total(&mut self, zap_total: i64) {
    165     self.fbb_.push_slot::<i64>(NdbEventMeta::VT_ZAP_TOTAL, zap_total, 0);
    166   }
    167   #[inline]
    168   pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> NdbEventMetaBuilder<'a, 'b> {
    169     let start = _fbb.start_table();
    170     NdbEventMetaBuilder {
    171       fbb_: _fbb,
    172       start_: start,
    173     }
    174   }
    175   #[inline]
    176   pub fn finish(self) -> flatbuffers::WIPOffset<NdbEventMeta<'a>> {
    177     let o = self.fbb_.end_table(self.start_);
    178     flatbuffers::WIPOffset::new(o.value())
    179   }
    180 }
    181 
    182 impl core::fmt::Debug for NdbEventMeta<'_> {
    183   fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    184     let mut ds = f.debug_struct("NdbEventMeta");
    185       ds.field("received_at", &self.received_at());
    186       ds.field("reactions", &self.reactions());
    187       ds.field("quotes", &self.quotes());
    188       ds.field("reposts", &self.reposts());
    189       ds.field("zaps", &self.zaps());
    190       ds.field("zap_total", &self.zap_total());
    191       ds.finish()
    192   }
    193 }
    194 #[inline]
    195 /// Verifies that a buffer of bytes contains a `NdbEventMeta`
    196 /// and returns it.
    197 /// Note that verification is still experimental and may not
    198 /// catch every error, or be maximally performant. For the
    199 /// previous, unchecked, behavior use
    200 /// `root_as_ndb_event_meta_unchecked`.
    201 pub fn root_as_ndb_event_meta(buf: &[u8]) -> Result<NdbEventMeta, flatbuffers::InvalidFlatbuffer> {
    202   flatbuffers::root::<NdbEventMeta>(buf)
    203 }
    204 #[inline]
    205 /// Verifies that a buffer of bytes contains a size prefixed
    206 /// `NdbEventMeta` and returns it.
    207 /// Note that verification is still experimental and may not
    208 /// catch every error, or be maximally performant. For the
    209 /// previous, unchecked, behavior use
    210 /// `size_prefixed_root_as_ndb_event_meta_unchecked`.
    211 pub fn size_prefixed_root_as_ndb_event_meta(buf: &[u8]) -> Result<NdbEventMeta, flatbuffers::InvalidFlatbuffer> {
    212   flatbuffers::size_prefixed_root::<NdbEventMeta>(buf)
    213 }
    214 #[inline]
    215 /// Verifies, with the given options, that a buffer of bytes
    216 /// contains a `NdbEventMeta` and returns it.
    217 /// Note that verification is still experimental and may not
    218 /// catch every error, or be maximally performant. For the
    219 /// previous, unchecked, behavior use
    220 /// `root_as_ndb_event_meta_unchecked`.
    221 pub fn root_as_ndb_event_meta_with_opts<'b, 'o>(
    222   opts: &'o flatbuffers::VerifierOptions,
    223   buf: &'b [u8],
    224 ) -> Result<NdbEventMeta<'b>, flatbuffers::InvalidFlatbuffer> {
    225   flatbuffers::root_with_opts::<NdbEventMeta<'b>>(opts, buf)
    226 }
    227 #[inline]
    228 /// Verifies, with the given verifier options, that a buffer of
    229 /// bytes contains a size prefixed `NdbEventMeta` and returns
    230 /// it. Note that verification is still experimental and may not
    231 /// catch every error, or be maximally performant. For the
    232 /// previous, unchecked, behavior use
    233 /// `root_as_ndb_event_meta_unchecked`.
    234 pub fn size_prefixed_root_as_ndb_event_meta_with_opts<'b, 'o>(
    235   opts: &'o flatbuffers::VerifierOptions,
    236   buf: &'b [u8],
    237 ) -> Result<NdbEventMeta<'b>, flatbuffers::InvalidFlatbuffer> {
    238   flatbuffers::size_prefixed_root_with_opts::<NdbEventMeta<'b>>(opts, buf)
    239 }
    240 #[inline]
    241 /// Assumes, without verification, that a buffer of bytes contains a NdbEventMeta and returns it.
    242 /// # Safety
    243 /// Callers must trust the given bytes do indeed contain a valid `NdbEventMeta`.
    244 pub unsafe fn root_as_ndb_event_meta_unchecked(buf: &[u8]) -> NdbEventMeta {
    245   flatbuffers::root_unchecked::<NdbEventMeta>(buf)
    246 }
    247 #[inline]
    248 /// Assumes, without verification, that a buffer of bytes contains a size prefixed NdbEventMeta and returns it.
    249 /// # Safety
    250 /// Callers must trust the given bytes do indeed contain a valid size prefixed `NdbEventMeta`.
    251 pub unsafe fn size_prefixed_root_as_ndb_event_meta_unchecked(buf: &[u8]) -> NdbEventMeta {
    252   flatbuffers::size_prefixed_root_unchecked::<NdbEventMeta>(buf)
    253 }
    254 #[inline]
    255 pub fn finish_ndb_event_meta_buffer<'a, 'b>(
    256     fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
    257     root: flatbuffers::WIPOffset<NdbEventMeta<'a>>) {
    258   fbb.finish(root, None);
    259 }
    260 
    261 #[inline]
    262 pub fn finish_size_prefixed_ndb_event_meta_buffer<'a, 'b>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, root: flatbuffers::WIPOffset<NdbEventMeta<'a>>) {
    263   fbb.finish_size_prefixed(root, None);
    264 }