// 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 WeaponLevelTemplateOffset {}
#[derive(Copy, Clone, PartialEq)]

pub struct WeaponLevelTemplate<'a> {
  pub _tab: flatbuffers::Table<'a>,
}

impl<'a> flatbuffers::Follow<'a> for WeaponLevelTemplate<'a> {
  type Inner = WeaponLevelTemplate<'a>;
  #[inline]
  unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
    Self { _tab: flatbuffers::Table::new(buf, loc) }
  }
}

impl<'a> WeaponLevelTemplate<'a> {
  pub const VT_RARITY: flatbuffers::VOffsetT = 4;
  pub const VT_LEVEL: flatbuffers::VOffsetT = 6;
  pub const VT_RATE: flatbuffers::VOffsetT = 8;
  pub const VT_EXP: flatbuffers::VOffsetT = 10;

  #[inline]
  pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
    WeaponLevelTemplate { _tab: table }
  }
  #[allow(unused_mut)]
  pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>(
    _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,
    args: &'args WeaponLevelTemplateArgs
  ) -> flatbuffers::WIPOffset<WeaponLevelTemplate<'bldr>> {
    let mut builder = WeaponLevelTemplateBuilder::new(_fbb);
    builder.add_exp(args.exp);
    builder.add_rate(args.rate);
    builder.add_level(args.level);
    builder.add_rarity(args.rarity);
    builder.finish()
  }


  #[inline]
  pub fn rarity(&self) -> u32 {
    // Safety:
    // Created from valid Table for this object
    // which contains a valid value in this slot
    unsafe { self._tab.get::<u32>(WeaponLevelTemplate::VT_RARITY, Some(0)).unwrap()}
  }
  #[inline]
  pub fn level(&self) -> u32 {
    // Safety:
    // Created from valid Table for this object
    // which contains a valid value in this slot
    unsafe { self._tab.get::<u32>(WeaponLevelTemplate::VT_LEVEL, Some(0)).unwrap()}
  }
  #[inline]
  pub fn rate(&self) -> u32 {
    // Safety:
    // Created from valid Table for this object
    // which contains a valid value in this slot
    unsafe { self._tab.get::<u32>(WeaponLevelTemplate::VT_RATE, Some(0)).unwrap()}
  }
  #[inline]
  pub fn exp(&self) -> u32 {
    // Safety:
    // Created from valid Table for this object
    // which contains a valid value in this slot
    unsafe { self._tab.get::<u32>(WeaponLevelTemplate::VT_EXP, Some(0)).unwrap()}
  }
}

impl flatbuffers::Verifiable for WeaponLevelTemplate<'_> {
  #[inline]
  fn run_verifier(
    v: &mut flatbuffers::Verifier, pos: usize
  ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
    use self::flatbuffers::Verifiable;
    v.visit_table(pos)?
     .visit_field::<u32>("rarity", Self::VT_RARITY, false)?
     .visit_field::<u32>("level", Self::VT_LEVEL, false)?
     .visit_field::<u32>("rate", Self::VT_RATE, false)?
     .visit_field::<u32>("exp", Self::VT_EXP, false)?
     .finish();
    Ok(())
  }
}
pub struct WeaponLevelTemplateArgs {
    pub rarity: u32,
    pub level: u32,
    pub rate: u32,
    pub exp: u32,
}
impl<'a> Default for WeaponLevelTemplateArgs {
  #[inline]
  fn default() -> Self {
    WeaponLevelTemplateArgs {
      rarity: 0,
      level: 0,
      rate: 0,
      exp: 0,
    }
  }
}

pub struct WeaponLevelTemplateBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
  fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
  start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> WeaponLevelTemplateBuilder<'a, 'b, A> {
  #[inline]
  pub fn add_rarity(&mut self, rarity: u32) {
    self.fbb_.push_slot::<u32>(WeaponLevelTemplate::VT_RARITY, rarity, 0);
  }
  #[inline]
  pub fn add_level(&mut self, level: u32) {
    self.fbb_.push_slot::<u32>(WeaponLevelTemplate::VT_LEVEL, level, 0);
  }
  #[inline]
  pub fn add_rate(&mut self, rate: u32) {
    self.fbb_.push_slot::<u32>(WeaponLevelTemplate::VT_RATE, rate, 0);
  }
  #[inline]
  pub fn add_exp(&mut self, exp: u32) {
    self.fbb_.push_slot::<u32>(WeaponLevelTemplate::VT_EXP, exp, 0);
  }
  #[inline]
  pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> WeaponLevelTemplateBuilder<'a, 'b, A> {
    let start = _fbb.start_table();
    WeaponLevelTemplateBuilder {
      fbb_: _fbb,
      start_: start,
    }
  }
  #[inline]
  pub fn finish(self) -> flatbuffers::WIPOffset<WeaponLevelTemplate<'a>> {
    let o = self.fbb_.end_table(self.start_);
    flatbuffers::WIPOffset::new(o.value())
  }
}

impl core::fmt::Debug for WeaponLevelTemplate<'_> {
  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    let mut ds = f.debug_struct("WeaponLevelTemplate");
      ds.field("rarity", &self.rarity());
      ds.field("level", &self.level());
      ds.field("rate", &self.rate());
      ds.field("exp", &self.exp());
      ds.finish()
  }
}
pub enum WeaponLevelTemplateTbOffset {}
#[derive(Copy, Clone, PartialEq)]

pub struct WeaponLevelTemplateTb<'a> {
  pub _tab: flatbuffers::Table<'a>,
}

impl<'a> flatbuffers::Follow<'a> for WeaponLevelTemplateTb<'a> {
  type Inner = WeaponLevelTemplateTb<'a>;
  #[inline]
  unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
    Self { _tab: flatbuffers::Table::new(buf, loc) }
  }
}

impl<'a> WeaponLevelTemplateTb<'a> {
  pub const VT_DATA: flatbuffers::VOffsetT = 4;

  #[inline]
  pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
    WeaponLevelTemplateTb { _tab: table }
  }
  #[allow(unused_mut)]
  pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>(
    _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,
    args: &'args WeaponLevelTemplateTbArgs<'args>
  ) -> flatbuffers::WIPOffset<WeaponLevelTemplateTb<'bldr>> {
    let mut builder = WeaponLevelTemplateTbBuilder::new(_fbb);
    if let Some(x) = args.data { builder.add_data(x); }
    builder.finish()
  }


  #[inline]
  pub fn data(&self) -> Option<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<WeaponLevelTemplate<'a>>>> {
    // Safety:
    // Created from valid Table for this object
    // which contains a valid value in this slot
    unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<WeaponLevelTemplate>>>>(WeaponLevelTemplateTb::VT_DATA, None)}
  }
}

impl flatbuffers::Verifiable for WeaponLevelTemplateTb<'_> {
  #[inline]
  fn run_verifier(
    v: &mut flatbuffers::Verifier, pos: usize
  ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
    use self::flatbuffers::Verifiable;
    v.visit_table(pos)?
     .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, flatbuffers::ForwardsUOffset<WeaponLevelTemplate>>>>("data", Self::VT_DATA, false)?
     .finish();
    Ok(())
  }
}
pub struct WeaponLevelTemplateTbArgs<'a> {
    pub data: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<WeaponLevelTemplate<'a>>>>>,
}
impl<'a> Default for WeaponLevelTemplateTbArgs<'a> {
  #[inline]
  fn default() -> Self {
    WeaponLevelTemplateTbArgs {
      data: None,
    }
  }
}

pub struct WeaponLevelTemplateTbBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
  fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
  start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> WeaponLevelTemplateTbBuilder<'a, 'b, A> {
  #[inline]
  pub fn add_data(&mut self, data: flatbuffers::WIPOffset<flatbuffers::Vector<'b , flatbuffers::ForwardsUOffset<WeaponLevelTemplate<'b >>>>) {
    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(WeaponLevelTemplateTb::VT_DATA, data);
  }
  #[inline]
  pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> WeaponLevelTemplateTbBuilder<'a, 'b, A> {
    let start = _fbb.start_table();
    WeaponLevelTemplateTbBuilder {
      fbb_: _fbb,
      start_: start,
    }
  }
  #[inline]
  pub fn finish(self) -> flatbuffers::WIPOffset<WeaponLevelTemplateTb<'a>> {
    let o = self.fbb_.end_table(self.start_);
    flatbuffers::WIPOffset::new(o.value())
  }
}

impl core::fmt::Debug for WeaponLevelTemplateTb<'_> {
  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    let mut ds = f.debug_struct("WeaponLevelTemplateTb");
      ds.field("data", &self.data());
      ds.finish()
  }
}
