"Fossies" - the Fresh Open Source Software Archive

Member "flatbuffers-23.1.21/tests/private_annotation_test/annotations_generated.rs" (21 Jan 2023, 3604 Bytes) of package /linux/misc/flatbuffers-23.1.21.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Rust source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 // automatically generated by the FlatBuffers compiler, do not modify
    2 // @generated
    3 extern crate alloc;
    4 extern crate flatbuffers;
    5 use alloc::boxed::Box;
    6 use alloc::string::{String, ToString};
    7 use alloc::vec::Vec;
    8 use core::mem;
    9 use core::cmp::Ordering;
   10 use self::flatbuffers::{EndianScalar, Follow};
   11 use super::*;
   12 pub(crate) enum AnnotationsOffset {}
   13 #[derive(Copy, Clone, PartialEq)]
   14 
   15 pub(crate) struct Annotations<'a> {
   16   pub _tab: flatbuffers::Table<'a>,
   17 }
   18 
   19 impl<'a> flatbuffers::Follow<'a> for Annotations<'a> {
   20   type Inner = Annotations<'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> Annotations<'a> {
   28   pub const VT_VALUE: flatbuffers::VOffsetT = 4;
   29 
   30   pub const fn get_fully_qualified_name() -> &'static str {
   31     "Annotations"
   32   }
   33 
   34   #[inline]
   35   pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
   36     Annotations { _tab: table }
   37   }
   38   #[allow(unused_mut)]
   39   pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
   40     _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
   41     args: &'args AnnotationsArgs
   42   ) -> flatbuffers::WIPOffset<Annotations<'bldr>> {
   43     let mut builder = AnnotationsBuilder::new(_fbb);
   44     builder.add_value(args.value);
   45     builder.finish()
   46   }
   47 
   48   pub fn unpack(&self) -> AnnotationsT {
   49     let value = self.value();
   50     AnnotationsT {
   51       value,
   52     }
   53   }
   54 
   55   #[inline]
   56   pub fn value(&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>(Annotations::VT_VALUE, Some(0)).unwrap()}
   61   }
   62 }
   63 
   64 impl flatbuffers::Verifiable for Annotations<'_> {
   65   #[inline]
   66   fn run_verifier(
   67     v: &mut flatbuffers::Verifier, pos: usize
   68   ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
   69     use self::flatbuffers::Verifiable;
   70     v.visit_table(pos)?
   71      .visit_field::<i32>("value", Self::VT_VALUE, false)?
   72      .finish();
   73     Ok(())
   74   }
   75 }
   76 pub(crate) struct AnnotationsArgs {
   77     pub value: i32,
   78 }
   79 impl<'a> Default for AnnotationsArgs {
   80   #[inline]
   81   fn default() -> Self {
   82     AnnotationsArgs {
   83       value: 0,
   84     }
   85   }
   86 }
   87 
   88 pub(crate) struct AnnotationsBuilder<'a: 'b, 'b> {
   89   fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
   90   start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
   91 }
   92 impl<'a: 'b, 'b> AnnotationsBuilder<'a, 'b> {
   93   #[inline]
   94   pub fn add_value(&mut self, value: i32) {
   95     self.fbb_.push_slot::<i32>(Annotations::VT_VALUE, value, 0);
   96   }
   97   #[inline]
   98   pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> AnnotationsBuilder<'a, 'b> {
   99     let start = _fbb.start_table();
  100     AnnotationsBuilder {
  101       fbb_: _fbb,
  102       start_: start,
  103     }
  104   }
  105   #[inline]
  106   pub fn finish(self) -> flatbuffers::WIPOffset<Annotations<'a>> {
  107     let o = self.fbb_.end_table(self.start_);
  108     flatbuffers::WIPOffset::new(o.value())
  109   }
  110 }
  111 
  112 impl core::fmt::Debug for Annotations<'_> {
  113   fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
  114     let mut ds = f.debug_struct("Annotations");
  115       ds.field("value", &self.value());
  116       ds.finish()
  117   }
  118 }
  119 #[non_exhaustive]
  120 #[derive(Debug, Clone, PartialEq)]
  121 pub(crate) struct AnnotationsT {
  122   pub value: i32,
  123 }
  124 impl Default for AnnotationsT {
  125   fn default() -> Self {
  126     Self {
  127       value: 0,
  128     }
  129   }
  130 }
  131 impl AnnotationsT {
  132   pub fn pack<'b>(
  133     &self,
  134     _fbb: &mut flatbuffers::FlatBufferBuilder<'b>
  135   ) -> flatbuffers::WIPOffset<Annotations<'b>> {
  136     let value = self.value;
  137     Annotations::create(_fbb, &AnnotationsArgs{
  138       value,
  139     })
  140   }
  141 }