mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-17 23:16:30 +00:00
Fixes unused imports in Rust code generator (#8828)
* Fixes unused imports in Rust code generator * Regenerates generated schemas
This commit is contained in:
@@ -1,47 +1,40 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// @generated
|
||||
extern crate alloc;
|
||||
extern crate flatbuffers;
|
||||
use alloc::boxed::Box;
|
||||
use alloc::string::{String, ToString};
|
||||
use alloc::vec::Vec;
|
||||
use core::mem;
|
||||
use core::cmp::Ordering;
|
||||
use self::flatbuffers::{EndianScalar, Follow};
|
||||
use super::*;
|
||||
pub enum StatOffset {}
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
|
||||
pub struct Stat<'a> {
|
||||
pub _tab: flatbuffers::Table<'a>,
|
||||
pub _tab: ::flatbuffers::Table<'a>,
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Follow<'a> for Stat<'a> {
|
||||
impl<'a> ::flatbuffers::Follow<'a> for Stat<'a> {
|
||||
type Inner = Stat<'a>;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } }
|
||||
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Stat<'a> {
|
||||
pub const VT_ID: flatbuffers::VOffsetT = 4;
|
||||
pub const VT_VAL: flatbuffers::VOffsetT = 6;
|
||||
pub const VT_COUNT: flatbuffers::VOffsetT = 8;
|
||||
pub const VT_ID: ::flatbuffers::VOffsetT = 4;
|
||||
pub const VT_VAL: ::flatbuffers::VOffsetT = 6;
|
||||
pub const VT_COUNT: ::flatbuffers::VOffsetT = 8;
|
||||
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.Stat"
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
||||
Stat { _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>,
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
||||
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||
args: &'args StatArgs<'args>
|
||||
) -> flatbuffers::WIPOffset<Stat<'bldr>> {
|
||||
) -> ::flatbuffers::WIPOffset<Stat<'bldr>> {
|
||||
let mut builder = StatBuilder::new(_fbb);
|
||||
builder.add_val(args.val);
|
||||
if let Some(x) = args.id { builder.add_id(x); }
|
||||
@@ -51,7 +44,7 @@ impl<'a> Stat<'a> {
|
||||
|
||||
pub fn unpack(&self) -> StatT {
|
||||
let id = self.id().map(|x| {
|
||||
x.to_string()
|
||||
alloc::string::ToString::to_string(x)
|
||||
});
|
||||
let val = self.val();
|
||||
let count = self.count();
|
||||
@@ -67,7 +60,7 @@ impl<'a> Stat<'a> {
|
||||
// Safety:
|
||||
// Created from valid Table for this object
|
||||
// which contains a valid value in this slot
|
||||
unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(Stat::VT_ID, None)}
|
||||
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(Stat::VT_ID, None)}
|
||||
}
|
||||
#[inline]
|
||||
pub fn val(&self) -> i64 {
|
||||
@@ -95,14 +88,13 @@ impl<'a> Stat<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl flatbuffers::Verifiable for Stat<'_> {
|
||||
impl ::flatbuffers::Verifiable for Stat<'_> {
|
||||
#[inline]
|
||||
fn run_verifier(
|
||||
v: &mut flatbuffers::Verifier, pos: usize
|
||||
) -> Result<(), flatbuffers::InvalidFlatbuffer> {
|
||||
use self::flatbuffers::Verifiable;
|
||||
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||
v.visit_table(pos)?
|
||||
.visit_field::<flatbuffers::ForwardsUOffset<&str>>("id", Self::VT_ID, false)?
|
||||
.visit_field::<::flatbuffers::ForwardsUOffset<&str>>("id", Self::VT_ID, false)?
|
||||
.visit_field::<i64>("val", Self::VT_VAL, false)?
|
||||
.visit_field::<u16>("count", Self::VT_COUNT, false)?
|
||||
.finish();
|
||||
@@ -110,7 +102,7 @@ impl flatbuffers::Verifiable for Stat<'_> {
|
||||
}
|
||||
}
|
||||
pub struct StatArgs<'a> {
|
||||
pub id: Option<flatbuffers::WIPOffset<&'a str>>,
|
||||
pub id: Option<::flatbuffers::WIPOffset<&'a str>>,
|
||||
pub val: i64,
|
||||
pub count: u16,
|
||||
}
|
||||
@@ -125,14 +117,14 @@ impl<'a> Default for StatArgs<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct StatBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
|
||||
start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
|
||||
pub struct StatBuilder<'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> StatBuilder<'a, 'b, A> {
|
||||
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> StatBuilder<'a, 'b, A> {
|
||||
#[inline]
|
||||
pub fn add_id(&mut self, id: flatbuffers::WIPOffset<&'b str>) {
|
||||
self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Stat::VT_ID, id);
|
||||
pub fn add_id(&mut self, id: ::flatbuffers::WIPOffset<&'b str>) {
|
||||
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Stat::VT_ID, id);
|
||||
}
|
||||
#[inline]
|
||||
pub fn add_val(&mut self, val: i64) {
|
||||
@@ -143,7 +135,7 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> StatBuilder<'a, 'b, A> {
|
||||
self.fbb_.push_slot::<u16>(Stat::VT_COUNT, count, 0);
|
||||
}
|
||||
#[inline]
|
||||
pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> StatBuilder<'a, 'b, A> {
|
||||
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> StatBuilder<'a, 'b, A> {
|
||||
let start = _fbb.start_table();
|
||||
StatBuilder {
|
||||
fbb_: _fbb,
|
||||
@@ -151,14 +143,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> StatBuilder<'a, 'b, A> {
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn finish(self) -> flatbuffers::WIPOffset<Stat<'a>> {
|
||||
pub fn finish(self) -> ::flatbuffers::WIPOffset<Stat<'a>> {
|
||||
let o = self.fbb_.end_table(self.start_);
|
||||
flatbuffers::WIPOffset::new(o.value())
|
||||
::flatbuffers::WIPOffset::new(o.value())
|
||||
}
|
||||
}
|
||||
|
||||
impl core::fmt::Debug for Stat<'_> {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
impl ::core::fmt::Debug for Stat<'_> {
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
|
||||
let mut ds = f.debug_struct("Stat");
|
||||
ds.field("id", &self.id());
|
||||
ds.field("val", &self.val());
|
||||
@@ -169,7 +161,7 @@ impl core::fmt::Debug for Stat<'_> {
|
||||
#[non_exhaustive]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct StatT {
|
||||
pub id: Option<String>,
|
||||
pub id: Option<alloc::string::String>,
|
||||
pub val: i64,
|
||||
pub count: u16,
|
||||
}
|
||||
@@ -183,10 +175,10 @@ impl Default for StatT {
|
||||
}
|
||||
}
|
||||
impl StatT {
|
||||
pub fn pack<'b, A: flatbuffers::Allocator + 'b>(
|
||||
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
||||
&self,
|
||||
_fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>
|
||||
) -> flatbuffers::WIPOffset<Stat<'b>> {
|
||||
_fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
|
||||
) -> ::flatbuffers::WIPOffset<Stat<'b>> {
|
||||
let id = self.id.as_ref().map(|x|{
|
||||
_fbb.create_string(x)
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user