use std::cmp::Ordering;
use std::mem;
extern crate flatbuffers;
use self::flatbuffers::{EndianScalar, Follow};
#[deprecated(
since = "2.0.0",
note = "Use associated constants instead. This will no longer be generated in 2021."
)]
pub const ENUM_MIN_COMPRESSION: i32 = 0;
#[deprecated(
since = "2.0.0",
note = "Use associated constants instead. This will no longer be generated in 2021."
)]
pub const ENUM_MAX_COMPRESSION: i32 = 4;
#[deprecated(
since = "2.0.0",
note = "Use associated constants instead. This will no longer be generated in 2021."
)]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_COMPRESSION: [Compression; 5] = [
Compression::None,
Compression::Lz4,
Compression::Lz4High,
Compression::Zstd,
Compression::ZstdHigh,
];
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct Compression(pub i32);
#[allow(non_upper_case_globals)]
impl Compression {
pub const None: Self = Self(0);
pub const Lz4: Self = Self(1);
pub const Lz4High: Self = Self(2);
pub const Zstd: Self = Self(3);
pub const ZstdHigh: Self = Self(4);
pub const ENUM_MIN: i32 = 0;
pub const ENUM_MAX: i32 = 4;
pub const ENUM_VALUES: &'static [Self] = &[
Self::None,
Self::Lz4,
Self::Lz4High,
Self::Zstd,
Self::ZstdHigh,
];
pub fn variant_name(self) -> Option<&'static str> {
match self {
Self::None => Some("None"),
Self::Lz4 => Some("Lz4"),
Self::Lz4High => Some("Lz4High"),
Self::Zstd => Some("Zstd"),
Self::ZstdHigh => Some("ZstdHigh"),
_ => None,
}
}
}
impl std::fmt::Debug for Compression {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
if let Some(name) = self.variant_name() {
f.write_str(name)
} else {
f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
}
}
}
impl<'a> flatbuffers::Follow<'a> for Compression {
type Inner = Self;
#[inline]
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { flatbuffers::read_scalar_at::<i32>(buf, loc) };
Self(b)
}
}
impl flatbuffers::Push for Compression {
type Output = Compression;
#[inline]
fn push(&self, dst: &mut [u8], _rest: &[u8]) {
unsafe {
flatbuffers::emplace_scalar::<i32>(dst, self.0);
}
}
}
impl flatbuffers::EndianScalar for Compression {
#[inline]
fn to_little_endian(self) -> Self {
let b = i32::to_le(self.0);
Self(b)
}
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(self) -> Self {
let b = i32::from_le(self.0);
Self(b)
}
}
impl<'a> flatbuffers::Verifiable for Compression {
#[inline]
fn run_verifier(
v: &mut flatbuffers::Verifier,
pos: usize,
) -> Result<(), flatbuffers::InvalidFlatbuffer> {
use self::flatbuffers::Verifiable;
i32::run_verifier(v, pos)
}
}
impl flatbuffers::SimpleToVerifyInSlice for Compression {}
pub enum IoheaderOffset {}
#[derive(Copy, Clone, PartialEq)]
pub struct Ioheader<'a> {
pub _tab: flatbuffers::Table<'a>,
}
impl<'a> flatbuffers::Follow<'a> for Ioheader<'a> {
type Inner = Ioheader<'a>;
#[inline]
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
_tab: flatbuffers::Table { buf, loc },
}
}
}
impl<'a> Ioheader<'a> {
#[inline]
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
Ioheader { _tab: table }
}
#[allow(unused_mut)]
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
args: &'args IoheaderArgs<'args>,
) -> flatbuffers::WIPOffset<Ioheader<'bldr>> {
let mut builder = IoheaderBuilder::new(_fbb);
builder.add_file_data_position(args.file_data_position);
if let Some(x) = args.description {
builder.add_description(x);
}
builder.add_compression(args.compression);
builder.finish()
}
pub const VT_COMPRESSION: flatbuffers::VOffsetT = 4;
pub const VT_FILE_DATA_POSITION: flatbuffers::VOffsetT = 6;
pub const VT_DESCRIPTION: flatbuffers::VOffsetT = 8;
#[inline]
pub fn compression(&self) -> Compression {
self._tab
.get::<Compression>(Ioheader::VT_COMPRESSION, Some(Compression::None))
.unwrap()
}
#[inline]
pub fn file_data_position(&self) -> i64 {
self._tab
.get::<i64>(Ioheader::VT_FILE_DATA_POSITION, Some(-1))
.unwrap()
}
#[inline]
pub fn description(&self) -> Option<&'a str> {
self._tab
.get::<flatbuffers::ForwardsUOffset<&str>>(Ioheader::VT_DESCRIPTION, None)
}
}
impl flatbuffers::Verifiable for Ioheader<'_> {
#[inline]
fn run_verifier(
v: &mut flatbuffers::Verifier,
pos: usize,
) -> Result<(), flatbuffers::InvalidFlatbuffer> {
use self::flatbuffers::Verifiable;
v.visit_table(pos)?
.visit_field::<Compression>(&"compression", Self::VT_COMPRESSION, false)?
.visit_field::<i64>(&"file_data_position", Self::VT_FILE_DATA_POSITION, false)?
.visit_field::<flatbuffers::ForwardsUOffset<&str>>(
&"description",
Self::VT_DESCRIPTION,
false,
)?
.finish();
Ok(())
}
}
pub struct IoheaderArgs<'a> {
pub compression: Compression,
pub file_data_position: i64,
pub description: Option<flatbuffers::WIPOffset<&'a str>>,
}
impl<'a> Default for IoheaderArgs<'a> {
#[inline]
fn default() -> Self {
IoheaderArgs {
compression: Compression::None,
file_data_position: -1,
description: None,
}
}
}
pub struct IoheaderBuilder<'a: 'b, 'b> {
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b> IoheaderBuilder<'a, 'b> {
#[inline]
pub fn add_compression(&mut self, compression: Compression) {
self.fbb_.push_slot::<Compression>(
Ioheader::VT_COMPRESSION,
compression,
Compression::None,
);
}
#[inline]
pub fn add_file_data_position(&mut self, file_data_position: i64) {
self.fbb_
.push_slot::<i64>(Ioheader::VT_FILE_DATA_POSITION, file_data_position, -1);
}
#[inline]
pub fn add_description(&mut self, description: flatbuffers::WIPOffset<&'b str>) {
self.fbb_
.push_slot_always::<flatbuffers::WIPOffset<_>>(Ioheader::VT_DESCRIPTION, description);
}
#[inline]
pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> IoheaderBuilder<'a, 'b> {
let start = _fbb.start_table();
IoheaderBuilder {
fbb_: _fbb,
start_: start,
}
}
#[inline]
pub fn finish(self) -> flatbuffers::WIPOffset<Ioheader<'a>> {
let o = self.fbb_.end_table(self.start_);
flatbuffers::WIPOffset::new(o.value())
}
}
impl std::fmt::Debug for Ioheader<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut ds = f.debug_struct("Ioheader");
ds.field("compression", &self.compression());
ds.field("file_data_position", &self.file_data_position());
ds.field("description", &self.description());
ds.finish()
}
}
#[inline]
#[deprecated(since = "2.0.0", note = "Deprecated in favor of `root_as...` methods.")]
pub fn get_root_as_ioheader<'a>(buf: &'a [u8]) -> Ioheader<'a> {
unsafe { flatbuffers::root_unchecked::<Ioheader<'a>>(buf) }
}
#[inline]
#[deprecated(since = "2.0.0", note = "Deprecated in favor of `root_as...` methods.")]
pub fn get_size_prefixed_root_as_ioheader<'a>(buf: &'a [u8]) -> Ioheader<'a> {
unsafe { flatbuffers::size_prefixed_root_unchecked::<Ioheader<'a>>(buf) }
}
#[inline]
pub fn root_as_ioheader(buf: &[u8]) -> Result<Ioheader, flatbuffers::InvalidFlatbuffer> {
flatbuffers::root::<Ioheader>(buf)
}
#[inline]
pub fn size_prefixed_root_as_ioheader(
buf: &[u8],
) -> Result<Ioheader, flatbuffers::InvalidFlatbuffer> {
flatbuffers::size_prefixed_root::<Ioheader>(buf)
}
#[inline]
pub fn root_as_ioheader_with_opts<'b, 'o>(
opts: &'o flatbuffers::VerifierOptions,
buf: &'b [u8],
) -> Result<Ioheader<'b>, flatbuffers::InvalidFlatbuffer> {
flatbuffers::root_with_opts::<Ioheader<'b>>(opts, buf)
}
#[inline]
pub fn size_prefixed_root_as_ioheader_with_opts<'b, 'o>(
opts: &'o flatbuffers::VerifierOptions,
buf: &'b [u8],
) -> Result<Ioheader<'b>, flatbuffers::InvalidFlatbuffer> {
flatbuffers::size_prefixed_root_with_opts::<Ioheader<'b>>(opts, buf)
}
#[inline]
pub unsafe fn root_as_ioheader_unchecked(buf: &[u8]) -> Ioheader {
flatbuffers::root_unchecked::<Ioheader>(buf)
}
#[inline]
pub unsafe fn size_prefixed_root_as_ioheader_unchecked(buf: &[u8]) -> Ioheader {
flatbuffers::size_prefixed_root_unchecked::<Ioheader>(buf)
}
pub const IOHEADER_IDENTIFIER: &str = "IOHE";
#[inline]
pub fn ioheader_buffer_has_identifier(buf: &[u8]) -> bool {
flatbuffers::buffer_has_identifier(buf, IOHEADER_IDENTIFIER, false)
}
#[inline]
pub fn ioheader_size_prefixed_buffer_has_identifier(buf: &[u8]) -> bool {
flatbuffers::buffer_has_identifier(buf, IOHEADER_IDENTIFIER, true)
}
#[inline]
pub fn finish_ioheader_buffer<'a, 'b>(
fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
root: flatbuffers::WIPOffset<Ioheader<'a>>,
) {
fbb.finish(root, Some(IOHEADER_IDENTIFIER));
}
#[inline]
pub fn finish_size_prefixed_ioheader_buffer<'a, 'b>(
fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
root: flatbuffers::WIPOffset<Ioheader<'a>>,
) {
fbb.finish_size_prefixed(root, Some(IOHEADER_IDENTIFIER));
}