self_sdk 0.1.0

An SDK for interacting with the self network
Documentation
// automatically generated by the FlatBuffers compiler, do not modify
extern crate flatbuffers;
use std::mem;
use std::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum AuthOffset {}
#[derive(Copy, Clone, PartialEq)]

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

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

impl<'a> Auth<'a> {
  pub const VT_ID: flatbuffers::VOffsetT = 4;
  pub const VT_MSGTYPE: flatbuffers::VOffsetT = 6;
  pub const VT_TOKEN: flatbuffers::VOffsetT = 8;
  pub const VT_DEVICE: flatbuffers::VOffsetT = 10;
  pub const VT_OFFSET: flatbuffers::VOffsetT = 12;

  #[inline]
  pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
    Auth { _tab: table }
  }
  #[allow(unused_mut)]
  pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
    _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
    args: &'args AuthArgs<'args>
  ) -> flatbuffers::WIPOffset<Auth<'bldr>> {
    let mut builder = AuthBuilder::new(_fbb);
    builder.add_offset(args.offset);
    if let Some(x) = args.device { builder.add_device(x); }
    if let Some(x) = args.token { builder.add_token(x); }
    if let Some(x) = args.id { builder.add_id(x); }
    builder.add_msgtype(args.msgtype);
    builder.finish()
  }


  #[inline]
  pub fn id(&self) -> Option<&'a str> {
    self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(Auth::VT_ID, None)
  }
  #[inline]
  pub fn msgtype(&self) -> MsgType {
    self._tab.get::<MsgType>(Auth::VT_MSGTYPE, Some(MsgType::MSG)).unwrap()
  }
  #[inline]
  pub fn token(&self) -> Option<&'a str> {
    self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(Auth::VT_TOKEN, None)
  }
  #[inline]
  pub fn device(&self) -> Option<&'a str> {
    self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(Auth::VT_DEVICE, None)
  }
  #[inline]
  pub fn offset(&self) -> i64 {
    self._tab.get::<i64>(Auth::VT_OFFSET, Some(0)).unwrap()
  }
}

impl flatbuffers::Verifiable for Auth<'_> {
  #[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<&str>>("id", Self::VT_ID, false)?
     .visit_field::<MsgType>("msgtype", Self::VT_MSGTYPE, false)?
     .visit_field::<flatbuffers::ForwardsUOffset<&str>>("token", Self::VT_TOKEN, false)?
     .visit_field::<flatbuffers::ForwardsUOffset<&str>>("device", Self::VT_DEVICE, false)?
     .visit_field::<i64>("offset", Self::VT_OFFSET, false)?
     .finish();
    Ok(())
  }
}
pub struct AuthArgs<'a> {
    pub id: Option<flatbuffers::WIPOffset<&'a str>>,
    pub msgtype: MsgType,
    pub token: Option<flatbuffers::WIPOffset<&'a str>>,
    pub device: Option<flatbuffers::WIPOffset<&'a str>>,
    pub offset: i64,
}
impl<'a> Default for AuthArgs<'a> {
  #[inline]
  fn default() -> Self {
    AuthArgs {
      id: None,
      msgtype: MsgType::MSG,
      token: None,
      device: None,
      offset: 0,
    }
  }
}

pub struct AuthBuilder<'a: 'b, 'b> {
  fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
  start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b> AuthBuilder<'a, 'b> {
  #[inline]
  pub fn add_id(&mut self, id: flatbuffers::WIPOffset<&'b  str>) {
    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Auth::VT_ID, id);
  }
  #[inline]
  pub fn add_msgtype(&mut self, msgtype: MsgType) {
    self.fbb_.push_slot::<MsgType>(Auth::VT_MSGTYPE, msgtype, MsgType::MSG);
  }
  #[inline]
  pub fn add_token(&mut self, token: flatbuffers::WIPOffset<&'b  str>) {
    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Auth::VT_TOKEN, token);
  }
  #[inline]
  pub fn add_device(&mut self, device: flatbuffers::WIPOffset<&'b  str>) {
    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Auth::VT_DEVICE, device);
  }
  #[inline]
  pub fn add_offset(&mut self, offset: i64) {
    self.fbb_.push_slot::<i64>(Auth::VT_OFFSET, offset, 0);
  }
  #[inline]
  pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> AuthBuilder<'a, 'b> {
    let start = _fbb.start_table();
    AuthBuilder {
      fbb_: _fbb,
      start_: start,
    }
  }
  #[inline]
  pub fn finish(self) -> flatbuffers::WIPOffset<Auth<'a>> {
    let o = self.fbb_.end_table(self.start_);
    flatbuffers::WIPOffset::new(o.value())
  }
}

