mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-09 06:30:54 +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,13 +1,6 @@
|
||||
// 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::*;
|
||||
// struct NestedStruct, aligned to 8
|
||||
#[repr(transparent)]
|
||||
@@ -18,8 +11,8 @@ impl Default for NestedStruct {
|
||||
Self([0; 32])
|
||||
}
|
||||
}
|
||||
impl core::fmt::Debug for NestedStruct {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
||||
impl ::core::fmt::Debug for NestedStruct {
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||
f.debug_struct("NestedStruct")
|
||||
.field("a", &self.a())
|
||||
.field("b", &self.b())
|
||||
@@ -29,40 +22,39 @@ impl core::fmt::Debug for NestedStruct {
|
||||
}
|
||||
}
|
||||
|
||||
impl flatbuffers::SimpleToVerifyInSlice for NestedStruct {}
|
||||
impl<'a> flatbuffers::Follow<'a> for NestedStruct {
|
||||
impl ::flatbuffers::SimpleToVerifyInSlice for NestedStruct {}
|
||||
impl<'a> ::flatbuffers::Follow<'a> for NestedStruct {
|
||||
type Inner = &'a NestedStruct;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
unsafe { <&'a NestedStruct>::follow(buf, loc) }
|
||||
}
|
||||
}
|
||||
impl<'a> flatbuffers::Follow<'a> for &'a NestedStruct {
|
||||
impl<'a> ::flatbuffers::Follow<'a> for &'a NestedStruct {
|
||||
type Inner = &'a NestedStruct;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
unsafe { flatbuffers::follow_cast_ref::<NestedStruct>(buf, loc) }
|
||||
unsafe { ::flatbuffers::follow_cast_ref::<NestedStruct>(buf, loc) }
|
||||
}
|
||||
}
|
||||
impl<'b> flatbuffers::Push for NestedStruct {
|
||||
impl<'b> ::flatbuffers::Push for NestedStruct {
|
||||
type Output = NestedStruct;
|
||||
#[inline]
|
||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||
let src = unsafe { ::core::slice::from_raw_parts(self as *const NestedStruct as *const u8, <Self as flatbuffers::Push>::size()) };
|
||||
let src = unsafe { ::core::slice::from_raw_parts(self as *const NestedStruct as *const u8, <Self as ::flatbuffers::Push>::size()) };
|
||||
dst.copy_from_slice(src);
|
||||
}
|
||||
#[inline]
|
||||
fn alignment() -> flatbuffers::PushAlignment {
|
||||
flatbuffers::PushAlignment::new(8)
|
||||
fn alignment() -> ::flatbuffers::PushAlignment {
|
||||
::flatbuffers::PushAlignment::new(8)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Verifiable for NestedStruct {
|
||||
impl<'a> ::flatbuffers::Verifiable for NestedStruct {
|
||||
#[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.in_buffer::<Self>(pos)
|
||||
}
|
||||
}
|
||||
@@ -87,54 +79,56 @@ impl<'a> NestedStruct {
|
||||
"MyGame.Example.NestedStruct"
|
||||
}
|
||||
|
||||
pub fn a(&'a self) -> flatbuffers::Array<'a, i32, 2> {
|
||||
pub fn a(&'a self) -> ::flatbuffers::Array<'a, i32, 2> {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
unsafe { flatbuffers::Array::follow(&self.0, 0) }
|
||||
use ::flatbuffers::Follow;
|
||||
unsafe { ::flatbuffers::Array::follow(&self.0, 0) }
|
||||
}
|
||||
|
||||
pub fn set_a(&mut self, items: &[i32; 2]) {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
unsafe { flatbuffers::emplace_scalar_array(&mut self.0, 0, items) };
|
||||
unsafe { ::flatbuffers::emplace_scalar_array(&mut self.0, 0, items) };
|
||||
}
|
||||
|
||||
pub fn b(&self) -> TestEnum {
|
||||
let mut mem = core::mem::MaybeUninit::<<TestEnum as EndianScalar>::Scalar>::uninit();
|
||||
let mut mem = ::core::mem::MaybeUninit::<<TestEnum as ::flatbuffers::EndianScalar>::Scalar>::uninit();
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid value in this slot
|
||||
EndianScalar::from_little_endian(unsafe {
|
||||
core::ptr::copy_nonoverlapping(
|
||||
::flatbuffers::EndianScalar::from_little_endian(unsafe {
|
||||
::core::ptr::copy_nonoverlapping(
|
||||
self.0[8..].as_ptr(),
|
||||
mem.as_mut_ptr() as *mut u8,
|
||||
core::mem::size_of::<<TestEnum as EndianScalar>::Scalar>(),
|
||||
::core::mem::size_of::<<TestEnum as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||
);
|
||||
mem.assume_init()
|
||||
})
|
||||
}
|
||||
|
||||
pub fn set_b(&mut self, x: TestEnum) {
|
||||
let x_le = x.to_little_endian();
|
||||
let x_le = ::flatbuffers::EndianScalar::to_little_endian(x);
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid value in this slot
|
||||
unsafe {
|
||||
core::ptr::copy_nonoverlapping(
|
||||
::core::ptr::copy_nonoverlapping(
|
||||
&x_le as *const _ as *const u8,
|
||||
self.0[8..].as_mut_ptr(),
|
||||
core::mem::size_of::<<TestEnum as EndianScalar>::Scalar>(),
|
||||
::core::mem::size_of::<<TestEnum as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn c(&'a self) -> flatbuffers::Array<'a, TestEnum, 2> {
|
||||
pub fn c(&'a self) -> ::flatbuffers::Array<'a, TestEnum, 2> {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
unsafe { flatbuffers::Array::follow(&self.0, 9) }
|
||||
use ::flatbuffers::Follow;
|
||||
unsafe { ::flatbuffers::Array::follow(&self.0, 9) }
|
||||
}
|
||||
|
||||
pub fn set_c(&mut self, x: &[TestEnum; 2]) {
|
||||
@@ -142,7 +136,7 @@ impl<'a> NestedStruct {
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
unsafe {
|
||||
core::ptr::copy(
|
||||
::core::ptr::copy(
|
||||
x.as_ptr() as *const u8,
|
||||
self.0.as_mut_ptr().add(9),
|
||||
2,
|
||||
@@ -150,18 +144,19 @@ impl<'a> NestedStruct {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn d(&'a self) -> flatbuffers::Array<'a, i64, 2> {
|
||||
pub fn d(&'a self) -> ::flatbuffers::Array<'a, i64, 2> {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
unsafe { flatbuffers::Array::follow(&self.0, 16) }
|
||||
use ::flatbuffers::Follow;
|
||||
unsafe { ::flatbuffers::Array::follow(&self.0, 16) }
|
||||
}
|
||||
|
||||
pub fn set_d(&mut self, items: &[i64; 2]) {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
unsafe { flatbuffers::emplace_scalar_array(&mut self.0, 16, items) };
|
||||
unsafe { ::flatbuffers::emplace_scalar_array(&mut self.0, 16, items) };
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> NestedStructT {
|
||||
|
||||
Reference in New Issue
Block a user