extern crate flatbuffers;
use std::mem;
use std::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum NotificationOffset {}
#[derive(Copy, Clone, PartialEq)]
pub struct Notification<'a> {
pub _tab: flatbuffers::Table<'a>,
}
impl<'a> flatbuffers::Follow<'a> for Notification<'a> {
type Inner = Notification<'a>;
#[inline]
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: flatbuffers::Table { buf, loc } }
}
}
impl<'a> Notification<'a> {
pub const VT_ID: flatbuffers::VOffsetT = 4;
pub const VT_MSGTYPE: flatbuffers::VOffsetT = 6;
pub const VT_ERROR: flatbuffers::VOffsetT = 8;
pub const VT_ERRTYPE: flatbuffers::VOffsetT = 10;
#[inline]
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
Notification { _tab: table }
}
#[allow(unused_mut)]
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
args: &'args NotificationArgs<'args>
) -> flatbuffers::WIPOffset<Notification<'bldr>> {
let mut builder = NotificationBuilder::new(_fbb);
if let Some(x) = args.error { builder.add_error(x); }
if let Some(x) = args.id { builder.add_id(x); }
builder.add_errtype(args.errtype);
builder.add_msgtype(args.msgtype);
builder.finish()
}
#[inline]
pub fn id(&self) -> Option<&'a str> {
self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(Notification::VT_ID, None)
}
#[inline]
pub fn msgtype(&self) -> MsgType {
self._tab.get::<MsgType>(Notification::VT_MSGTYPE, Some(MsgType::MSG)).unwrap()
}
#[inline]
pub fn error(&self) -> Option<&'a str> {
self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(Notification::VT_ERROR, None)
}
#[inline]
pub fn errtype(&self) -> ErrType {
self._tab.get::<ErrType>(Notification::VT_ERRTYPE, Some(ErrType::ErrConnection)).unwrap()
}
}
impl flatbuffers::Verifiable for Notification<'_> {
#[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>>("error", Self::VT_ERROR, false)?
.visit_field::<ErrType>("errtype", Self::VT_ERRTYPE, false)?
.finish();
Ok(())
}
}
pub struct NotificationArgs<'a> {
pub id: Option<flatbuffers::WIPOffset<&'a str>>,
pub msgtype: MsgType,
pub error: Option<flatbuffers::WIPOffset<&'a str>>,
pub errtype: ErrType,
}
impl<'a> Default for NotificationArgs<'a> {
#[inline]
fn default() -> Self {
NotificationArgs {
id: None,
msgtype: MsgType::MSG,
error: None,
errtype: ErrType::ErrConnection,
}
}
}
pub struct NotificationBuilder<'a: 'b, 'b> {
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b> NotificationBuilder<'a, 'b> {
#[inline]
pub fn add_id(&mut self, id: flatbuffers::WIPOffset<&'b str>) {
self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Notification::VT_ID, id);
}
#[inline]
pub fn add_msgtype(&mut self, msgtype: MsgType) {
self.fbb_.push_slot::<MsgType>(Notification::VT_MSGTYPE, msgtype, MsgType::MSG);
}
#[inline]
pub fn add_error(&mut self, error: flatbuffers::WIPOffset<&'b str>) {
self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Notification::VT_ERROR, error);
}
#[inline]
pub fn add_errtype(&mut self, errtype: ErrType) {
self.fbb_.push_slot::<ErrType>(Notification::VT_ERRTYPE, errtype, ErrType::ErrConnection);
}
#[inline]
pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> NotificationBuilder<'a, 'b> {
let start = _fbb.start_table();
NotificationBuilder {
fbb_: _fbb,
start_: start,
}
}
#[inline]
pub fn finish(self) -> flatbuffers::WIPOffset<Notification<'a>> {
let o = self.fbb_.end_table(self.start_);
flatbuffers::WIPOffset::new(o.value())
}
}
impl std::fmt::Debug for Notification<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut ds = f.debug_struct("Notification");
ds.field("id", &self.id());
ds.field("msgtype", &self.msgtype());
ds.field("error", &self.error());
ds.field("errtype", &self.errtype());
ds.finish()
}
}
#[inline]
#[deprecated(since="2.0.0", note="Deprecated in favor of `root_as...` methods.")]
pub fn get_root_as_notification<'a>(buf: &'a [u8]) -> Notification<'a> {
unsafe { flatbuffers::root_unchecked::<Notification<'a>>(buf) }
}
#[inline]
#[deprecated(since="2.0.0", note="Deprecated in favor of `root_as...` methods.")]
pub fn get_size_prefixed_root_as_notification<'a>(buf: &'a [u8]) -> Notification<'a> {
unsafe { flatbuffers::size_prefixed_root_unchecked::<Notification<'a>>(buf) }
}
#[inline]
pub fn root_as_notification(buf: &[u8]) -> Result<Notification, flatbuffers::InvalidFlatbuffer> {
flatbuffers::root::<Notification>(buf)
}
#[inline]
pub fn size_prefixed_root_as_notification(buf: &[u8]) -> Result<Notification, flatbuffers::InvalidFlatbuffer> {
flatbuffers::size_prefixed_root::<Notification>(buf)
}
#[inline]
pub fn root_as_notification_with_opts<'b, 'o>(
opts: &'o flatbuffers::VerifierOptions,
buf: &'b [u8],
) -> Result<Notification<'b>, flatbuffers::InvalidFlatbuffer> {
flatbuffers::root_with_opts::<Notification<'b>>(opts, buf)
}
#[inline]
pub fn size_prefixed_root_as_notification_with_opts<'b, 'o>(
opts: &'o flatbuffers::VerifierOptions,
buf: &'b [u8],
) -> Result<Notification<'b>, flatbuffers::InvalidFlatbuffer> {
flatbuffers::size_prefixed_root_with_opts::<Notification<'b>>(opts, buf)
}
#[inline]
pub unsafe fn root_as_notification_unchecked(buf: &[u8]) -> Notification {
flatbuffers::root_unchecked::<Notification>(buf)
}
#[inline]
pub unsafe fn size_prefixed_root_as_notification_unchecked(buf: &[u8]) -> Notification {
flatbuffers::size_prefixed_root_unchecked::<Notification>(buf)
}
#[inline]
pub fn finish_notification_buffer<'a, 'b>(
fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
root: flatbuffers::WIPOffset<Notification<'a>>) {
fbb.finish(root, None);
}
#[inline]
pub fn finish_size_prefixed_notification_buffer<'a, 'b>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, root: flatbuffers::WIPOffset<Notification<'a>>) {
fbb.finish_size_prefixed(root, None);
}