impl std::fmt::Debug for Auth<'_> {
  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
    let mut ds = f.debug_struct("Auth");
      ds.field("id", &self.id());
      ds.field("msgtype", &self.msgtype());
      ds.field("token", &self.token());
      ds.field("device", &self.device());
      ds.field("offset", &self.offset());
      ds.finish()
  }
}
#[inline]
#[deprecated(since="2.0.0", note="Deprecated in favor of `root_as...` methods.")]
pub fn get_root_as_auth<'a>(buf: &'a [u8]) -> Auth<'a> {
  unsafe { flatbuffers::root_unchecked::<Auth<'a>>(buf) }
}

#[inline]
#[deprecated(since="2.0.0", note="Deprecated in favor of `root_as...` methods.")]
pub fn get_size_prefixed_root_as_auth<'a>(buf: &'a [u8]) -> Auth<'a> {
  unsafe { flatbuffers::size_prefixed_root_unchecked::<Auth<'a>>(buf) }
}

#[inline]
/// Verifies that a buffer of bytes contains a `Auth`
/// 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_auth_unchecked`.
pub fn root_as_auth(buf: &[u8]) -> Result<Auth, flatbuffers::InvalidFlatbuffer> {
  flatbuffers::root::<Auth>(buf)
}
#[inline]
/// Verifies that a buffer of bytes contains a size prefixed
/// `Auth` 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_auth_unchecked`.
pub fn size_prefixed_root_as_auth(buf: &[u8]) -> Result<Auth, flatbuffers::InvalidFlatbuffer> {
  flatbuffers::size_prefixed_root::<Auth>(buf)
}
#[inline]
/// Verifies, with the given options, that a buffer of bytes
/// contains a `Auth` 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_auth_unchecked`.
pub fn root_as_auth_with_opts<'b, 'o>(
  opts: &'o flatbuffers::VerifierOptions,
  buf: &'b [u8],
) -> Result<Auth<'b>, flatbuffers::InvalidFlatbuffer> {
  flatbuffers::root_with_opts::<Auth<'b>>(opts, buf)
}
#[inline]
/// Verifies, with the given verifier options, that a buffer of
/// bytes contains a size prefixed `Auth` 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_auth_unchecked`.
pub fn size_prefixed_root_as_auth_with_opts<'b, 'o>(
  opts: &'o flatbuffers::VerifierOptions,
  buf: &'b [u8],
) -> Result<Auth<'b>, flatbuffers::InvalidFlatbuffer> {
  flatbuffers::size_prefixed_root_with_opts::<Auth<'b>>(opts, buf)
}
#[inline]
/// Assumes, without verification, that a buffer of bytes contains a Auth and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid `Auth`.
pub unsafe fn root_as_auth_unchecked(buf: &[u8]) -> Auth {
  flatbuffers::root_unchecked::<Auth>(buf)
}
#[inline]
/// Assumes, without verification, that a buffer of bytes contains a size prefixed Auth and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid size prefixed `Auth`.
pub unsafe fn size_prefixed_root_as_auth_unchecked(buf: &[u8]) -> Auth {
  flatbuffers::size_prefixed_root_unchecked::<Auth>(buf)
}
#[inline]
pub fn finish_auth_buffer<'a, 'b>(
    fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
    root: flatbuffers::WIPOffset<Auth<'a>>) {
  fbb.finish(root, None);
}

#[inline]
pub fn finish_size_prefixed_auth_buffer<'a, 'b>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, root: flatbuffers::WIPOffset<Auth<'a>>) {
  fbb.finish_size_prefixed(root, None);
}