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_ABC: i32 = 0;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MAX_ABC: i32 = 2;
#[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_ABC: [ABC; 3] = [
@@ -17,6 +20,7 @@ pub const ENUM_VALUES_ABC: [ABC; 3] = [
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct ABC(pub i32);
#[allow(non_upper_case_globals)]
impl ABC {
pub const void: Self = Self(0);
@@ -30,6 +34,7 @@ impl ABC {
Self::where_,
Self::stackalloc,
];
/// Returns the variant's name or "" if unknown.
pub fn variant_name(self) -> Option<&'static str> {
match self {
@@ -40,6 +45,7 @@ impl ABC {
}
}
}
impl ::core::fmt::Debug for ABC {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
@@ -49,8 +55,10 @@ impl ::core::fmt::Debug for ABC {
}
}
}
impl<'a> ::flatbuffers::Follow<'a> for ABC {
type Inner = Self;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { ::flatbuffers::read_scalar_at::<i32>(buf, loc) };
@@ -60,6 +68,7 @@ impl<'a> ::flatbuffers::Follow<'a> for ABC {
impl ::flatbuffers::Push for ABC {
type Output = ABC;
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { ::flatbuffers::emplace_scalar::<i32>(dst, self.0) };
@@ -68,10 +77,12 @@ impl ::flatbuffers::Push for ABC {
impl ::flatbuffers::EndianScalar for ABC {
type Scalar = i32;
#[inline]
fn to_little_endian(self) -> i32 {
self.0.to_le()
}
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: i32) -> Self {

View File

@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
pub enum KeywordsInTableOffset {}
#[derive(Copy, Clone, PartialEq)]
pub enum KeywordsInTableOffset {}
#[derive(Copy, Clone, PartialEq)]
pub struct KeywordsInTable<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for KeywordsInTable<'a> {
type Inner = KeywordsInTable<'a>;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -31,6 +33,7 @@ impl<'a> KeywordsInTable<'a> {
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
KeywordsInTable { _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>,
@@ -64,6 +67,7 @@ impl<'a> KeywordsInTable<'a> {
// which contains a valid value in this slot
unsafe { self._tab.get::<ABC>(KeywordsInTable::VT_IS, Some(ABC::void)).unwrap()}
}
#[inline]
pub fn private(&self) -> public {
// Safety:
@@ -71,6 +75,7 @@ impl<'a> KeywordsInTable<'a> {
// which contains a valid value in this slot
unsafe { self._tab.get::<public>(KeywordsInTable::VT_PRIVATE, Some(public::NONE)).unwrap()}
}
#[inline]
pub fn type_(&self) -> i32 {
// Safety:
@@ -78,6 +83,7 @@ impl<'a> KeywordsInTable<'a> {
// which contains a valid value in this slot
unsafe { self._tab.get::<i32>(KeywordsInTable::VT_TYPE_, Some(0)).unwrap()}
}
#[inline]
pub fn default(&self) -> bool {
// Safety:
@@ -101,12 +107,14 @@ impl ::flatbuffers::Verifiable for KeywordsInTable<'_> {
Ok(())
}
}
pub struct KeywordsInTableArgs {
pub is: ABC,
pub private: public,
pub type_: i32,
pub default: bool,
}
impl<'a> Default for KeywordsInTableArgs {
#[inline]
fn default() -> Self {
@@ -123,23 +131,28 @@ pub struct KeywordsInTableBuilder<'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> KeywordsInTableBuilder<'a, 'b, A> {
#[inline]
pub fn add_is(&mut self, is: ABC) {
self.fbb_.push_slot::<ABC>(KeywordsInTable::VT_IS, is, ABC::void);
}
#[inline]
pub fn add_private(&mut self, private: public) {
self.fbb_.push_slot::<public>(KeywordsInTable::VT_PRIVATE, private, public::NONE);
}
#[inline]
pub fn add_type_(&mut self, type_: i32) {
self.fbb_.push_slot::<i32>(KeywordsInTable::VT_TYPE_, type_, 0);
}
#[inline]
pub fn add_default(&mut self, default: bool) {
self.fbb_.push_slot::<bool>(KeywordsInTable::VT_DEFAULT, default, false);
}
#[inline]
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> KeywordsInTableBuilder<'a, 'b, A> {
let start = _fbb.start_table();
@@ -148,6 +161,7 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> KeywordsInTableBuilder<'a, 'b
start_: start,
}
}
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<KeywordsInTable<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -165,6 +179,7 @@ impl ::core::fmt::Debug for KeywordsInTable<'_> {
ds.finish()
}
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct KeywordsInTableT {
@@ -173,6 +188,7 @@ pub struct KeywordsInTableT {
pub type_: i32,
pub default: bool,
}
impl Default for KeywordsInTableT {
fn default() -> Self {
Self {
@@ -183,6 +199,7 @@ impl Default for KeywordsInTableT {
}
}
}
impl KeywordsInTableT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,

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_KEYWORDS_IN_UNION: u8 = 0;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MAX_KEYWORDS_IN_UNION: u8 = 2;
#[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_KEYWORDS_IN_UNION: [KeywordsInUnion; 3] = [
@@ -17,6 +20,7 @@ pub const ENUM_VALUES_KEYWORDS_IN_UNION: [KeywordsInUnion; 3] = [
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct KeywordsInUnion(pub u8);
#[allow(non_upper_case_globals)]
impl KeywordsInUnion {
pub const NONE: Self = Self(0);
@@ -30,6 +34,7 @@ impl KeywordsInUnion {
Self::static_,
Self::internal,
];
/// Returns the variant's name or "" if unknown.
pub fn variant_name(self) -> Option<&'static str> {
match self {
@@ -40,6 +45,7 @@ impl KeywordsInUnion {
}
}
}
impl ::core::fmt::Debug for KeywordsInUnion {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
@@ -49,8 +55,10 @@ impl ::core::fmt::Debug for KeywordsInUnion {
}
}
}
impl<'a> ::flatbuffers::Follow<'a> for KeywordsInUnion {
type Inner = Self;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
@@ -60,6 +68,7 @@ impl<'a> ::flatbuffers::Follow<'a> for KeywordsInUnion {
impl ::flatbuffers::Push for KeywordsInUnion {
type Output = KeywordsInUnion;
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { ::flatbuffers::emplace_scalar::<u8>(dst, self.0) };
@@ -68,10 +77,12 @@ impl ::flatbuffers::Push for KeywordsInUnion {
impl ::flatbuffers::EndianScalar for KeywordsInUnion {
type Scalar = u8;
#[inline]
fn to_little_endian(self) -> u8 {
self.0.to_le()
}
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: u8) -> Self {
@@ -90,6 +101,7 @@ impl<'a> ::flatbuffers::Verifiable for KeywordsInUnion {
}
impl ::flatbuffers::SimpleToVerifyInSlice for KeywordsInUnion {}
pub struct KeywordsInUnionUnionTableOffset {}
#[allow(clippy::upper_case_acronyms)]
@@ -100,11 +112,13 @@ pub enum KeywordsInUnionT {
Static_(alloc::boxed::Box<KeywordsInTableT>),
Internal(alloc::boxed::Box<KeywordsInTableT>),
}
impl Default for KeywordsInUnionT {
fn default() -> Self {
Self::NONE
}
}
impl KeywordsInUnionT {
pub fn keywords_in_union_type(&self) -> KeywordsInUnion {
match self {
@@ -113,6 +127,7 @@ impl KeywordsInUnionT {
Self::Internal(_) => KeywordsInUnion::internal,
}
}
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,
@@ -120,6 +135,7 @@ impl KeywordsInUnionT {
Self::Internal(v) => Some(v.pack(fbb).as_union_value()),
}
}
/// If the union variant matches, return the owned KeywordsInTableT, setting the union to NONE.
pub fn take_static_(&mut self) -> Option<alloc::boxed::Box<KeywordsInTableT>> {
if let Self::Static_(_) = self {
@@ -133,14 +149,17 @@ impl KeywordsInUnionT {
None
}
}
/// If the union variant matches, return a reference to the KeywordsInTableT.
pub fn as_static_(&self) -> Option<&KeywordsInTableT> {
if let Self::Static_(v) = self { Some(v.as_ref()) } else { None }
}
/// If the union variant matches, return a mutable reference to the KeywordsInTableT.
pub fn as_static__mut(&mut self) -> Option<&mut KeywordsInTableT> {
if let Self::Static_(v) = self { Some(v.as_mut()) } else { None }
}
/// If the union variant matches, return the owned KeywordsInTableT, setting the union to NONE.
pub fn take_internal(&mut self) -> Option<alloc::boxed::Box<KeywordsInTableT>> {
if let Self::Internal(_) = self {
@@ -154,12 +173,15 @@ impl KeywordsInUnionT {
None
}
}
/// If the union variant matches, return a reference to the KeywordsInTableT.
pub fn as_internal(&self) -> Option<&KeywordsInTableT> {
if let Self::Internal(v) = self { Some(v.as_ref()) } else { None }
}
/// If the union variant matches, return a mutable reference to the KeywordsInTableT.
pub fn as_internal_mut(&mut self) -> Option<&mut KeywordsInTableT> {
if let Self::Internal(v) = self { Some(v.as_mut()) } else { None }
}
}

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

View File

@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
pub enum Table2Offset {}
#[derive(Copy, Clone, PartialEq)]
pub enum Table2Offset {}
#[derive(Copy, Clone, PartialEq)]
pub struct Table2<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for Table2<'a> {
type Inner = Table2<'a>;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -29,6 +31,7 @@ impl<'a> Table2<'a> {
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
Table2 { _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,6 +70,7 @@ impl<'a> Table2<'a> {
// which contains a valid value in this slot
unsafe { self._tab.get::<KeywordsInUnion>(Table2::VT_TYPE_TYPE, Some(KeywordsInUnion::NONE)).unwrap()}
}
#[inline]
pub fn type_(&self) -> Option<::flatbuffers::Table<'a>> {
// Safety:
@@ -74,6 +78,7 @@ impl<'a> Table2<'a> {
// which contains a valid value in this slot
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Table2::VT_TYPE_, None)}
}
#[inline]
#[allow(non_snake_case)]
pub fn type__as_static_(&self) -> Option<KeywordsInTable<'a>> {
@@ -103,7 +108,6 @@ impl<'a> Table2<'a> {
None
}
}
}
impl ::flatbuffers::Verifiable for Table2<'_> {
@@ -123,10 +127,12 @@ impl ::flatbuffers::Verifiable for Table2<'_> {
Ok(())
}
}
pub struct Table2Args {
pub type_type: KeywordsInUnion,
pub type_: Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>,
}
impl<'a> Default for Table2Args {
#[inline]
fn default() -> Self {
@@ -141,15 +147,18 @@ pub struct Table2Builder<'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> Table2Builder<'a, 'b, A> {
#[inline]
pub fn add_type_type(&mut self, type_type: KeywordsInUnion) {
self.fbb_.push_slot::<KeywordsInUnion>(Table2::VT_TYPE_TYPE, type_type, KeywordsInUnion::NONE);
}
#[inline]
pub fn add_type_(&mut self, type_: ::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>) {
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Table2::VT_TYPE_, type_);
}
#[inline]
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> Table2Builder<'a, 'b, A> {
let start = _fbb.start_table();
@@ -158,6 +167,7 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> Table2Builder<'a, 'b, A> {
start_: start,
}
}
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<Table2<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -192,11 +202,13 @@ impl ::core::fmt::Debug for Table2<'_> {
ds.finish()
}
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct Table2T {
pub type_: KeywordsInUnionT,
}
impl Default for Table2T {
fn default() -> Self {
Self {
@@ -204,6 +216,7 @@ impl Default for Table2T {
}
}
}
impl Table2T {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,