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

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

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

impl<'a> ACL<'a> {
  pub const VT_ID: flatbuffers::VOffsetT = 4;
  pub const VT_MSGTYPE: flatbuffers::VOffsetT = 6;
  pub const VT_COMMAND: flatbuffers::VOffsetT = 8;
  pub const VT_PAYLOAD: flatbuffers::VOffsetT = 10;

  #[inline]
  pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
    ACL { _tab: table }
  }
  #[allow(unused_mut)]
  pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
    _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
    args: &'args ACLArgs<'args>
  ) -> flatbuffers::WIPOffset<ACL<'bldr>> {
    let mut builder = ACLBuilder::new(_fbb);
    if let Some(x) = args.payload { builder.add_payload(x); }
    if let Some(x) = args.id { builder.add_id(x); }
    builder.add_command(args.command);
    builder.add_msgtype(args.msgtype);
    builder.finish()
  }


  #[inline]
  pub fn id(&self) -> Option<&'a str> {
    self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(ACL::VT_ID, None)
  }
  #[inline]
  pub fn msgtype(&self) -> MsgType {
    self._tab.get::<MsgType>(ACL::VT_MSGTYPE, Some(MsgType::MSG)).unwrap()
  }
  #[inline]
  pub fn command(&self) -> ACLCommand {
    self._tab.get::<ACLCommand>(ACL::VT_COMMAND, Some(ACLCommand::LIST)).unwrap()
  }
  #[inline]
  pub fn payload(&self) -> Option<&'a [u8]> {
    self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, u8>>>(ACL::VT_PAYLOAD, None).map(|v| v.safe_slice())
  }
}

impl flatbuffers::Verifiable for ACL<'_> {
  #[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::<ACLCommand>("command", Self::VT_COMMAND, false)?
     .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, u8>>>("payload", Self::VT_PAYLOAD, false)?
     .finish();
    Ok(())
  }
}
pub struct ACLArgs<'a> {
    pub id: Option<flatbuffers::WIPOffset<&'a str>>,
    pub msgtype: MsgType,
    pub command: ACLCommand,
    pub payload: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, u8>>>,
}
impl<'a> Default for ACLArgs<'a> {
  #[inline]
  fn default() -> Self {
    ACLArgs {
      id: None,
      msgtype: MsgType::MSG,
      command: ACLCommand::LIST,
      payload: None,
    }
  }
}

pub struct ACLBuilder<'a: 'b, 'b> {
  fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
  start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b> ACLBuilder<'a, 'b> {
  #[inline]
  pub fn add_id(&mut self, id: flatbuffers::WIPOffset<&'b  str>) {
    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(ACL::VT_ID, id);
  }
  #[inline]
  pub fn add_msgtype(&mut self, msgtype: MsgType) {
    self.fbb_.push_slot::<MsgType>(ACL::VT_MSGTYPE, msgtype, MsgType::MSG);
  }
  #[inline]
  pub fn add_command(&mut self, command: ACLCommand) {
    self.fbb_.push_slot::<ACLCommand>(ACL::VT_COMMAND, command, ACLCommand::LIST);
  }
  #[inline]
  pub fn add_payload(&mut self, payload: flatbuffers::WIPOffset<flatbuffers::Vector<'b , u8>>) {
    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(ACL::VT_PAYLOAD, payload);
  }
  #[inline]
  pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> ACLBuilder<'a, 'b> {
    let start = _fbb.start_table();
    ACLBuilder {
      fbb_: _fbb,
      start_: start,
    }
  }
  #[inline]
  pub fn finish(self) -> flatbuffers::WIPOffset<ACL<'a>> {
    let o = self.fbb_.end_table(self.start_);
    flatbuffers::WIPOffset::new(o.value())
  }
}

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

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

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

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