mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-20 23:17:31 +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,15 +1,8 @@
|
||||
// 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;
|
||||
extern crate serde;
|
||||
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
|
||||
use self::flatbuffers::{EndianScalar, Follow};
|
||||
use super::*;
|
||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||
pub const ENUM_MIN_ANY: u8 = 0;
|
||||
@@ -53,8 +46,8 @@ impl Any {
|
||||
}
|
||||
}
|
||||
}
|
||||
impl core::fmt::Debug for Any {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
||||
impl ::core::fmt::Debug for Any {
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||
if let Some(name) = self.variant_name() {
|
||||
f.write_str(name)
|
||||
} else {
|
||||
@@ -90,24 +83,24 @@ impl<'de> serde::Deserialize<'de> for Any {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Follow<'a> for Any {
|
||||
impl<'a> ::flatbuffers::Follow<'a> for Any {
|
||||
type Inner = Self;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
let b = unsafe { flatbuffers::read_scalar_at::<u8>(buf, loc) };
|
||||
let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
|
||||
Self(b)
|
||||
}
|
||||
}
|
||||
|
||||
impl flatbuffers::Push for Any {
|
||||
impl ::flatbuffers::Push for Any {
|
||||
type Output = Any;
|
||||
#[inline]
|
||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||
unsafe { flatbuffers::emplace_scalar::<u8>(dst, self.0); }
|
||||
unsafe { ::flatbuffers::emplace_scalar::<u8>(dst, self.0) };
|
||||
}
|
||||
}
|
||||
|
||||
impl flatbuffers::EndianScalar for Any {
|
||||
impl ::flatbuffers::EndianScalar for Any {
|
||||
type Scalar = u8;
|
||||
#[inline]
|
||||
fn to_little_endian(self) -> u8 {
|
||||
@@ -121,17 +114,16 @@ impl flatbuffers::EndianScalar for Any {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Verifiable for Any {
|
||||
impl<'a> ::flatbuffers::Verifiable for Any {
|
||||
#[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> {
|
||||
u8::run_verifier(v, pos)
|
||||
}
|
||||
}
|
||||
|
||||
impl flatbuffers::SimpleToVerifyInSlice for Any {}
|
||||
impl ::flatbuffers::SimpleToVerifyInSlice for Any {}
|
||||
pub struct AnyUnionTableOffset {}
|
||||
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
@@ -139,9 +131,9 @@ pub struct AnyUnionTableOffset {}
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum AnyT {
|
||||
NONE,
|
||||
Monster(Box<MonsterT>),
|
||||
TestSimpleTableWithEnum(Box<TestSimpleTableWithEnumT>),
|
||||
MyGameExample2Monster(Box<super::example_2::MonsterT>),
|
||||
Monster(alloc::boxed::Box<MonsterT>),
|
||||
TestSimpleTableWithEnum(alloc::boxed::Box<TestSimpleTableWithEnumT>),
|
||||
MyGameExample2Monster(alloc::boxed::Box<super::example_2::MonsterT>),
|
||||
}
|
||||
impl Default for AnyT {
|
||||
fn default() -> Self {
|
||||
@@ -157,7 +149,7 @@ impl AnyT {
|
||||
Self::MyGameExample2Monster(_) => Any::MyGame_Example2_Monster,
|
||||
}
|
||||
}
|
||||
pub fn pack<'b, A: flatbuffers::Allocator + 'b>(&self, fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>) -> Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>> {
|
||||
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(&self, fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>) -> Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>> {
|
||||
match self {
|
||||
Self::NONE => None,
|
||||
Self::Monster(v) => Some(v.pack(fbb).as_union_value()),
|
||||
@@ -166,9 +158,9 @@ impl AnyT {
|
||||
}
|
||||
}
|
||||
/// If the union variant matches, return the owned MonsterT, setting the union to NONE.
|
||||
pub fn take_monster(&mut self) -> Option<Box<MonsterT>> {
|
||||
pub fn take_monster(&mut self) -> Option<alloc::boxed::Box<MonsterT>> {
|
||||
if let Self::Monster(_) = self {
|
||||
let v = core::mem::replace(self, Self::NONE);
|
||||
let v = ::core::mem::replace(self, Self::NONE);
|
||||
if let Self::Monster(w) = v {
|
||||
Some(w)
|
||||
} else {
|
||||
@@ -187,9 +179,9 @@ impl AnyT {
|
||||
if let Self::Monster(v) = self { Some(v.as_mut()) } else { None }
|
||||
}
|
||||
/// If the union variant matches, return the owned TestSimpleTableWithEnumT, setting the union to NONE.
|
||||
pub fn take_test_simple_table_with_enum(&mut self) -> Option<Box<TestSimpleTableWithEnumT>> {
|
||||
pub fn take_test_simple_table_with_enum(&mut self) -> Option<alloc::boxed::Box<TestSimpleTableWithEnumT>> {
|
||||
if let Self::TestSimpleTableWithEnum(_) = self {
|
||||
let v = core::mem::replace(self, Self::NONE);
|
||||
let v = ::core::mem::replace(self, Self::NONE);
|
||||
if let Self::TestSimpleTableWithEnum(w) = v {
|
||||
Some(w)
|
||||
} else {
|
||||
@@ -208,9 +200,9 @@ impl AnyT {
|
||||
if let Self::TestSimpleTableWithEnum(v) = self { Some(v.as_mut()) } else { None }
|
||||
}
|
||||
/// If the union variant matches, return the owned super::example_2::MonsterT, setting the union to NONE.
|
||||
pub fn take_my_game_example_2_monster(&mut self) -> Option<Box<super::example_2::MonsterT>> {
|
||||
pub fn take_my_game_example_2_monster(&mut self) -> Option<alloc::boxed::Box<super::example_2::MonsterT>> {
|
||||
if let Self::MyGameExample2Monster(_) = self {
|
||||
let v = core::mem::replace(self, Self::NONE);
|
||||
let v = ::core::mem::replace(self, Self::NONE);
|
||||
if let Self::MyGameExample2Monster(w) = v {
|
||||
Some(w)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user