Generate better formatted Rust code (#8919)

* Cleans up Rust formatting

* Regenerates generated schemas
This commit is contained in:
Cameron Mulhern
2026-03-04 21:49:46 -05:00
committed by GitHub
parent 9c383559e0
commit 08b6372a36
95 changed files with 2783 additions and 1062 deletions

View File

@@ -2,10 +2,13 @@
// @generated
extern crate alloc;
use super::*;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_FROM_INCLUDE: i64 = 0;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MAX_FROM_INCLUDE: i64 = 0;
#[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_FROM_INCLUDE: [FromInclude; 1] = [
@@ -15,6 +18,7 @@ pub const ENUM_VALUES_FROM_INCLUDE: [FromInclude; 1] = [
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct FromInclude(pub i64);
#[allow(non_upper_case_globals)]
impl FromInclude {
pub const IncludeVal: Self = Self(0);
@@ -24,6 +28,7 @@ impl FromInclude {
pub const ENUM_VALUES: &'static [Self] = &[
Self::IncludeVal,
];
/// Returns the variant's name or "" if unknown.
pub fn variant_name(self) -> Option<&'static str> {
match self {
@@ -32,6 +37,7 @@ impl FromInclude {
}
}
}
impl ::core::fmt::Debug for FromInclude {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
@@ -41,8 +47,10 @@ impl ::core::fmt::Debug for FromInclude {
}
}
}
impl<'a> ::flatbuffers::Follow<'a> for FromInclude {
type Inner = Self;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { ::flatbuffers::read_scalar_at::<i64>(buf, loc) };
@@ -52,6 +60,7 @@ impl<'a> ::flatbuffers::Follow<'a> for FromInclude {
impl ::flatbuffers::Push for FromInclude {
type Output = FromInclude;
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { ::flatbuffers::emplace_scalar::<i64>(dst, self.0) };
@@ -60,10 +69,12 @@ impl ::flatbuffers::Push for FromInclude {
impl ::flatbuffers::EndianScalar for FromInclude {
type Scalar = i64;
#[inline]
fn to_little_endian(self) -> i64 {
self.0.to_le()
}
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: i64) -> Self {

View File

@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
pub enum TableBOffset {}
#[derive(Copy, Clone, PartialEq)]
pub enum TableBOffset {}
#[derive(Copy, Clone, PartialEq)]
pub struct TableB<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for TableB<'a> {
type Inner = TableB<'a>;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -28,6 +30,7 @@ impl<'a> TableB<'a> {
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
TableB { _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>,
@@ -67,9 +70,11 @@ impl ::flatbuffers::Verifiable for TableB<'_> {
Ok(())
}
}
pub struct TableBArgs<'a> {
pub a: Option<::flatbuffers::WIPOffset<super::super::TableA<'a>>>,
}
impl<'a> Default for TableBArgs<'a> {
#[inline]
fn default() -> Self {
@@ -83,11 +88,13 @@ pub struct TableBBuilder<'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> TableBBuilder<'a, 'b, A> {
#[inline]
pub fn add_a(&mut self, a: ::flatbuffers::WIPOffset<super::super::TableA<'b >>) {
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::super::TableA>>(TableB::VT_A, a);
}
#[inline]
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> {
let start = _fbb.start_table();
@@ -96,6 +103,7 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> {
start_: start,
}
}
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableB<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -110,11 +118,13 @@ impl ::core::fmt::Debug for TableB<'_> {
ds.finish()
}
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TableBT {
pub a: Option<alloc::boxed::Box<super::super::TableAT>>,
}
impl Default for TableBT {
fn default() -> Self {
Self {
@@ -122,6 +132,7 @@ impl Default for TableBT {
}
}
}
impl TableBT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,

View File

@@ -2,15 +2,18 @@
// @generated
extern crate alloc;
use super::*;
// struct Unused, aligned to 4
#[repr(transparent)]
#[derive(Clone, Copy, PartialEq)]
pub struct Unused(pub [u8; 4]);
impl Default for Unused {
fn default() -> Self {
Self([0; 4])
}
}
impl ::core::fmt::Debug for Unused {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
f.debug_struct("Unused")
@@ -20,27 +23,34 @@ impl ::core::fmt::Debug for Unused {
}
impl ::flatbuffers::SimpleToVerifyInSlice for Unused {}
impl<'a> ::flatbuffers::Follow<'a> for Unused {
type Inner = &'a Unused;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
unsafe { <&'a Unused>::follow(buf, loc) }
}
}
impl<'a> ::flatbuffers::Follow<'a> for &'a Unused {
type Inner = &'a Unused;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
unsafe { ::flatbuffers::follow_cast_ref::<Unused>(buf, loc) }
}
}
impl<'b> ::flatbuffers::Push for Unused {
type Output = Unused;
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
let src = unsafe { ::core::slice::from_raw_parts(self as *const Unused as *const u8, <Self as ::flatbuffers::Push>::size()) };
dst.copy_from_slice(src);
}
#[inline]
fn alignment() -> ::flatbuffers::PushAlignment {
::flatbuffers::PushAlignment::new(4)
@@ -110,6 +120,7 @@ impl<'a> Unused {
pub struct UnusedT {
pub a: i32,
}
impl UnusedT {
pub fn pack(&self) -> Unused {
Unused::new(
@@ -117,4 +128,3 @@ impl UnusedT {
)
}
}

View File

@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
pub enum TableAOffset {}
#[derive(Copy, Clone, PartialEq)]
pub enum TableAOffset {}
#[derive(Copy, Clone, PartialEq)]
pub struct TableA<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for TableA<'a> {
type Inner = TableA<'a>;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -28,6 +30,7 @@ impl<'a> TableA<'a> {
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
TableA { _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>,
@@ -67,9 +70,11 @@ impl ::flatbuffers::Verifiable for TableA<'_> {
Ok(())
}
}
pub struct TableAArgs<'a> {
pub b: Option<::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'a>>>,
}
impl<'a> Default for TableAArgs<'a> {
#[inline]
fn default() -> Self {
@@ -83,11 +88,13 @@ pub struct TableABuilder<'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> TableABuilder<'a, 'b, A> {
#[inline]
pub fn add_b(&mut self, b: ::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'b >>) {
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<my_game::other_name_space::TableB>>(TableA::VT_B, b);
}
#[inline]
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> {
let start = _fbb.start_table();
@@ -96,6 +103,7 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> {
start_: start,
}
}
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -110,11 +118,13 @@ impl ::core::fmt::Debug for TableA<'_> {
ds.finish()
}
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TableAT {
pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
}
impl Default for TableAT {
fn default() -> Self {
Self {
@@ -122,6 +132,7 @@ impl Default for TableAT {
}
}
}
impl TableAT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,