mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-05 13:08:58 +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 ArrayStruct, aligned to 8
|
||||
#[repr(transparent)]
|
||||
@@ -18,8 +11,8 @@ impl Default for ArrayStruct {
|
||||
Self([0; 160])
|
||||
}
|
||||
}
|
||||
impl core::fmt::Debug for ArrayStruct {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
||||
impl ::core::fmt::Debug for ArrayStruct {
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||
f.debug_struct("ArrayStruct")
|
||||
.field("a", &self.a())
|
||||
.field("b", &self.b())
|
||||
@@ -31,40 +24,39 @@ impl core::fmt::Debug for ArrayStruct {
|
||||
}
|
||||
}
|
||||
|
||||
impl flatbuffers::SimpleToVerifyInSlice for ArrayStruct {}
|
||||
impl<'a> flatbuffers::Follow<'a> for ArrayStruct {
|
||||
impl ::flatbuffers::SimpleToVerifyInSlice for ArrayStruct {}
|
||||
impl<'a> ::flatbuffers::Follow<'a> for ArrayStruct {
|
||||
type Inner = &'a ArrayStruct;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
unsafe { <&'a ArrayStruct>::follow(buf, loc) }
|
||||
}
|
||||
}
|
||||
impl<'a> flatbuffers::Follow<'a> for &'a ArrayStruct {
|
||||
impl<'a> ::flatbuffers::Follow<'a> for &'a ArrayStruct {
|
||||
type Inner = &'a ArrayStruct;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
unsafe { flatbuffers::follow_cast_ref::<ArrayStruct>(buf, loc) }
|
||||
unsafe { ::flatbuffers::follow_cast_ref::<ArrayStruct>(buf, loc) }
|
||||
}
|
||||
}
|
||||
impl<'b> flatbuffers::Push for ArrayStruct {
|
||||
impl<'b> ::flatbuffers::Push for ArrayStruct {
|
||||
type Output = ArrayStruct;
|
||||
#[inline]
|
||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||
let src = unsafe { ::core::slice::from_raw_parts(self as *const ArrayStruct as *const u8, <Self as flatbuffers::Push>::size()) };
|
||||
let src = unsafe { ::core::slice::from_raw_parts(self as *const ArrayStruct 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 ArrayStruct {
|
||||
impl<'a> ::flatbuffers::Verifiable for ArrayStruct {
|
||||
#[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)
|
||||
}
|
||||
}
|
||||
@@ -94,82 +86,84 @@ impl<'a> ArrayStruct {
|
||||
}
|
||||
|
||||
pub fn a(&self) -> f32 {
|
||||
let mut mem = core::mem::MaybeUninit::<<f32 as EndianScalar>::Scalar>::uninit();
|
||||
let mut mem = ::core::mem::MaybeUninit::<<f32 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[0..].as_ptr(),
|
||||
mem.as_mut_ptr() as *mut u8,
|
||||
core::mem::size_of::<<f32 as EndianScalar>::Scalar>(),
|
||||
::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||
);
|
||||
mem.assume_init()
|
||||
})
|
||||
}
|
||||
|
||||
pub fn set_a(&mut self, x: f32) {
|
||||
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[0..].as_mut_ptr(),
|
||||
core::mem::size_of::<<f32 as EndianScalar>::Scalar>(),
|
||||
::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn b(&'a self) -> flatbuffers::Array<'a, i32, 15> {
|
||||
pub fn b(&'a self) -> ::flatbuffers::Array<'a, i32, 15> {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
unsafe { flatbuffers::Array::follow(&self.0, 4) }
|
||||
use ::flatbuffers::Follow;
|
||||
unsafe { ::flatbuffers::Array::follow(&self.0, 4) }
|
||||
}
|
||||
|
||||
pub fn set_b(&mut self, items: &[i32; 15]) {
|
||||
// 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, 4, items) };
|
||||
unsafe { ::flatbuffers::emplace_scalar_array(&mut self.0, 4, items) };
|
||||
}
|
||||
|
||||
pub fn c(&self) -> i8 {
|
||||
let mut mem = core::mem::MaybeUninit::<<i8 as EndianScalar>::Scalar>::uninit();
|
||||
let mut mem = ::core::mem::MaybeUninit::<<i8 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[64..].as_ptr(),
|
||||
mem.as_mut_ptr() as *mut u8,
|
||||
core::mem::size_of::<<i8 as EndianScalar>::Scalar>(),
|
||||
::core::mem::size_of::<<i8 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||
);
|
||||
mem.assume_init()
|
||||
})
|
||||
}
|
||||
|
||||
pub fn set_c(&mut self, x: i8) {
|
||||
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[64..].as_mut_ptr(),
|
||||
core::mem::size_of::<<i8 as EndianScalar>::Scalar>(),
|
||||
::core::mem::size_of::<<i8 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn d(&'a self) -> flatbuffers::Array<'a, NestedStruct, 2> {
|
||||
pub fn d(&'a self) -> ::flatbuffers::Array<'a, NestedStruct, 2> {
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid array in this slot
|
||||
unsafe { flatbuffers::Array::follow(&self.0, 72) }
|
||||
use ::flatbuffers::Follow;
|
||||
unsafe { ::flatbuffers::Array::follow(&self.0, 72) }
|
||||
}
|
||||
|
||||
pub fn set_d(&mut self, x: &[NestedStruct; 2]) {
|
||||
@@ -177,7 +171,7 @@ impl<'a> ArrayStruct {
|
||||
// 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(72),
|
||||
64,
|
||||
@@ -186,46 +180,47 @@ impl<'a> ArrayStruct {
|
||||
}
|
||||
|
||||
pub fn e(&self) -> i32 {
|
||||
let mut mem = core::mem::MaybeUninit::<<i32 as EndianScalar>::Scalar>::uninit();
|
||||
let mut mem = ::core::mem::MaybeUninit::<<i32 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[136..].as_ptr(),
|
||||
mem.as_mut_ptr() as *mut u8,
|
||||
core::mem::size_of::<<i32 as EndianScalar>::Scalar>(),
|
||||
::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||
);
|
||||
mem.assume_init()
|
||||
})
|
||||
}
|
||||
|
||||
pub fn set_e(&mut self, x: i32) {
|
||||
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[136..].as_mut_ptr(),
|
||||
core::mem::size_of::<<i32 as EndianScalar>::Scalar>(),
|
||||
::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn f(&'a self) -> flatbuffers::Array<'a, i64, 2> {
|
||||
pub fn f(&'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, 144) }
|
||||
use ::flatbuffers::Follow;
|
||||
unsafe { ::flatbuffers::Array::follow(&self.0, 144) }
|
||||
}
|
||||
|
||||
pub fn set_f(&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, 144, items) };
|
||||
unsafe { ::flatbuffers::emplace_scalar_array(&mut self.0, 144, items) };
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> ArrayStructT {
|
||||
@@ -233,7 +228,7 @@ impl<'a> ArrayStruct {
|
||||
a: self.a(),
|
||||
b: self.b().into(),
|
||||
c: self.c(),
|
||||
d: { let d = self.d(); flatbuffers::array_init(|i| d.get(i).unpack()) },
|
||||
d: { let d = self.d(); ::flatbuffers::array_init(|i| d.get(i).unpack()) },
|
||||
e: self.e(),
|
||||
f: self.f().into(),
|
||||
}
|
||||
@@ -255,7 +250,7 @@ impl ArrayStructT {
|
||||
self.a,
|
||||
&self.b,
|
||||
self.c,
|
||||
&flatbuffers::array_init(|i| self.d[i].pack()),
|
||||
&::flatbuffers::array_init(|i| self.d[i].pack()),
|
||||
self.e,
|
||||
&self.f,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user