use crate::dtype::*;
use core::mem;
use core::cmp::Ordering;
extern crate flatbuffers;
use self::flatbuffers::{EndianScalar, Follow};
pub enum ScalarOffset {}
#[derive(Copy, Clone, PartialEq)]
pub struct Scalar<'a> {
pub _tab: flatbuffers::Table<'a>,
}
impl<'a> flatbuffers::Follow<'a> for Scalar<'a> {
type Inner = Scalar<'a>;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: flatbuffers::Table::new(buf, loc) }
}
}
impl<'a> Scalar<'a> {
pub const VT_DTYPE: flatbuffers::VOffsetT = 4;
pub const VT_VALUE: flatbuffers::VOffsetT = 6;
#[inline]
pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
Scalar { _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 ScalarArgs<'args>
) -> flatbuffers::WIPOffset<Scalar<'bldr>> {
let mut builder = ScalarBuilder::new(_fbb);
if let Some(x) = args.value { builder.add_value(x); }
if let Some(x) = args.dtype { builder.add_dtype(x); }
builder.finish()
}
#[inline]
pub fn dtype(&self) -> DType<'a> {
unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<DType>>(Scalar::VT_DTYPE, None).unwrap()}
}
#[inline]
pub fn value(&self) -> ScalarValue<'a> {
unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<ScalarValue>>(Scalar::VT_VALUE, None).unwrap()}
}
}
impl flatbuffers::Verifiable for Scalar<'_> {
#[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<DType>>("dtype", Self::VT_DTYPE, true)?
.visit_field::<flatbuffers::ForwardsUOffset<ScalarValue>>("value", Self::VT_VALUE, true)?
.finish();
Ok(())
}
}
pub struct ScalarArgs<'a> {
pub dtype: Option<flatbuffers::WIPOffset<DType<'a>>>,
pub value: Option<flatbuffers::WIPOffset<ScalarValue<'a>>>,
}
impl<'a> Default for ScalarArgs<'a> {
#[inline]
fn default() -> Self {
ScalarArgs {
dtype: None, value: None, }
}
}
pub struct ScalarBuilder<'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> ScalarBuilder<'a, 'b, A> {
#[inline]
pub fn add_dtype(&mut self, dtype: flatbuffers::WIPOffset<DType<'b >>) {
self.fbb_.push_slot_always::<flatbuffers::WIPOffset<DType>>(Scalar::VT_DTYPE, dtype);
}
#[inline]
pub fn add_value(&mut self, value: flatbuffers::WIPOffset<ScalarValue<'b >>) {
self.fbb_.push_slot_always::<flatbuffers::WIPOffset<ScalarValue>>(Scalar::VT_VALUE, value);
}
#[inline]
pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> ScalarBuilder<'a, 'b, A> {
let start = _fbb.start_table();
ScalarBuilder {
fbb_: _fbb,
start_: start,
}
}
#[inline]
pub fn finish(self) -> flatbuffers::WIPOffset<Scalar<'a>> {
let o = self.fbb_.end_table(self.start_);
self.fbb_.required(o, Scalar::VT_DTYPE,"dtype");
self.fbb_.required(o, Scalar::VT_VALUE,"value");
flatbuffers::WIPOffset::new(o.value())
}
}
impl core::fmt::Debug for Scalar<'_> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("Scalar");
ds.field("dtype", &self.dtype());
ds.field("value", &self.value());
ds.finish()
}
}
pub enum ScalarValueOffset {}
#[derive(Copy, Clone, PartialEq)]
pub struct ScalarValue<'a> {
pub _tab: flatbuffers::Table<'a>,
}
impl<'a> flatbuffers::Follow<'a> for ScalarValue<'a> {
type Inner = ScalarValue<'a>;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: flatbuffers::Table::new(buf, loc) }
}
}
impl<'a> ScalarValue<'a> {
pub const VT_FLEX: flatbuffers::VOffsetT = 4;
#[inline]
pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
ScalarValue { _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 ScalarValueArgs<'args>
) -> flatbuffers::WIPOffset<ScalarValue<'bldr>> {
let mut builder = ScalarValueBuilder::new(_fbb);
if let Some(x) = args.flex { builder.add_flex(x); }
builder.finish()
}
#[inline]
pub fn flex(&self) -> flatbuffers::Vector<'a, u8> {
unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, u8>>>(ScalarValue::VT_FLEX, None).unwrap()}
}
}
impl flatbuffers::Verifiable for ScalarValue<'_> {
#[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<'_, u8>>>("flex", Self::VT_FLEX, true)?
.finish();
Ok(())
}
}
pub struct ScalarValueArgs<'a> {
pub flex: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, u8>>>,
}
impl<'a> Default for ScalarValueArgs<'a> {
#[inline]
fn default() -> Self {
ScalarValueArgs {
flex: None, }
}
}
pub struct ScalarValueBuilder<'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> ScalarValueBuilder<'a, 'b, A> {
#[inline]
pub fn add_flex(&mut self, flex: flatbuffers::WIPOffset<flatbuffers::Vector<'b , u8>>) {
self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(ScalarValue::VT_FLEX, flex);
}
#[inline]
pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> ScalarValueBuilder<'a, 'b, A> {
let start = _fbb.start_table();
ScalarValueBuilder {
fbb_: _fbb,
start_: start,
}
}
#[inline]
pub fn finish(self) -> flatbuffers::WIPOffset<ScalarValue<'a>> {
let o = self.fbb_.end_table(self.start_);
self.fbb_.required(o, ScalarValue::VT_FLEX,"flex");
flatbuffers::WIPOffset::new(o.value())
}
}
impl core::fmt::Debug for ScalarValue<'_> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("ScalarValue");
ds.field("flex", &self.flex());
ds.finish()
}
}
#[inline]
pub fn root_as_scalar(buf: &[u8]) -> Result<Scalar, flatbuffers::InvalidFlatbuffer> {
flatbuffers::root::<Scalar>(buf)
}
#[inline]
pub fn size_prefixed_root_as_scalar(buf: &[u8]) -> Result<Scalar, flatbuffers::InvalidFlatbuffer> {
flatbuffers::size_prefixed_root::<Scalar>(buf)
}
#[inline]
pub fn root_as_scalar_with_opts<'b, 'o>(
opts: &'o flatbuffers::VerifierOptions,
buf: &'b [u8],
) -> Result<Scalar<'b>, flatbuffers::InvalidFlatbuffer> {
flatbuffers::root_with_opts::<Scalar<'b>>(opts, buf)
}
#[inline]
pub fn size_prefixed_root_as_scalar_with_opts<'b, 'o>(
opts: &'o flatbuffers::VerifierOptions,
buf: &'b [u8],
) -> Result<Scalar<'b>, flatbuffers::InvalidFlatbuffer> {
flatbuffers::size_prefixed_root_with_opts::<Scalar<'b>>(opts, buf)
}
#[inline]
pub unsafe fn root_as_scalar_unchecked(buf: &[u8]) -> Scalar {
flatbuffers::root_unchecked::<Scalar>(buf)
}
#[inline]
pub unsafe fn size_prefixed_root_as_scalar_unchecked(buf: &[u8]) -> Scalar {
flatbuffers::size_prefixed_root_unchecked::<Scalar>(buf)
}
#[inline]
pub fn finish_scalar_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(
fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
root: flatbuffers::WIPOffset<Scalar<'a>>) {
fbb.finish(root, None);
}
#[inline]
pub fn finish_size_prefixed_scalar_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, root: flatbuffers::WIPOffset<Scalar<'a>>) {
fbb.finish_size_prefixed(root, None);
}