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_ANY: u8 = 0;
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MAX_ANY: 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_ANY: [Any; 3] = [
@@ -17,6 +20,7 @@ pub const ENUM_VALUES_ANY: [Any; 3] = [
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub(crate) struct Any(pub u8);
#[allow(non_upper_case_globals)]
impl Any {
pub const NONE: Self = Self(0);
@@ -30,6 +34,7 @@ impl Any {
Self::Game,
Self::Annotations,
];
/// Returns the variant's name or "" if unknown.
pub fn variant_name(self) -> Option<&'static str> {
match self {
@@ -40,6 +45,7 @@ impl Any {
}
}
}
impl ::core::fmt::Debug for Any {
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 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) };
@@ -60,6 +68,7 @@ impl<'a> ::flatbuffers::Follow<'a> 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) };
@@ -68,10 +77,12 @@ impl ::flatbuffers::Push for Any {
impl ::flatbuffers::EndianScalar for Any {
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 Any {
}
impl ::flatbuffers::SimpleToVerifyInSlice for Any {}
pub(crate) struct AnyUnionTableOffset {}
#[allow(clippy::upper_case_acronyms)]
@@ -100,11 +112,13 @@ pub(crate) enum AnyT {
Game(alloc::boxed::Box<GameT>),
Annotations(alloc::boxed::Box<AnnotationsT>),
}
impl Default for AnyT {
fn default() -> Self {
Self::NONE
}
}
impl AnyT {
pub fn any_type(&self) -> Any {
match self {
@@ -113,6 +127,7 @@ impl AnyT {
Self::Annotations(_) => Any::Annotations,
}
}
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 AnyT {
Self::Annotations(v) => Some(v.pack(fbb).as_union_value()),
}
}
/// If the union variant matches, return the owned GameT, setting the union to NONE.
pub fn take_game(&mut self) -> Option<alloc::boxed::Box<GameT>> {
if let Self::Game(_) = self {
@@ -133,14 +149,17 @@ impl AnyT {
None
}
}
/// If the union variant matches, return a reference to the GameT.
pub fn as_game(&self) -> Option<&GameT> {
if let Self::Game(v) = self { Some(v.as_ref()) } else { None }
}
/// If the union variant matches, return a mutable reference to the GameT.
pub fn as_game_mut(&mut self) -> Option<&mut GameT> {
if let Self::Game(v) = self { Some(v.as_mut()) } else { None }
}
/// If the union variant matches, return the owned AnnotationsT, setting the union to NONE.
pub fn take_annotations(&mut self) -> Option<alloc::boxed::Box<AnnotationsT>> {
if let Self::Annotations(_) = self {
@@ -154,12 +173,15 @@ impl AnyT {
None
}
}
/// If the union variant matches, return a reference to the AnnotationsT.
pub fn as_annotations(&self) -> Option<&AnnotationsT> {
if let Self::Annotations(v) = self { Some(v.as_ref()) } else { None }
}
/// If the union variant matches, return a mutable reference to the AnnotationsT.
pub fn as_annotations_mut(&mut self) -> Option<&mut AnnotationsT> {
if let Self::Annotations(v) = self { Some(v.as_mut()) } else { None }
}
}