-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a88d83b
commit 2e17e21
Showing
7 changed files
with
243 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Metadata; | ||
|
||
table Metadata { | ||
send_errors: ulong; | ||
} | ||
|
||
root_type Metadata; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
// automatically generated by the FlatBuffers compiler, do not modify | ||
|
||
// @generated | ||
|
||
extern crate flatbuffers; | ||
|
||
#[allow(unused_imports, dead_code)] | ||
pub mod metadata { | ||
|
||
use core::cmp::Ordering; | ||
use core::mem; | ||
|
||
extern crate flatbuffers; | ||
use self::flatbuffers::{EndianScalar, Follow}; | ||
|
||
pub enum MetadataOffset {} | ||
#[derive(Copy, Clone, PartialEq)] | ||
|
||
pub struct Metadata<'a> { | ||
pub _tab: flatbuffers::Table<'a>, | ||
} | ||
|
||
impl<'a> flatbuffers::Follow<'a> for Metadata<'a> { | ||
type Inner = Metadata<'a>; | ||
#[inline] | ||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { | ||
Self { | ||
_tab: flatbuffers::Table::new(buf, loc), | ||
} | ||
} | ||
} | ||
|
||
impl<'a> Metadata<'a> { | ||
pub const VT_SEND_ERRORS: flatbuffers::VOffsetT = 4; | ||
|
||
#[inline] | ||
pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { | ||
Metadata { _tab: table } | ||
} | ||
#[allow(unused_mut)] | ||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( | ||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, | ||
args: &'args MetadataArgs, | ||
) -> flatbuffers::WIPOffset<Metadata<'bldr>> { | ||
let mut builder = MetadataBuilder::new(_fbb); | ||
builder.add_send_errors(args.send_errors); | ||
builder.finish() | ||
} | ||
|
||
#[inline] | ||
pub fn send_errors(&self) -> u64 { | ||
// Safety: | ||
// Created from valid Table for this object | ||
// which contains a valid value in this slot | ||
unsafe { | ||
self._tab | ||
.get::<u64>(Metadata::VT_SEND_ERRORS, Some(0)) | ||
.unwrap() | ||
} | ||
} | ||
} | ||
|
||
impl flatbuffers::Verifiable for Metadata<'_> { | ||
#[inline] | ||
fn run_verifier( | ||
v: &mut flatbuffers::Verifier, | ||
pos: usize, | ||
) -> Result<(), flatbuffers::InvalidFlatbuffer> { | ||
use self::flatbuffers::Verifiable; | ||
v.visit_table(pos)? | ||
.visit_field::<u64>("send_errors", Self::VT_SEND_ERRORS, false)? | ||
.finish(); | ||
Ok(()) | ||
} | ||
} | ||
pub struct MetadataArgs { | ||
pub send_errors: u64, | ||
} | ||
impl<'a> Default for MetadataArgs { | ||
#[inline] | ||
fn default() -> Self { | ||
MetadataArgs { send_errors: 0 } | ||
} | ||
} | ||
|
||
pub struct MetadataBuilder<'a: 'b, 'b> { | ||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, | ||
start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>, | ||
} | ||
impl<'a: 'b, 'b> MetadataBuilder<'a, 'b> { | ||
#[inline] | ||
pub fn add_send_errors(&mut self, send_errors: u64) { | ||
self.fbb_ | ||
.push_slot::<u64>(Metadata::VT_SEND_ERRORS, send_errors, 0); | ||
} | ||
#[inline] | ||
pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> MetadataBuilder<'a, 'b> { | ||
let start = _fbb.start_table(); | ||
MetadataBuilder { | ||
fbb_: _fbb, | ||
start_: start, | ||
} | ||
} | ||
#[inline] | ||
pub fn finish(self) -> flatbuffers::WIPOffset<Metadata<'a>> { | ||
let o = self.fbb_.end_table(self.start_); | ||
flatbuffers::WIPOffset::new(o.value()) | ||
} | ||
} | ||
|
||
impl core::fmt::Debug for Metadata<'_> { | ||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
let mut ds = f.debug_struct("Metadata"); | ||
ds.field("send_errors", &self.send_errors()); | ||
ds.finish() | ||
} | ||
} | ||
#[inline] | ||
/// Verifies that a buffer of bytes contains a `Metadata` | ||
/// 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_metadata_unchecked`. | ||
pub fn root_as_metadata(buf: &[u8]) -> Result<Metadata, flatbuffers::InvalidFlatbuffer> { | ||
flatbuffers::root::<Metadata>(buf) | ||
} | ||
#[inline] | ||
/// Verifies that a buffer of bytes contains a size prefixed | ||
/// `Metadata` 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_metadata_unchecked`. | ||
pub fn size_prefixed_root_as_metadata( | ||
buf: &[u8], | ||
) -> Result<Metadata, flatbuffers::InvalidFlatbuffer> { | ||
flatbuffers::size_prefixed_root::<Metadata>(buf) | ||
} | ||
#[inline] | ||
/// Verifies, with the given options, that a buffer of bytes | ||
/// contains a `Metadata` 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_metadata_unchecked`. | ||
pub fn root_as_metadata_with_opts<'b, 'o>( | ||
opts: &'o flatbuffers::VerifierOptions, | ||
buf: &'b [u8], | ||
) -> Result<Metadata<'b>, flatbuffers::InvalidFlatbuffer> { | ||
flatbuffers::root_with_opts::<Metadata<'b>>(opts, buf) | ||
} | ||
#[inline] | ||
/// Verifies, with the given verifier options, that a buffer of | ||
/// bytes contains a size prefixed `Metadata` 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_metadata_unchecked`. | ||
pub fn size_prefixed_root_as_metadata_with_opts<'b, 'o>( | ||
opts: &'o flatbuffers::VerifierOptions, | ||
buf: &'b [u8], | ||
) -> Result<Metadata<'b>, flatbuffers::InvalidFlatbuffer> { | ||
flatbuffers::size_prefixed_root_with_opts::<Metadata<'b>>(opts, buf) | ||
} | ||
#[inline] | ||
/// Assumes, without verification, that a buffer of bytes contains a Metadata and returns it. | ||
/// # Safety | ||
/// Callers must trust the given bytes do indeed contain a valid `Metadata`. | ||
pub unsafe fn root_as_metadata_unchecked(buf: &[u8]) -> Metadata { | ||
flatbuffers::root_unchecked::<Metadata>(buf) | ||
} | ||
#[inline] | ||
/// Assumes, without verification, that a buffer of bytes contains a size prefixed Metadata and returns it. | ||
/// # Safety | ||
/// Callers must trust the given bytes do indeed contain a valid size prefixed `Metadata`. | ||
pub unsafe fn size_prefixed_root_as_metadata_unchecked(buf: &[u8]) -> Metadata { | ||
flatbuffers::size_prefixed_root_unchecked::<Metadata>(buf) | ||
} | ||
#[inline] | ||
pub fn finish_metadata_buffer<'a, 'b>( | ||
fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, | ||
root: flatbuffers::WIPOffset<Metadata<'a>>, | ||
) { | ||
fbb.finish(root, None); | ||
} | ||
|
||
#[inline] | ||
pub fn finish_size_prefixed_metadata_buffer<'a, 'b>( | ||
fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, | ||
root: flatbuffers::WIPOffset<Metadata<'a>>, | ||
) { | ||
fbb.finish_size_prefixed(root, None); | ||
} | ||
} // pub mod Metadata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters