From 586b78dad084c2bd70fc1afb3f9cdb57c472d336 Mon Sep 17 00:00:00 2001 From: Marcin Radomski Date: Thu, 30 Jan 2025 12:18:32 +0000 Subject: [PATCH 01/11] flatbuffers Rust reflection: replace num with num-traits num crate is a wrapper over num-traits and a few other crates, that reexports the APIs from all of them. We only need num-traits. Signed-off-by: Marcin Radomski --- rust/reflection/Cargo.toml | 2 +- rust/reflection/src/lib.rs | 6 +++--- rust/reflection/src/safe_buffer.rs | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/rust/reflection/Cargo.toml b/rust/reflection/Cargo.toml index 9593d9b2e7b..2d3f3338a04 100644 --- a/rust/reflection/Cargo.toml +++ b/rust/reflection/Cargo.toml @@ -7,6 +7,6 @@ edition = "2021" flatbuffers = { path = "../flatbuffers"} escape_string = "0.1.2" stdint = "0.2.0" -num = "0.4.1" +num-traits = "0.2.19" anyhow = "1.0.75" thiserror = "1.0" diff --git a/rust/reflection/src/lib.rs b/rust/reflection/src/lib.rs index 1ca5a5e84e5..d42df601920 100644 --- a/rust/reflection/src/lib.rs +++ b/rust/reflection/src/lib.rs @@ -30,9 +30,9 @@ use reflection_generated::reflection::{BaseType, Field, Object, Schema}; use core::mem::size_of; use escape_string::escape; -use num::traits::float::Float; -use num::traits::int::PrimInt; -use num::traits::FromPrimitive; +use num_traits::float::Float; +use num_traits::int::PrimInt; +use num_traits::FromPrimitive; use stdint::uintmax_t; use thiserror::Error; diff --git a/rust/reflection/src/safe_buffer.rs b/rust/reflection/src/safe_buffer.rs index 5923f0fb7ff..ba61e87301f 100644 --- a/rust/reflection/src/safe_buffer.rs +++ b/rust/reflection/src/safe_buffer.rs @@ -25,9 +25,9 @@ use crate::{ FlatbufferResult, ForwardsUOffset, }; use flatbuffers::{Follow, Table, Vector, VerifierOptions}; -use num::traits::float::Float; -use num::traits::int::PrimInt; -use num::traits::FromPrimitive; +use num_traits::float::Float; +use num_traits::int::PrimInt; +use num_traits::FromPrimitive; use std::collections::HashMap; #[derive(Debug)] From 445b73963b17e51c7590f2008dc30fc879a6a72d Mon Sep 17 00:00:00 2001 From: Marcin Radomski Date: Thu, 30 Jan 2025 12:19:03 +0000 Subject: [PATCH 02/11] Rust reflection: drop dependency on stdint crate We only use it to get intmax_t for deriving alignment, which is an alias for `core::ffi::c_long` [1]. We can use that directly instead. [1] https://docs.rs/stdint/1.0.0/stdint/type.intmax_t.html Signed-off-by: Marcin Radomski --- rust/reflection/Cargo.toml | 1 - rust/reflection/src/lib.rs | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rust/reflection/Cargo.toml b/rust/reflection/Cargo.toml index 2d3f3338a04..65a90c160bd 100644 --- a/rust/reflection/Cargo.toml +++ b/rust/reflection/Cargo.toml @@ -6,7 +6,6 @@ edition = "2021" [dependencies] flatbuffers = { path = "../flatbuffers"} escape_string = "0.1.2" -stdint = "0.2.0" num-traits = "0.2.19" anyhow = "1.0.75" thiserror = "1.0" diff --git a/rust/reflection/src/lib.rs b/rust/reflection/src/lib.rs index d42df601920..806b3dd7b3c 100644 --- a/rust/reflection/src/lib.rs +++ b/rust/reflection/src/lib.rs @@ -33,7 +33,6 @@ use escape_string::escape; use num_traits::float::Float; use num_traits::int::PrimInt; use num_traits::FromPrimitive; -use stdint::uintmax_t; use thiserror::Error; #[derive(Error, Debug, PartialEq)] @@ -541,7 +540,9 @@ pub unsafe fn set_string( if delta != 0 { // Rounds the delta up to the nearest multiple of the maximum int size to keep the types after the insersion point aligned. - let mask = (size_of::() - 1) as isize; + // stdint crate defines intmax_t as an alias for c_long; use it directly to avoid extra + // dependency. + let mask = (size_of::() - 1) as isize; let offset = (delta + mask) & !mask; let mut visited_vec = vec![false; buf.len()]; From d7fcd5ffbee519e735ac1ba03ad4215308e7f8a1 Mon Sep 17 00:00:00 2001 From: Marcin Radomski Date: Thu, 30 Jan 2025 12:19:43 +0000 Subject: [PATCH 03/11] Rust reflection: drop dependency on escape_string crate It's used to format a string used for debugging only, so we might as well use the builtin Debug representation of a string. Signed-off-by: Marcin Radomski --- rust/reflection/Cargo.toml | 1 - rust/reflection/src/lib.rs | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/rust/reflection/Cargo.toml b/rust/reflection/Cargo.toml index 65a90c160bd..804fb68127a 100644 --- a/rust/reflection/Cargo.toml +++ b/rust/reflection/Cargo.toml @@ -5,7 +5,6 @@ edition = "2021" [dependencies] flatbuffers = { path = "../flatbuffers"} -escape_string = "0.1.2" num-traits = "0.2.19" anyhow = "1.0.75" thiserror = "1.0" diff --git a/rust/reflection/src/lib.rs b/rust/reflection/src/lib.rs index 806b3dd7b3c..f2ef413ae71 100644 --- a/rust/reflection/src/lib.rs +++ b/rust/reflection/src/lib.rs @@ -29,7 +29,6 @@ use flatbuffers::{ use reflection_generated::reflection::{BaseType, Field, Object, Schema}; use core::mem::size_of; -use escape_string::escape; use num_traits::float::Float; use num_traits::int::PrimInt; use num_traits::FromPrimitive; @@ -716,7 +715,8 @@ unsafe fn get_any_value_string( } let mut field_value = get_any_field_string(&table, &field, schema); if field.type_().base_type() == BaseType::String { - field_value = escape(field_value.as_str()).to_string(); + // Escape the string + field_value = format!("{:?}", field_value.as_str()); } s += field.name(); s += ": "; From 8d508921ce59c2efef59c7539b94b342f402885b Mon Sep 17 00:00:00 2001 From: Marcin Radomski Date: Thu, 30 Jan 2025 12:19:49 +0000 Subject: [PATCH 04/11] Rust codegen: add derives on generated bitflags Otherwise it limits the use of structs generated for reflection.fbs in Rust reflection API. Signed-off-by: Marcin Radomski --- src/idl_gen_rust.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/idl_gen_rust.cpp b/src/idl_gen_rust.cpp index b3e78e12457..f6a0ca46125 100644 --- a/src/idl_gen_rust.cpp +++ b/src/idl_gen_rust.cpp @@ -727,7 +727,7 @@ class RustGenerator : public BaseGenerator { code_ += "mod bitflags_{{ENUM_NAMESPACE}} {"; code_ += " flatbuffers::bitflags::bitflags! {"; GenComment(enum_def.doc_comment, " "); - code_ += " #[derive(Default)]"; + code_ += " #[derive(Default, Debug, Clone, Copy, PartialEq)]"; code_ += " {{ACCESS_TYPE}} struct {{ENUM_TY}}: {{BASE_TYPE}} {"; ForAllEnumValues1(enum_def, [&](const EnumVal &ev) { this->GenComment(ev.doc_comment, " "); From fd10db5d20b1b39f32a8c598f066ff450db94377 Mon Sep 17 00:00:00 2001 From: Marcin Radomski Date: Thu, 30 Jan 2025 13:30:27 +0000 Subject: [PATCH 05/11] Rust flatbuffers: update bitflags dependency to 2.8 Signed-off-by: Marcin Radomski --- rust/flatbuffers/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/flatbuffers/Cargo.toml b/rust/flatbuffers/Cargo.toml index 78eea287e05..47500e08a5a 100644 --- a/rust/flatbuffers/Cargo.toml +++ b/rust/flatbuffers/Cargo.toml @@ -17,7 +17,7 @@ std = [] serialize = ["serde"] [dependencies] -bitflags = "1.2.1" +bitflags = "2.8.0" serde = { version = "1.0", optional = true } [build-dependencies] From e8e51605c13523dc1b7295b8d95cc188c2eaaaf1 Mon Sep 17 00:00:00 2001 From: Marcin Radomski Date: Thu, 30 Jan 2025 13:34:47 +0000 Subject: [PATCH 06/11] Rust codegen: use bitflags v2 API for converting from bits from_bits_unchecked was replaced with safe from_bits_retain. Signed-off-by: Marcin Radomski --- src/idl_gen_rust.cpp | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/src/idl_gen_rust.cpp b/src/idl_gen_rust.cpp index f6a0ca46125..b8811c6f3ff 100644 --- a/src/idl_gen_rust.cpp +++ b/src/idl_gen_rust.cpp @@ -843,20 +843,7 @@ class RustGenerator : public BaseGenerator { code_ += " let b = flatbuffers::read_scalar_at::<{{BASE_TYPE}}>(buf, loc);"; if (IsBitFlagsEnum(enum_def)) { - // Safety: - // This is safe because we know bitflags is implemented with a repr - // transparent uint of the correct size. from_bits_unchecked will be - // replaced by an equivalent but safe from_bits_retain in bitflags 2.0 - // https://github.com/bitflags/bitflags/issues/262 - code_ += " // Safety:"; - code_ += - " // This is safe because we know bitflags is implemented with a " - "repr transparent uint of the correct size."; - code_ += - " // from_bits_unchecked will be replaced by an equivalent but " - "safe from_bits_retain in bitflags 2.0"; - code_ += " // https://github.com/bitflags/bitflags/issues/262"; - code_ += " Self::from_bits_unchecked(b)"; + code_ += " Self::from_bits_retain(b)"; } else { code_ += " Self(b)"; } @@ -884,20 +871,7 @@ class RustGenerator : public BaseGenerator { code_ += " fn from_little_endian(v: {{BASE_TYPE}}) -> Self {"; code_ += " let b = {{BASE_TYPE}}::from_le(v);"; if (IsBitFlagsEnum(enum_def)) { - // Safety: - // This is safe because we know bitflags is implemented with a repr - // transparent uint of the correct size. from_bits_unchecked will be - // replaced by an equivalent but safe from_bits_retain in bitflags 2.0 - // https://github.com/bitflags/bitflags/issues/262 - code_ += " // Safety:"; - code_ += - " // This is safe because we know bitflags is implemented with a " - "repr transparent uint of the correct size."; - code_ += - " // from_bits_unchecked will be replaced by an equivalent but " - "safe from_bits_retain in bitflags 2.0"; - code_ += " // https://github.com/bitflags/bitflags/issues/262"; - code_ += " unsafe { Self::from_bits_unchecked(b) }"; + code_ += " Self::from_bits_retain(b)"; } else { code_ += " Self(b)"; } From 3db2c0fde59df04be4cefef3f4c5acd32f061d31 Mon Sep 17 00:00:00 2001 From: Marcin Radomski Date: Thu, 30 Jan 2025 12:57:20 +0000 Subject: [PATCH 07/11] Regenerate Rust code after idl change Signed-off-by: Marcin Radomski --- .../my_game/example/color_generated.rs | 14 +++----------- .../my_game/example/long_enum_generated.rs | 14 +++----------- .../my_game/example/color_generated.rs | 14 +++----------- .../my_game/example/long_enum_generated.rs | 14 +++----------- 4 files changed, 12 insertions(+), 44 deletions(-) diff --git a/tests/monster_test/my_game/example/color_generated.rs b/tests/monster_test/my_game/example/color_generated.rs index 9cd348aa56b..713e2b3da36 100644 --- a/tests/monster_test/my_game/example/color_generated.rs +++ b/tests/monster_test/my_game/example/color_generated.rs @@ -13,7 +13,7 @@ use super::*; mod bitflags_color { flatbuffers::bitflags::bitflags! { /// Composite components of Monster color. - #[derive(Default)] + #[derive(Default, Debug, Clone, Copy, PartialEq)] pub struct Color: u8 { const Red = 1; /// \brief color Green @@ -31,11 +31,7 @@ impl<'a> flatbuffers::Follow<'a> for Color { #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { let b = flatbuffers::read_scalar_at::(buf, loc); - // Safety: - // This is safe because we know bitflags is implemented with a repr transparent uint of the correct size. - // from_bits_unchecked will be replaced by an equivalent but safe from_bits_retain in bitflags 2.0 - // https://github.com/bitflags/bitflags/issues/262 - Self::from_bits_unchecked(b) + Self::from_bits_retain(b) } } @@ -57,11 +53,7 @@ impl flatbuffers::EndianScalar for Color { #[allow(clippy::wrong_self_convention)] fn from_little_endian(v: u8) -> Self { let b = u8::from_le(v); - // Safety: - // This is safe because we know bitflags is implemented with a repr transparent uint of the correct size. - // from_bits_unchecked will be replaced by an equivalent but safe from_bits_retain in bitflags 2.0 - // https://github.com/bitflags/bitflags/issues/262 - unsafe { Self::from_bits_unchecked(b) } + Self::from_bits_retain(b) } } diff --git a/tests/monster_test/my_game/example/long_enum_generated.rs b/tests/monster_test/my_game/example/long_enum_generated.rs index d7625269c4b..c912d25b091 100644 --- a/tests/monster_test/my_game/example/long_enum_generated.rs +++ b/tests/monster_test/my_game/example/long_enum_generated.rs @@ -12,7 +12,7 @@ use super::*; #[allow(non_upper_case_globals)] mod bitflags_long_enum { flatbuffers::bitflags::bitflags! { - #[derive(Default)] + #[derive(Default, Debug, Clone, Copy, PartialEq)] pub struct LongEnum: u64 { const LongOne = 2; const LongTwo = 4; @@ -27,11 +27,7 @@ impl<'a> flatbuffers::Follow<'a> for LongEnum { #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { let b = flatbuffers::read_scalar_at::(buf, loc); - // Safety: - // This is safe because we know bitflags is implemented with a repr transparent uint of the correct size. - // from_bits_unchecked will be replaced by an equivalent but safe from_bits_retain in bitflags 2.0 - // https://github.com/bitflags/bitflags/issues/262 - Self::from_bits_unchecked(b) + Self::from_bits_retain(b) } } @@ -53,11 +49,7 @@ impl flatbuffers::EndianScalar for LongEnum { #[allow(clippy::wrong_self_convention)] fn from_little_endian(v: u64) -> Self { let b = u64::from_le(v); - // Safety: - // This is safe because we know bitflags is implemented with a repr transparent uint of the correct size. - // from_bits_unchecked will be replaced by an equivalent but safe from_bits_retain in bitflags 2.0 - // https://github.com/bitflags/bitflags/issues/262 - unsafe { Self::from_bits_unchecked(b) } + Self::from_bits_retain(b) } } diff --git a/tests/monster_test_serialize/my_game/example/color_generated.rs b/tests/monster_test_serialize/my_game/example/color_generated.rs index 0f9887952d7..d6879de592c 100644 --- a/tests/monster_test_serialize/my_game/example/color_generated.rs +++ b/tests/monster_test_serialize/my_game/example/color_generated.rs @@ -15,7 +15,7 @@ use super::*; mod bitflags_color { flatbuffers::bitflags::bitflags! { /// Composite components of Monster color. - #[derive(Default)] + #[derive(Default, Debug, Clone, Copy, PartialEq)] pub struct Color: u8 { const Red = 1; /// \brief color Green @@ -42,11 +42,7 @@ impl<'a> flatbuffers::Follow<'a> for Color { #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { let b = flatbuffers::read_scalar_at::(buf, loc); - // Safety: - // This is safe because we know bitflags is implemented with a repr transparent uint of the correct size. - // from_bits_unchecked will be replaced by an equivalent but safe from_bits_retain in bitflags 2.0 - // https://github.com/bitflags/bitflags/issues/262 - Self::from_bits_unchecked(b) + Self::from_bits_retain(b) } } @@ -68,11 +64,7 @@ impl flatbuffers::EndianScalar for Color { #[allow(clippy::wrong_self_convention)] fn from_little_endian(v: u8) -> Self { let b = u8::from_le(v); - // Safety: - // This is safe because we know bitflags is implemented with a repr transparent uint of the correct size. - // from_bits_unchecked will be replaced by an equivalent but safe from_bits_retain in bitflags 2.0 - // https://github.com/bitflags/bitflags/issues/262 - unsafe { Self::from_bits_unchecked(b) } + Self::from_bits_retain(b) } } diff --git a/tests/monster_test_serialize/my_game/example/long_enum_generated.rs b/tests/monster_test_serialize/my_game/example/long_enum_generated.rs index 1f56c6fb869..e588ae0e4af 100644 --- a/tests/monster_test_serialize/my_game/example/long_enum_generated.rs +++ b/tests/monster_test_serialize/my_game/example/long_enum_generated.rs @@ -14,7 +14,7 @@ use super::*; #[allow(non_upper_case_globals)] mod bitflags_long_enum { flatbuffers::bitflags::bitflags! { - #[derive(Default)] + #[derive(Default, Debug, Clone, Copy, PartialEq)] pub struct LongEnum: u64 { const LongOne = 2; const LongTwo = 4; @@ -38,11 +38,7 @@ impl<'a> flatbuffers::Follow<'a> for LongEnum { #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { let b = flatbuffers::read_scalar_at::(buf, loc); - // Safety: - // This is safe because we know bitflags is implemented with a repr transparent uint of the correct size. - // from_bits_unchecked will be replaced by an equivalent but safe from_bits_retain in bitflags 2.0 - // https://github.com/bitflags/bitflags/issues/262 - Self::from_bits_unchecked(b) + Self::from_bits_retain(b) } } @@ -64,11 +60,7 @@ impl flatbuffers::EndianScalar for LongEnum { #[allow(clippy::wrong_self_convention)] fn from_little_endian(v: u64) -> Self { let b = u64::from_le(v); - // Safety: - // This is safe because we know bitflags is implemented with a repr transparent uint of the correct size. - // from_bits_unchecked will be replaced by an equivalent but safe from_bits_retain in bitflags 2.0 - // https://github.com/bitflags/bitflags/issues/262 - unsafe { Self::from_bits_unchecked(b) } + Self::from_bits_retain(b) } } From 4ded7382a1ef4d28c8c7169d0930e809170a2c03 Mon Sep 17 00:00:00 2001 From: Marcin Radomski Date: Thu, 30 Jan 2025 13:07:01 +0000 Subject: [PATCH 08/11] Regenerate reflection_generated.rs With flatc --rust ../../../reflection/reflection.fbs Signed-off-by: Marcin Radomski --- rust/reflection/src/reflection_generated.rs | 5243 ++++++++----------- 1 file changed, 2270 insertions(+), 2973 deletions(-) diff --git a/rust/reflection/src/reflection_generated.rs b/rust/reflection/src/reflection_generated.rs index adf5c858348..84581e82c57 100644 --- a/rust/reflection/src/reflection_generated.rs +++ b/rust/reflection/src/reflection_generated.rs @@ -1,9 +1,10 @@ // automatically generated by the FlatBuffers compiler, do not modify + // @generated -use core::cmp::Ordering; use core::mem; +use core::cmp::Ordering; extern crate flatbuffers; use self::flatbuffers::{EndianScalar, Follow}; @@ -11,2978 +12,2274 @@ use self::flatbuffers::{EndianScalar, Follow}; #[allow(unused_imports, dead_code)] pub mod reflection { - use core::cmp::Ordering; - use core::mem; - - extern crate flatbuffers; - use self::flatbuffers::{EndianScalar, Follow}; - - #[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." - )] - pub const ENUM_MIN_BASE_TYPE: i8 = 0; - #[deprecated( - since = "2.0.0", - note = "Use associated constants instead. This will no longer be generated in 2021." - )] - pub const ENUM_MAX_BASE_TYPE: i8 = 19; - #[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_BASE_TYPE: [BaseType; 20] = [ - BaseType::None, - BaseType::UType, - BaseType::Bool, - BaseType::Byte, - BaseType::UByte, - BaseType::Short, - BaseType::UShort, - BaseType::Int, - BaseType::UInt, - BaseType::Long, - BaseType::ULong, - BaseType::Float, - BaseType::Double, - BaseType::String, - BaseType::Vector, - BaseType::Obj, - BaseType::Union, - BaseType::Array, - BaseType::Vector64, - BaseType::MaxBaseType, - ]; - - #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] - #[repr(transparent)] - pub struct BaseType(pub i8); - #[allow(non_upper_case_globals)] - impl BaseType { - pub const None: Self = Self(0); - pub const UType: Self = Self(1); - pub const Bool: Self = Self(2); - pub const Byte: Self = Self(3); - pub const UByte: Self = Self(4); - pub const Short: Self = Self(5); - pub const UShort: Self = Self(6); - pub const Int: Self = Self(7); - pub const UInt: Self = Self(8); - pub const Long: Self = Self(9); - pub const ULong: Self = Self(10); - pub const Float: Self = Self(11); - pub const Double: Self = Self(12); - pub const String: Self = Self(13); - pub const Vector: Self = Self(14); - pub const Obj: Self = Self(15); - pub const Union: Self = Self(16); - pub const Array: Self = Self(17); - pub const Vector64: Self = Self(18); - pub const MaxBaseType: Self = Self(19); - - pub const ENUM_MIN: i8 = 0; - pub const ENUM_MAX: i8 = 19; - pub const ENUM_VALUES: &'static [Self] = &[ - Self::None, - Self::UType, - Self::Bool, - Self::Byte, - Self::UByte, - Self::Short, - Self::UShort, - Self::Int, - Self::UInt, - Self::Long, - Self::ULong, - Self::Float, - Self::Double, - Self::String, - Self::Vector, - Self::Obj, - Self::Union, - Self::Array, - Self::Vector64, - Self::MaxBaseType, - ]; - /// Returns the variant's name or "" if unknown. - pub fn variant_name(self) -> Option<&'static str> { - match self { - Self::None => Some("None"), - Self::UType => Some("UType"), - Self::Bool => Some("Bool"), - Self::Byte => Some("Byte"), - Self::UByte => Some("UByte"), - Self::Short => Some("Short"), - Self::UShort => Some("UShort"), - Self::Int => Some("Int"), - Self::UInt => Some("UInt"), - Self::Long => Some("Long"), - Self::ULong => Some("ULong"), - Self::Float => Some("Float"), - Self::Double => Some("Double"), - Self::String => Some("String"), - Self::Vector => Some("Vector"), - Self::Obj => Some("Obj"), - Self::Union => Some("Union"), - Self::Array => Some("Array"), - Self::Vector64 => Some("Vector64"), - Self::MaxBaseType => Some("MaxBaseType"), - _ => None, - } - } - } - impl core::fmt::Debug for BaseType { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { - if let Some(name) = self.variant_name() { - f.write_str(name) - } else { - f.write_fmt(format_args!("", self.0)) - } - } - } - impl<'a> flatbuffers::Follow<'a> for BaseType { - type Inner = Self; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); - Self(b) - } - } - - impl flatbuffers::Push for BaseType { - type Output = BaseType; - #[inline] - unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); - } - } - - impl flatbuffers::EndianScalar for BaseType { - type Scalar = i8; - #[inline] - fn to_little_endian(self) -> i8 { - self.0.to_le() - } - #[inline] - #[allow(clippy::wrong_self_convention)] - fn from_little_endian(v: i8) -> Self { - let b = i8::from_le(v); - Self(b) - } - } - - impl<'a> flatbuffers::Verifiable for BaseType { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - i8::run_verifier(v, pos) - } - } - - impl flatbuffers::SimpleToVerifyInSlice for BaseType {} - #[allow(non_upper_case_globals)] - mod bitflags_advanced_features { - flatbuffers::bitflags::bitflags! { - /// New schema language features that are not supported by old code generators. - #[derive(Default)] - pub struct AdvancedFeatures: u64 { - const AdvancedArrayFeatures = 1; - const AdvancedUnionFeatures = 2; - const OptionalScalars = 4; - const DefaultVectorsAndStrings = 8; - } - } - } - pub use self::bitflags_advanced_features::AdvancedFeatures; - - impl<'a> flatbuffers::Follow<'a> for AdvancedFeatures { - type Inner = Self; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); - // Safety: - // This is safe because we know bitflags is implemented with a repr transparent uint of the correct size. - // from_bits_unchecked will be replaced by an equivalent but safe from_bits_retain in bitflags 2.0 - // https://github.com/bitflags/bitflags/issues/262 - Self::from_bits_unchecked(b) - } - } - - impl flatbuffers::Push for AdvancedFeatures { - type Output = AdvancedFeatures; - #[inline] - unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.bits()); - } - } - - impl flatbuffers::EndianScalar for AdvancedFeatures { - type Scalar = u64; - #[inline] - fn to_little_endian(self) -> u64 { - self.bits().to_le() - } - #[inline] - #[allow(clippy::wrong_self_convention)] - fn from_little_endian(v: u64) -> Self { - let b = u64::from_le(v); - // Safety: - // This is safe because we know bitflags is implemented with a repr transparent uint of the correct size. - // from_bits_unchecked will be replaced by an equivalent but safe from_bits_retain in bitflags 2.0 - // https://github.com/bitflags/bitflags/issues/262 - unsafe { Self::from_bits_unchecked(b) } - } - } - - impl<'a> flatbuffers::Verifiable for AdvancedFeatures { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - u64::run_verifier(v, pos) - } - } - - impl flatbuffers::SimpleToVerifyInSlice for AdvancedFeatures {} - pub enum TypeOffset {} - #[derive(Copy, Clone, PartialEq)] - - pub struct Type<'a> { - pub _tab: flatbuffers::Table<'a>, - } - - impl<'a> flatbuffers::Follow<'a> for Type<'a> { - type Inner = Type<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), - } - } - } - - impl<'a> Type<'a> { - pub const VT_BASE_TYPE: flatbuffers::VOffsetT = 4; - pub const VT_ELEMENT: flatbuffers::VOffsetT = 6; - pub const VT_INDEX: flatbuffers::VOffsetT = 8; - pub const VT_FIXED_LENGTH: flatbuffers::VOffsetT = 10; - pub const VT_BASE_SIZE: flatbuffers::VOffsetT = 12; - pub const VT_ELEMENT_SIZE: flatbuffers::VOffsetT = 14; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - Type { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args TypeArgs, - ) -> flatbuffers::WIPOffset> { - let mut builder = TypeBuilder::new(_fbb); - builder.add_element_size(args.element_size); - builder.add_base_size(args.base_size); - builder.add_index(args.index); - builder.add_fixed_length(args.fixed_length); - builder.add_element(args.element); - builder.add_base_type(args.base_type); - builder.finish() - } - - #[inline] - pub fn base_type(&self) -> BaseType { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Type::VT_BASE_TYPE, Some(BaseType::None)) - .unwrap() - } - } - #[inline] - pub fn element(&self) -> BaseType { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Type::VT_ELEMENT, Some(BaseType::None)) - .unwrap() - } - } - #[inline] - pub fn index(&self) -> i32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Type::VT_INDEX, Some(-1)).unwrap() } - } - #[inline] - pub fn fixed_length(&self) -> u16 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Type::VT_FIXED_LENGTH, Some(0)) - .unwrap() - } - } - /// The size (octets) of the `base_type` field. - #[inline] - pub fn base_size(&self) -> u32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Type::VT_BASE_SIZE, Some(4)).unwrap() } - } - /// The size (octets) of the `element` field, if present. - #[inline] - pub fn element_size(&self) -> u32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Type::VT_ELEMENT_SIZE, Some(0)) - .unwrap() - } - } - } - - impl flatbuffers::Verifiable for Type<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::("base_type", Self::VT_BASE_TYPE, false)? - .visit_field::("element", Self::VT_ELEMENT, false)? - .visit_field::("index", Self::VT_INDEX, false)? - .visit_field::("fixed_length", Self::VT_FIXED_LENGTH, false)? - .visit_field::("base_size", Self::VT_BASE_SIZE, false)? - .visit_field::("element_size", Self::VT_ELEMENT_SIZE, false)? - .finish(); - Ok(()) - } - } - pub struct TypeArgs { - pub base_type: BaseType, - pub element: BaseType, - pub index: i32, - pub fixed_length: u16, - pub base_size: u32, - pub element_size: u32, - } - impl<'a> Default for TypeArgs { - #[inline] - fn default() -> Self { - TypeArgs { - base_type: BaseType::None, - element: BaseType::None, - index: -1, - fixed_length: 0, - base_size: 4, - element_size: 0, - } - } - } - - pub struct TypeBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, - } - impl<'a: 'b, 'b> TypeBuilder<'a, 'b> { - #[inline] - pub fn add_base_type(&mut self, base_type: BaseType) { - self.fbb_ - .push_slot::(Type::VT_BASE_TYPE, base_type, BaseType::None); - } - #[inline] - pub fn add_element(&mut self, element: BaseType) { - self.fbb_ - .push_slot::(Type::VT_ELEMENT, element, BaseType::None); - } - #[inline] - pub fn add_index(&mut self, index: i32) { - self.fbb_.push_slot::(Type::VT_INDEX, index, -1); - } - #[inline] - pub fn add_fixed_length(&mut self, fixed_length: u16) { - self.fbb_ - .push_slot::(Type::VT_FIXED_LENGTH, fixed_length, 0); - } - #[inline] - pub fn add_base_size(&mut self, base_size: u32) { - self.fbb_.push_slot::(Type::VT_BASE_SIZE, base_size, 4); - } - #[inline] - pub fn add_element_size(&mut self, element_size: u32) { - self.fbb_ - .push_slot::(Type::VT_ELEMENT_SIZE, element_size, 0); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> TypeBuilder<'a, 'b> { - let start = _fbb.start_table(); - TypeBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) - } - } - - impl core::fmt::Debug for Type<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("Type"); - ds.field("base_type", &self.base_type()); - ds.field("element", &self.element()); - ds.field("index", &self.index()); - ds.field("fixed_length", &self.fixed_length()); - ds.field("base_size", &self.base_size()); - ds.field("element_size", &self.element_size()); - ds.finish() - } - } - pub enum KeyValueOffset {} - #[derive(Copy, Clone, PartialEq)] - - pub struct KeyValue<'a> { - pub _tab: flatbuffers::Table<'a>, - } - - impl<'a> flatbuffers::Follow<'a> for KeyValue<'a> { - type Inner = KeyValue<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), - } - } - } - - impl<'a> KeyValue<'a> { - pub const VT_KEY: flatbuffers::VOffsetT = 4; - pub const VT_VALUE: flatbuffers::VOffsetT = 6; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - KeyValue { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args KeyValueArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = KeyValueBuilder::new(_fbb); - if let Some(x) = args.value { - builder.add_value(x); - } - if let Some(x) = args.key { - builder.add_key(x); - } - builder.finish() - } - - #[inline] - pub fn key(&self) -> &'a str { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(KeyValue::VT_KEY, None) - .unwrap() - } - } - #[inline] - pub fn key_compare_less_than(&self, o: &KeyValue) -> bool { - self.key() < o.key() - } - - #[inline] - pub fn key_compare_with_value(&self, val: &str) -> ::core::cmp::Ordering { - let key = self.key(); - key.cmp(val) - } - #[inline] - pub fn value(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(KeyValue::VT_VALUE, None) - } - } - } - - impl flatbuffers::Verifiable for KeyValue<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>("key", Self::VT_KEY, true)? - .visit_field::>("value", Self::VT_VALUE, false)? - .finish(); - Ok(()) - } - } - pub struct KeyValueArgs<'a> { - pub key: Option>, - pub value: Option>, - } - impl<'a> Default for KeyValueArgs<'a> { - #[inline] - fn default() -> Self { - KeyValueArgs { - key: None, // required field - value: None, - } - } - } - - pub struct KeyValueBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, - } - impl<'a: 'b, 'b> KeyValueBuilder<'a, 'b> { - #[inline] - pub fn add_key(&mut self, key: flatbuffers::WIPOffset<&'b str>) { - self.fbb_ - .push_slot_always::>(KeyValue::VT_KEY, key); - } - #[inline] - pub fn add_value(&mut self, value: flatbuffers::WIPOffset<&'b str>) { - self.fbb_ - .push_slot_always::>(KeyValue::VT_VALUE, value); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> KeyValueBuilder<'a, 'b> { - let start = _fbb.start_table(); - KeyValueBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - self.fbb_.required(o, KeyValue::VT_KEY, "key"); - flatbuffers::WIPOffset::new(o.value()) - } - } - - impl core::fmt::Debug for KeyValue<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("KeyValue"); - ds.field("key", &self.key()); - ds.field("value", &self.value()); - ds.finish() - } - } - pub enum EnumValOffset {} - #[derive(Copy, Clone, PartialEq)] - - pub struct EnumVal<'a> { - pub _tab: flatbuffers::Table<'a>, - } - - impl<'a> flatbuffers::Follow<'a> for EnumVal<'a> { - type Inner = EnumVal<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), - } - } - } - - impl<'a> EnumVal<'a> { - pub const VT_NAME: flatbuffers::VOffsetT = 4; - pub const VT_VALUE: flatbuffers::VOffsetT = 6; - pub const VT_UNION_TYPE: flatbuffers::VOffsetT = 10; - pub const VT_DOCUMENTATION: flatbuffers::VOffsetT = 12; - pub const VT_ATTRIBUTES: flatbuffers::VOffsetT = 14; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - EnumVal { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args EnumValArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = EnumValBuilder::new(_fbb); - builder.add_value(args.value); - if let Some(x) = args.attributes { - builder.add_attributes(x); - } - if let Some(x) = args.documentation { - builder.add_documentation(x); - } - if let Some(x) = args.union_type { - builder.add_union_type(x); - } - if let Some(x) = args.name { - builder.add_name(x); - } - builder.finish() - } - - #[inline] - pub fn name(&self) -> &'a str { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(EnumVal::VT_NAME, None) - .unwrap() - } - } - #[inline] - pub fn value(&self) -> i64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(EnumVal::VT_VALUE, Some(0)).unwrap() } - } - #[inline] - pub fn key_compare_less_than(&self, o: &EnumVal) -> bool { - self.value() < o.value() - } - - #[inline] - pub fn key_compare_with_value(&self, val: i64) -> ::core::cmp::Ordering { - let key = self.value(); - key.cmp(&val) - } - #[inline] - pub fn union_type(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(EnumVal::VT_UNION_TYPE, None) - } - } - #[inline] - pub fn documentation( - &self, - ) -> Option>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab.get::>, - >>(EnumVal::VT_DOCUMENTATION, None) - } - } - #[inline] - pub fn attributes( - &self, - ) -> Option>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab.get::>, - >>(EnumVal::VT_ATTRIBUTES, None) - } - } - } - - impl flatbuffers::Verifiable for EnumVal<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>("name", Self::VT_NAME, true)? - .visit_field::("value", Self::VT_VALUE, false)? - .visit_field::>( - "union_type", - Self::VT_UNION_TYPE, - false, - )? - .visit_field::>, - >>("documentation", Self::VT_DOCUMENTATION, false)? - .visit_field::>, - >>("attributes", Self::VT_ATTRIBUTES, false)? - .finish(); - Ok(()) - } - } - pub struct EnumValArgs<'a> { - pub name: Option>, - pub value: i64, - pub union_type: Option>>, - pub documentation: Option< - flatbuffers::WIPOffset>>, - >, - pub attributes: Option< - flatbuffers::WIPOffset< - flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>>, - >, - >, - } - impl<'a> Default for EnumValArgs<'a> { - #[inline] - fn default() -> Self { - EnumValArgs { - name: None, // required field - value: 0, - union_type: None, - documentation: None, - attributes: None, - } - } - } - - pub struct EnumValBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, - } - impl<'a: 'b, 'b> EnumValBuilder<'a, 'b> { - #[inline] - pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { - self.fbb_ - .push_slot_always::>(EnumVal::VT_NAME, name); - } - #[inline] - pub fn add_value(&mut self, value: i64) { - self.fbb_.push_slot::(EnumVal::VT_VALUE, value, 0); - } - #[inline] - pub fn add_union_type(&mut self, union_type: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>( - EnumVal::VT_UNION_TYPE, - union_type, - ); - } - #[inline] - pub fn add_documentation( - &mut self, - documentation: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset<&'b str>>, - >, - ) { - self.fbb_.push_slot_always::>( - EnumVal::VT_DOCUMENTATION, - documentation, - ); - } - #[inline] - pub fn add_attributes( - &mut self, - attributes: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, - >, - ) { - self.fbb_ - .push_slot_always::>(EnumVal::VT_ATTRIBUTES, attributes); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> EnumValBuilder<'a, 'b> { - let start = _fbb.start_table(); - EnumValBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - self.fbb_.required(o, EnumVal::VT_NAME, "name"); - flatbuffers::WIPOffset::new(o.value()) - } - } - - impl core::fmt::Debug for EnumVal<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("EnumVal"); - ds.field("name", &self.name()); - ds.field("value", &self.value()); - ds.field("union_type", &self.union_type()); - ds.field("documentation", &self.documentation()); - ds.field("attributes", &self.attributes()); - ds.finish() - } - } - pub enum EnumOffset {} - #[derive(Copy, Clone, PartialEq)] - - pub struct Enum<'a> { - pub _tab: flatbuffers::Table<'a>, - } - - impl<'a> flatbuffers::Follow<'a> for Enum<'a> { - type Inner = Enum<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), - } - } - } - - impl<'a> Enum<'a> { - pub const VT_NAME: flatbuffers::VOffsetT = 4; - pub const VT_VALUES: flatbuffers::VOffsetT = 6; - pub const VT_IS_UNION: flatbuffers::VOffsetT = 8; - pub const VT_UNDERLYING_TYPE: flatbuffers::VOffsetT = 10; - pub const VT_ATTRIBUTES: flatbuffers::VOffsetT = 12; - pub const VT_DOCUMENTATION: flatbuffers::VOffsetT = 14; - pub const VT_DECLARATION_FILE: flatbuffers::VOffsetT = 16; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - Enum { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args EnumArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = EnumBuilder::new(_fbb); - if let Some(x) = args.declaration_file { - builder.add_declaration_file(x); - } - if let Some(x) = args.documentation { - builder.add_documentation(x); - } - if let Some(x) = args.attributes { - builder.add_attributes(x); - } - if let Some(x) = args.underlying_type { - builder.add_underlying_type(x); - } - if let Some(x) = args.values { - builder.add_values(x); - } - if let Some(x) = args.name { - builder.add_name(x); - } - builder.add_is_union(args.is_union); - builder.finish() - } - - #[inline] - pub fn name(&self) -> &'a str { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(Enum::VT_NAME, None) - .unwrap() - } - } - #[inline] - pub fn key_compare_less_than(&self, o: &Enum) -> bool { - self.name() < o.name() - } - - #[inline] - pub fn key_compare_with_value(&self, val: &str) -> ::core::cmp::Ordering { - let key = self.name(); - key.cmp(val) - } - #[inline] - pub fn values(&self) -> flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>, - >>(Enum::VT_VALUES, None) - .unwrap() - } - } - #[inline] - pub fn is_union(&self) -> bool { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Enum::VT_IS_UNION, Some(false)) - .unwrap() - } - } - #[inline] - pub fn underlying_type(&self) -> Type<'a> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(Enum::VT_UNDERLYING_TYPE, None) - .unwrap() - } - } - #[inline] - pub fn attributes( - &self, - ) -> Option>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab.get::>, - >>(Enum::VT_ATTRIBUTES, None) - } - } - #[inline] - pub fn documentation( - &self, - ) -> Option>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab.get::>, - >>(Enum::VT_DOCUMENTATION, None) - } - } - /// File that this Enum is declared in. - #[inline] - pub fn declaration_file(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(Enum::VT_DECLARATION_FILE, None) - } - } - } - - impl flatbuffers::Verifiable for Enum<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>("name", Self::VT_NAME, true)? - .visit_field::>, - >>("values", Self::VT_VALUES, true)? - .visit_field::("is_union", Self::VT_IS_UNION, false)? - .visit_field::>( - "underlying_type", - Self::VT_UNDERLYING_TYPE, - true, - )? - .visit_field::>, - >>("attributes", Self::VT_ATTRIBUTES, false)? - .visit_field::>, - >>("documentation", Self::VT_DOCUMENTATION, false)? - .visit_field::>( - "declaration_file", - Self::VT_DECLARATION_FILE, - false, - )? - .finish(); - Ok(()) - } - } - pub struct EnumArgs<'a> { - pub name: Option>, - pub values: Option< - flatbuffers::WIPOffset< - flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>>, - >, - >, - pub is_union: bool, - pub underlying_type: Option>>, - pub attributes: Option< - flatbuffers::WIPOffset< - flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>>, - >, - >, - pub documentation: Option< - flatbuffers::WIPOffset>>, - >, - pub declaration_file: Option>, - } - impl<'a> Default for EnumArgs<'a> { - #[inline] - fn default() -> Self { - EnumArgs { - name: None, // required field - values: None, // required field - is_union: false, - underlying_type: None, // required field - attributes: None, - documentation: None, - declaration_file: None, - } - } - } - - pub struct EnumBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, - } - impl<'a: 'b, 'b> EnumBuilder<'a, 'b> { - #[inline] - pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { - self.fbb_ - .push_slot_always::>(Enum::VT_NAME, name); - } - #[inline] - pub fn add_values( - &mut self, - values: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, - >, - ) { - self.fbb_ - .push_slot_always::>(Enum::VT_VALUES, values); - } - #[inline] - pub fn add_is_union(&mut self, is_union: bool) { - self.fbb_ - .push_slot::(Enum::VT_IS_UNION, is_union, false); - } - #[inline] - pub fn add_underlying_type(&mut self, underlying_type: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>( - Enum::VT_UNDERLYING_TYPE, - underlying_type, - ); - } - #[inline] - pub fn add_attributes( - &mut self, - attributes: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, - >, - ) { - self.fbb_ - .push_slot_always::>(Enum::VT_ATTRIBUTES, attributes); - } - #[inline] - pub fn add_documentation( - &mut self, - documentation: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset<&'b str>>, - >, - ) { - self.fbb_.push_slot_always::>( - Enum::VT_DOCUMENTATION, - documentation, - ); - } - #[inline] - pub fn add_declaration_file(&mut self, declaration_file: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>( - Enum::VT_DECLARATION_FILE, - declaration_file, - ); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> EnumBuilder<'a, 'b> { - let start = _fbb.start_table(); - EnumBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - self.fbb_.required(o, Enum::VT_NAME, "name"); - self.fbb_.required(o, Enum::VT_VALUES, "values"); - self.fbb_ - .required(o, Enum::VT_UNDERLYING_TYPE, "underlying_type"); - flatbuffers::WIPOffset::new(o.value()) - } - } - - impl core::fmt::Debug for Enum<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("Enum"); - ds.field("name", &self.name()); - ds.field("values", &self.values()); - ds.field("is_union", &self.is_union()); - ds.field("underlying_type", &self.underlying_type()); - ds.field("attributes", &self.attributes()); - ds.field("documentation", &self.documentation()); - ds.field("declaration_file", &self.declaration_file()); - ds.finish() - } - } - pub enum FieldOffset {} - #[derive(Copy, Clone, PartialEq)] - - pub struct Field<'a> { - pub _tab: flatbuffers::Table<'a>, - } - - impl<'a> flatbuffers::Follow<'a> for Field<'a> { - type Inner = Field<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), - } - } - } - - impl<'a> Field<'a> { - pub const VT_NAME: flatbuffers::VOffsetT = 4; - pub const VT_TYPE_: flatbuffers::VOffsetT = 6; - pub const VT_ID: flatbuffers::VOffsetT = 8; - pub const VT_OFFSET: flatbuffers::VOffsetT = 10; - pub const VT_DEFAULT_INTEGER: flatbuffers::VOffsetT = 12; - pub const VT_DEFAULT_REAL: flatbuffers::VOffsetT = 14; - pub const VT_DEPRECATED: flatbuffers::VOffsetT = 16; - pub const VT_REQUIRED: flatbuffers::VOffsetT = 18; - pub const VT_KEY: flatbuffers::VOffsetT = 20; - pub const VT_ATTRIBUTES: flatbuffers::VOffsetT = 22; - pub const VT_DOCUMENTATION: flatbuffers::VOffsetT = 24; - pub const VT_OPTIONAL: flatbuffers::VOffsetT = 26; - pub const VT_PADDING: flatbuffers::VOffsetT = 28; - pub const VT_OFFSET64: flatbuffers::VOffsetT = 30; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - Field { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args FieldArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = FieldBuilder::new(_fbb); - builder.add_default_real(args.default_real); - builder.add_default_integer(args.default_integer); - if let Some(x) = args.documentation { - builder.add_documentation(x); - } - if let Some(x) = args.attributes { - builder.add_attributes(x); - } - if let Some(x) = args.type_ { - builder.add_type_(x); - } - if let Some(x) = args.name { - builder.add_name(x); - } - builder.add_padding(args.padding); - builder.add_offset(args.offset); - builder.add_id(args.id); - builder.add_offset64(args.offset64); - builder.add_optional(args.optional); - builder.add_key(args.key); - builder.add_required(args.required); - builder.add_deprecated(args.deprecated); - builder.finish() - } - - #[inline] - pub fn name(&self) -> &'a str { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(Field::VT_NAME, None) - .unwrap() - } - } - #[inline] - pub fn key_compare_less_than(&self, o: &Field) -> bool { - self.name() < o.name() - } - - #[inline] - pub fn key_compare_with_value(&self, val: &str) -> ::core::cmp::Ordering { - let key = self.name(); - key.cmp(val) - } - #[inline] - pub fn type_(&self) -> Type<'a> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(Field::VT_TYPE_, None) - .unwrap() - } - } - #[inline] - pub fn id(&self) -> u16 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Field::VT_ID, Some(0)).unwrap() } - } - #[inline] - pub fn offset(&self) -> u16 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Field::VT_OFFSET, Some(0)).unwrap() } - } - #[inline] - pub fn default_integer(&self) -> i64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Field::VT_DEFAULT_INTEGER, Some(0)) - .unwrap() - } - } - #[inline] - pub fn default_real(&self) -> f64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Field::VT_DEFAULT_REAL, Some(0.0)) - .unwrap() - } - } - #[inline] - pub fn deprecated(&self) -> bool { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Field::VT_DEPRECATED, Some(false)) - .unwrap() - } - } - #[inline] - pub fn required(&self) -> bool { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Field::VT_REQUIRED, Some(false)) - .unwrap() - } - } - #[inline] - pub fn key(&self) -> bool { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Field::VT_KEY, Some(false)).unwrap() } - } - #[inline] - pub fn attributes( - &self, - ) -> Option>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab.get::>, - >>(Field::VT_ATTRIBUTES, None) - } - } - #[inline] - pub fn documentation( - &self, - ) -> Option>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab.get::>, - >>(Field::VT_DOCUMENTATION, None) - } - } - #[inline] - pub fn optional(&self) -> bool { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Field::VT_OPTIONAL, Some(false)) - .unwrap() - } - } - /// Number of padding octets to always add after this field. Structs only. - #[inline] - pub fn padding(&self) -> u16 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Field::VT_PADDING, Some(0)).unwrap() } - } - /// If the field uses 64-bit offsets. - #[inline] - pub fn offset64(&self) -> bool { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Field::VT_OFFSET64, Some(false)) - .unwrap() - } - } - } - - impl flatbuffers::Verifiable for Field<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>("name", Self::VT_NAME, true)? - .visit_field::>("type_", Self::VT_TYPE_, true)? - .visit_field::("id", Self::VT_ID, false)? - .visit_field::("offset", Self::VT_OFFSET, false)? - .visit_field::("default_integer", Self::VT_DEFAULT_INTEGER, false)? - .visit_field::("default_real", Self::VT_DEFAULT_REAL, false)? - .visit_field::("deprecated", Self::VT_DEPRECATED, false)? - .visit_field::("required", Self::VT_REQUIRED, false)? - .visit_field::("key", Self::VT_KEY, false)? - .visit_field::>, - >>("attributes", Self::VT_ATTRIBUTES, false)? - .visit_field::>, - >>("documentation", Self::VT_DOCUMENTATION, false)? - .visit_field::("optional", Self::VT_OPTIONAL, false)? - .visit_field::("padding", Self::VT_PADDING, false)? - .visit_field::("offset64", Self::VT_OFFSET64, false)? - .finish(); - Ok(()) - } - } - pub struct FieldArgs<'a> { - pub name: Option>, - pub type_: Option>>, - pub id: u16, - pub offset: u16, - pub default_integer: i64, - pub default_real: f64, - pub deprecated: bool, - pub required: bool, - pub key: bool, - pub attributes: Option< - flatbuffers::WIPOffset< - flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>>, - >, - >, - pub documentation: Option< - flatbuffers::WIPOffset>>, - >, - pub optional: bool, - pub padding: u16, - pub offset64: bool, - } - impl<'a> Default for FieldArgs<'a> { - #[inline] - fn default() -> Self { - FieldArgs { - name: None, // required field - type_: None, // required field - id: 0, - offset: 0, - default_integer: 0, - default_real: 0.0, - deprecated: false, - required: false, - key: false, - attributes: None, - documentation: None, - optional: false, - padding: 0, - offset64: false, - } - } - } - - pub struct FieldBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, - } - impl<'a: 'b, 'b> FieldBuilder<'a, 'b> { - #[inline] - pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { - self.fbb_ - .push_slot_always::>(Field::VT_NAME, name); - } - #[inline] - pub fn add_type_(&mut self, type_: flatbuffers::WIPOffset>) { - self.fbb_ - .push_slot_always::>(Field::VT_TYPE_, type_); - } - #[inline] - pub fn add_id(&mut self, id: u16) { - self.fbb_.push_slot::(Field::VT_ID, id, 0); - } - #[inline] - pub fn add_offset(&mut self, offset: u16) { - self.fbb_.push_slot::(Field::VT_OFFSET, offset, 0); - } - #[inline] - pub fn add_default_integer(&mut self, default_integer: i64) { - self.fbb_ - .push_slot::(Field::VT_DEFAULT_INTEGER, default_integer, 0); - } - #[inline] - pub fn add_default_real(&mut self, default_real: f64) { - self.fbb_ - .push_slot::(Field::VT_DEFAULT_REAL, default_real, 0.0); - } - #[inline] - pub fn add_deprecated(&mut self, deprecated: bool) { - self.fbb_ - .push_slot::(Field::VT_DEPRECATED, deprecated, false); - } - #[inline] - pub fn add_required(&mut self, required: bool) { - self.fbb_ - .push_slot::(Field::VT_REQUIRED, required, false); - } - #[inline] - pub fn add_key(&mut self, key: bool) { - self.fbb_.push_slot::(Field::VT_KEY, key, false); - } - #[inline] - pub fn add_attributes( - &mut self, - attributes: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, - >, - ) { - self.fbb_ - .push_slot_always::>(Field::VT_ATTRIBUTES, attributes); - } - #[inline] - pub fn add_documentation( - &mut self, - documentation: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset<&'b str>>, - >, - ) { - self.fbb_.push_slot_always::>( - Field::VT_DOCUMENTATION, - documentation, - ); - } - #[inline] - pub fn add_optional(&mut self, optional: bool) { - self.fbb_ - .push_slot::(Field::VT_OPTIONAL, optional, false); - } - #[inline] - pub fn add_padding(&mut self, padding: u16) { - self.fbb_.push_slot::(Field::VT_PADDING, padding, 0); - } - #[inline] - pub fn add_offset64(&mut self, offset64: bool) { - self.fbb_ - .push_slot::(Field::VT_OFFSET64, offset64, false); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> FieldBuilder<'a, 'b> { - let start = _fbb.start_table(); - FieldBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - self.fbb_.required(o, Field::VT_NAME, "name"); - self.fbb_.required(o, Field::VT_TYPE_, "type_"); - flatbuffers::WIPOffset::new(o.value()) - } - } - - impl core::fmt::Debug for Field<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("Field"); - ds.field("name", &self.name()); - ds.field("type_", &self.type_()); - ds.field("id", &self.id()); - ds.field("offset", &self.offset()); - ds.field("default_integer", &self.default_integer()); - ds.field("default_real", &self.default_real()); - ds.field("deprecated", &self.deprecated()); - ds.field("required", &self.required()); - ds.field("key", &self.key()); - ds.field("attributes", &self.attributes()); - ds.field("documentation", &self.documentation()); - ds.field("optional", &self.optional()); - ds.field("padding", &self.padding()); - ds.field("offset64", &self.offset64()); - ds.finish() - } - } - pub enum ObjectOffset {} - #[derive(Copy, Clone, PartialEq)] - - pub struct Object<'a> { - pub _tab: flatbuffers::Table<'a>, - } - - impl<'a> flatbuffers::Follow<'a> for Object<'a> { - type Inner = Object<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), - } - } - } - - impl<'a> Object<'a> { - pub const VT_NAME: flatbuffers::VOffsetT = 4; - pub const VT_FIELDS: flatbuffers::VOffsetT = 6; - pub const VT_IS_STRUCT: flatbuffers::VOffsetT = 8; - pub const VT_MINALIGN: flatbuffers::VOffsetT = 10; - pub const VT_BYTESIZE: flatbuffers::VOffsetT = 12; - pub const VT_ATTRIBUTES: flatbuffers::VOffsetT = 14; - pub const VT_DOCUMENTATION: flatbuffers::VOffsetT = 16; - pub const VT_DECLARATION_FILE: flatbuffers::VOffsetT = 18; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - Object { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args ObjectArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = ObjectBuilder::new(_fbb); - if let Some(x) = args.declaration_file { - builder.add_declaration_file(x); - } - if let Some(x) = args.documentation { - builder.add_documentation(x); - } - if let Some(x) = args.attributes { - builder.add_attributes(x); - } - builder.add_bytesize(args.bytesize); - builder.add_minalign(args.minalign); - if let Some(x) = args.fields { - builder.add_fields(x); - } - if let Some(x) = args.name { - builder.add_name(x); - } - builder.add_is_struct(args.is_struct); - builder.finish() - } - - #[inline] - pub fn name(&self) -> &'a str { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(Object::VT_NAME, None) - .unwrap() - } - } - #[inline] - pub fn key_compare_less_than(&self, o: &Object) -> bool { - self.name() < o.name() - } - - #[inline] - pub fn key_compare_with_value(&self, val: &str) -> ::core::cmp::Ordering { - let key = self.name(); - key.cmp(val) - } - #[inline] - pub fn fields(&self) -> flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>, - >>(Object::VT_FIELDS, None) - .unwrap() - } - } - #[inline] - pub fn is_struct(&self) -> bool { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Object::VT_IS_STRUCT, Some(false)) - .unwrap() - } - } - #[inline] - pub fn minalign(&self) -> i32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Object::VT_MINALIGN, Some(0)).unwrap() } - } - #[inline] - pub fn bytesize(&self) -> i32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Object::VT_BYTESIZE, Some(0)).unwrap() } - } - #[inline] - pub fn attributes( - &self, - ) -> Option>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab.get::>, - >>(Object::VT_ATTRIBUTES, None) - } - } - #[inline] - pub fn documentation( - &self, - ) -> Option>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab.get::>, - >>(Object::VT_DOCUMENTATION, None) - } - } - /// File that this Object is declared in. - #[inline] - pub fn declaration_file(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(Object::VT_DECLARATION_FILE, None) - } - } - } - - impl flatbuffers::Verifiable for Object<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>("name", Self::VT_NAME, true)? - .visit_field::>, - >>("fields", Self::VT_FIELDS, true)? - .visit_field::("is_struct", Self::VT_IS_STRUCT, false)? - .visit_field::("minalign", Self::VT_MINALIGN, false)? - .visit_field::("bytesize", Self::VT_BYTESIZE, false)? - .visit_field::>, - >>("attributes", Self::VT_ATTRIBUTES, false)? - .visit_field::>, - >>("documentation", Self::VT_DOCUMENTATION, false)? - .visit_field::>( - "declaration_file", - Self::VT_DECLARATION_FILE, - false, - )? - .finish(); - Ok(()) - } - } - pub struct ObjectArgs<'a> { - pub name: Option>, - pub fields: Option< - flatbuffers::WIPOffset< - flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>>, - >, - >, - pub is_struct: bool, - pub minalign: i32, - pub bytesize: i32, - pub attributes: Option< - flatbuffers::WIPOffset< - flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>>, - >, - >, - pub documentation: Option< - flatbuffers::WIPOffset>>, - >, - pub declaration_file: Option>, - } - impl<'a> Default for ObjectArgs<'a> { - #[inline] - fn default() -> Self { - ObjectArgs { - name: None, // required field - fields: None, // required field - is_struct: false, - minalign: 0, - bytesize: 0, - attributes: None, - documentation: None, - declaration_file: None, - } - } - } - - pub struct ObjectBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, - } - impl<'a: 'b, 'b> ObjectBuilder<'a, 'b> { - #[inline] - pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { - self.fbb_ - .push_slot_always::>(Object::VT_NAME, name); - } - #[inline] - pub fn add_fields( - &mut self, - fields: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, - >, - ) { - self.fbb_ - .push_slot_always::>(Object::VT_FIELDS, fields); - } - #[inline] - pub fn add_is_struct(&mut self, is_struct: bool) { - self.fbb_ - .push_slot::(Object::VT_IS_STRUCT, is_struct, false); - } - #[inline] - pub fn add_minalign(&mut self, minalign: i32) { - self.fbb_.push_slot::(Object::VT_MINALIGN, minalign, 0); - } - #[inline] - pub fn add_bytesize(&mut self, bytesize: i32) { - self.fbb_.push_slot::(Object::VT_BYTESIZE, bytesize, 0); - } - #[inline] - pub fn add_attributes( - &mut self, - attributes: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, - >, - ) { - self.fbb_ - .push_slot_always::>(Object::VT_ATTRIBUTES, attributes); - } - #[inline] - pub fn add_documentation( - &mut self, - documentation: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset<&'b str>>, - >, - ) { - self.fbb_.push_slot_always::>( - Object::VT_DOCUMENTATION, - documentation, - ); - } - #[inline] - pub fn add_declaration_file(&mut self, declaration_file: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>( - Object::VT_DECLARATION_FILE, - declaration_file, - ); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> ObjectBuilder<'a, 'b> { - let start = _fbb.start_table(); - ObjectBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - self.fbb_.required(o, Object::VT_NAME, "name"); - self.fbb_.required(o, Object::VT_FIELDS, "fields"); - flatbuffers::WIPOffset::new(o.value()) - } - } - - impl core::fmt::Debug for Object<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("Object"); - ds.field("name", &self.name()); - ds.field("fields", &self.fields()); - ds.field("is_struct", &self.is_struct()); - ds.field("minalign", &self.minalign()); - ds.field("bytesize", &self.bytesize()); - ds.field("attributes", &self.attributes()); - ds.field("documentation", &self.documentation()); - ds.field("declaration_file", &self.declaration_file()); - ds.finish() - } - } - pub enum RPCCallOffset {} - #[derive(Copy, Clone, PartialEq)] - - pub struct RPCCall<'a> { - pub _tab: flatbuffers::Table<'a>, - } - - impl<'a> flatbuffers::Follow<'a> for RPCCall<'a> { - type Inner = RPCCall<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), - } - } - } - - impl<'a> RPCCall<'a> { - pub const VT_NAME: flatbuffers::VOffsetT = 4; - pub const VT_REQUEST: flatbuffers::VOffsetT = 6; - pub const VT_RESPONSE: flatbuffers::VOffsetT = 8; - pub const VT_ATTRIBUTES: flatbuffers::VOffsetT = 10; - pub const VT_DOCUMENTATION: flatbuffers::VOffsetT = 12; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - RPCCall { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args RPCCallArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = RPCCallBuilder::new(_fbb); - if let Some(x) = args.documentation { - builder.add_documentation(x); - } - if let Some(x) = args.attributes { - builder.add_attributes(x); - } - if let Some(x) = args.response { - builder.add_response(x); - } - if let Some(x) = args.request { - builder.add_request(x); - } - if let Some(x) = args.name { - builder.add_name(x); - } - builder.finish() - } - - #[inline] - pub fn name(&self) -> &'a str { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(RPCCall::VT_NAME, None) - .unwrap() - } - } - #[inline] - pub fn key_compare_less_than(&self, o: &RPCCall) -> bool { - self.name() < o.name() - } - - #[inline] - pub fn key_compare_with_value(&self, val: &str) -> ::core::cmp::Ordering { - let key = self.name(); - key.cmp(val) - } - #[inline] - pub fn request(&self) -> Object<'a> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(RPCCall::VT_REQUEST, None) - .unwrap() - } - } - #[inline] - pub fn response(&self) -> Object<'a> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(RPCCall::VT_RESPONSE, None) - .unwrap() - } - } - #[inline] - pub fn attributes( - &self, - ) -> Option>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab.get::>, - >>(RPCCall::VT_ATTRIBUTES, None) - } - } - #[inline] - pub fn documentation( - &self, - ) -> Option>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab.get::>, - >>(RPCCall::VT_DOCUMENTATION, None) - } - } - } - - impl flatbuffers::Verifiable for RPCCall<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>("name", Self::VT_NAME, true)? - .visit_field::>( - "request", - Self::VT_REQUEST, - true, - )? - .visit_field::>( - "response", - Self::VT_RESPONSE, - true, - )? - .visit_field::>, - >>("attributes", Self::VT_ATTRIBUTES, false)? - .visit_field::>, - >>("documentation", Self::VT_DOCUMENTATION, false)? - .finish(); - Ok(()) - } - } - pub struct RPCCallArgs<'a> { - pub name: Option>, - pub request: Option>>, - pub response: Option>>, - pub attributes: Option< - flatbuffers::WIPOffset< - flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>>, - >, - >, - pub documentation: Option< - flatbuffers::WIPOffset>>, - >, - } - impl<'a> Default for RPCCallArgs<'a> { - #[inline] - fn default() -> Self { - RPCCallArgs { - name: None, // required field - request: None, // required field - response: None, // required field - attributes: None, - documentation: None, - } - } - } - - pub struct RPCCallBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, - } - impl<'a: 'b, 'b> RPCCallBuilder<'a, 'b> { - #[inline] - pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { - self.fbb_ - .push_slot_always::>(RPCCall::VT_NAME, name); - } - #[inline] - pub fn add_request(&mut self, request: flatbuffers::WIPOffset>) { - self.fbb_ - .push_slot_always::>(RPCCall::VT_REQUEST, request); - } - #[inline] - pub fn add_response(&mut self, response: flatbuffers::WIPOffset>) { - self.fbb_ - .push_slot_always::>(RPCCall::VT_RESPONSE, response); - } - #[inline] - pub fn add_attributes( - &mut self, - attributes: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, - >, - ) { - self.fbb_ - .push_slot_always::>(RPCCall::VT_ATTRIBUTES, attributes); - } - #[inline] - pub fn add_documentation( - &mut self, - documentation: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset<&'b str>>, - >, - ) { - self.fbb_.push_slot_always::>( - RPCCall::VT_DOCUMENTATION, - documentation, - ); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> RPCCallBuilder<'a, 'b> { - let start = _fbb.start_table(); - RPCCallBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - self.fbb_.required(o, RPCCall::VT_NAME, "name"); - self.fbb_.required(o, RPCCall::VT_REQUEST, "request"); - self.fbb_.required(o, RPCCall::VT_RESPONSE, "response"); - flatbuffers::WIPOffset::new(o.value()) - } - } - - impl core::fmt::Debug for RPCCall<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("RPCCall"); - ds.field("name", &self.name()); - ds.field("request", &self.request()); - ds.field("response", &self.response()); - ds.field("attributes", &self.attributes()); - ds.field("documentation", &self.documentation()); - ds.finish() - } - } - pub enum ServiceOffset {} - #[derive(Copy, Clone, PartialEq)] - - pub struct Service<'a> { - pub _tab: flatbuffers::Table<'a>, - } - - impl<'a> flatbuffers::Follow<'a> for Service<'a> { - type Inner = Service<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), - } - } - } - - impl<'a> Service<'a> { - pub const VT_NAME: flatbuffers::VOffsetT = 4; - pub const VT_CALLS: flatbuffers::VOffsetT = 6; - pub const VT_ATTRIBUTES: flatbuffers::VOffsetT = 8; - pub const VT_DOCUMENTATION: flatbuffers::VOffsetT = 10; - pub const VT_DECLARATION_FILE: flatbuffers::VOffsetT = 12; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - Service { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args ServiceArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = ServiceBuilder::new(_fbb); - if let Some(x) = args.declaration_file { - builder.add_declaration_file(x); - } - if let Some(x) = args.documentation { - builder.add_documentation(x); - } - if let Some(x) = args.attributes { - builder.add_attributes(x); - } - if let Some(x) = args.calls { - builder.add_calls(x); - } - if let Some(x) = args.name { - builder.add_name(x); - } - builder.finish() - } - - #[inline] - pub fn name(&self) -> &'a str { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(Service::VT_NAME, None) - .unwrap() - } - } - #[inline] - pub fn key_compare_less_than(&self, o: &Service) -> bool { - self.name() < o.name() - } - - #[inline] - pub fn key_compare_with_value(&self, val: &str) -> ::core::cmp::Ordering { - let key = self.name(); - key.cmp(val) - } - #[inline] - pub fn calls( - &self, - ) -> Option>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab.get::>, - >>(Service::VT_CALLS, None) - } - } - #[inline] - pub fn attributes( - &self, - ) -> Option>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab.get::>, - >>(Service::VT_ATTRIBUTES, None) - } - } - #[inline] - pub fn documentation( - &self, - ) -> Option>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab.get::>, - >>(Service::VT_DOCUMENTATION, None) - } - } - /// File that this Service is declared in. - #[inline] - pub fn declaration_file(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(Service::VT_DECLARATION_FILE, None) - } - } - } - - impl flatbuffers::Verifiable for Service<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>("name", Self::VT_NAME, true)? - .visit_field::>, - >>("calls", Self::VT_CALLS, false)? - .visit_field::>, - >>("attributes", Self::VT_ATTRIBUTES, false)? - .visit_field::>, - >>("documentation", Self::VT_DOCUMENTATION, false)? - .visit_field::>( - "declaration_file", - Self::VT_DECLARATION_FILE, - false, - )? - .finish(); - Ok(()) - } - } - pub struct ServiceArgs<'a> { - pub name: Option>, - pub calls: Option< - flatbuffers::WIPOffset< - flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>>, - >, - >, - pub attributes: Option< - flatbuffers::WIPOffset< - flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>>, - >, - >, - pub documentation: Option< - flatbuffers::WIPOffset>>, - >, - pub declaration_file: Option>, - } - impl<'a> Default for ServiceArgs<'a> { - #[inline] - fn default() -> Self { - ServiceArgs { - name: None, // required field - calls: None, - attributes: None, - documentation: None, - declaration_file: None, - } - } - } - - pub struct ServiceBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, - } - impl<'a: 'b, 'b> ServiceBuilder<'a, 'b> { - #[inline] - pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { - self.fbb_ - .push_slot_always::>(Service::VT_NAME, name); - } - #[inline] - pub fn add_calls( - &mut self, - calls: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, - >, - ) { - self.fbb_ - .push_slot_always::>(Service::VT_CALLS, calls); - } - #[inline] - pub fn add_attributes( - &mut self, - attributes: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, - >, - ) { - self.fbb_ - .push_slot_always::>(Service::VT_ATTRIBUTES, attributes); - } - #[inline] - pub fn add_documentation( - &mut self, - documentation: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset<&'b str>>, - >, - ) { - self.fbb_.push_slot_always::>( - Service::VT_DOCUMENTATION, - documentation, - ); - } - #[inline] - pub fn add_declaration_file(&mut self, declaration_file: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>( - Service::VT_DECLARATION_FILE, - declaration_file, - ); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> ServiceBuilder<'a, 'b> { - let start = _fbb.start_table(); - ServiceBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - self.fbb_.required(o, Service::VT_NAME, "name"); - flatbuffers::WIPOffset::new(o.value()) - } - } - - impl core::fmt::Debug for Service<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("Service"); - ds.field("name", &self.name()); - ds.field("calls", &self.calls()); - ds.field("attributes", &self.attributes()); - ds.field("documentation", &self.documentation()); - ds.field("declaration_file", &self.declaration_file()); - ds.finish() - } - } - pub enum SchemaFileOffset {} - #[derive(Copy, Clone, PartialEq)] - - /// File specific information. - /// Symbols declared within a file may be recovered by iterating over all - /// symbols and examining the `declaration_file` field. - pub struct SchemaFile<'a> { - pub _tab: flatbuffers::Table<'a>, - } - - impl<'a> flatbuffers::Follow<'a> for SchemaFile<'a> { - type Inner = SchemaFile<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), - } - } - } - - impl<'a> SchemaFile<'a> { - pub const VT_FILENAME: flatbuffers::VOffsetT = 4; - pub const VT_INCLUDED_FILENAMES: flatbuffers::VOffsetT = 6; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - SchemaFile { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args SchemaFileArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = SchemaFileBuilder::new(_fbb); - if let Some(x) = args.included_filenames { - builder.add_included_filenames(x); - } - if let Some(x) = args.filename { - builder.add_filename(x); - } - builder.finish() - } - - /// Filename, relative to project root. - #[inline] - pub fn filename(&self) -> &'a str { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(SchemaFile::VT_FILENAME, None) - .unwrap() - } - } - #[inline] - pub fn key_compare_less_than(&self, o: &SchemaFile) -> bool { - self.filename() < o.filename() - } - - #[inline] - pub fn key_compare_with_value(&self, val: &str) -> ::core::cmp::Ordering { - let key = self.filename(); - key.cmp(val) - } - /// Names of included files, relative to project root. - #[inline] - pub fn included_filenames( - &self, - ) -> Option>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab.get::>, - >>(SchemaFile::VT_INCLUDED_FILENAMES, None) - } - } - } - - impl flatbuffers::Verifiable for SchemaFile<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>( - "filename", - Self::VT_FILENAME, - true, - )? - .visit_field::>, - >>("included_filenames", Self::VT_INCLUDED_FILENAMES, false)? - .finish(); - Ok(()) - } - } - pub struct SchemaFileArgs<'a> { - pub filename: Option>, - pub included_filenames: Option< - flatbuffers::WIPOffset>>, - >, - } - impl<'a> Default for SchemaFileArgs<'a> { - #[inline] - fn default() -> Self { - SchemaFileArgs { - filename: None, // required field - included_filenames: None, - } - } - } - - pub struct SchemaFileBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, - } - impl<'a: 'b, 'b> SchemaFileBuilder<'a, 'b> { - #[inline] - pub fn add_filename(&mut self, filename: flatbuffers::WIPOffset<&'b str>) { - self.fbb_ - .push_slot_always::>(SchemaFile::VT_FILENAME, filename); - } - #[inline] - pub fn add_included_filenames( - &mut self, - included_filenames: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset<&'b str>>, - >, - ) { - self.fbb_.push_slot_always::>( - SchemaFile::VT_INCLUDED_FILENAMES, - included_filenames, - ); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> SchemaFileBuilder<'a, 'b> { - let start = _fbb.start_table(); - SchemaFileBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - self.fbb_.required(o, SchemaFile::VT_FILENAME, "filename"); - flatbuffers::WIPOffset::new(o.value()) - } - } - - impl core::fmt::Debug for SchemaFile<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("SchemaFile"); - ds.field("filename", &self.filename()); - ds.field("included_filenames", &self.included_filenames()); - ds.finish() - } - } - pub enum SchemaOffset {} - #[derive(Copy, Clone, PartialEq)] - - pub struct Schema<'a> { - pub _tab: flatbuffers::Table<'a>, - } - - impl<'a> flatbuffers::Follow<'a> for Schema<'a> { - type Inner = Schema<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { - _tab: flatbuffers::Table::new(buf, loc), - } - } - } - - impl<'a> Schema<'a> { - pub const VT_OBJECTS: flatbuffers::VOffsetT = 4; - pub const VT_ENUMS: flatbuffers::VOffsetT = 6; - pub const VT_FILE_IDENT: flatbuffers::VOffsetT = 8; - pub const VT_FILE_EXT: flatbuffers::VOffsetT = 10; - pub const VT_ROOT_TABLE: flatbuffers::VOffsetT = 12; - pub const VT_SERVICES: flatbuffers::VOffsetT = 14; - pub const VT_ADVANCED_FEATURES: flatbuffers::VOffsetT = 16; - pub const VT_FBS_FILES: flatbuffers::VOffsetT = 18; - - #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - Schema { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( - _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args SchemaArgs<'args>, - ) -> flatbuffers::WIPOffset> { - let mut builder = SchemaBuilder::new(_fbb); - builder.add_advanced_features(args.advanced_features); - if let Some(x) = args.fbs_files { - builder.add_fbs_files(x); - } - if let Some(x) = args.services { - builder.add_services(x); - } - if let Some(x) = args.root_table { - builder.add_root_table(x); - } - if let Some(x) = args.file_ext { - builder.add_file_ext(x); - } - if let Some(x) = args.file_ident { - builder.add_file_ident(x); - } - if let Some(x) = args.enums { - builder.add_enums(x); - } - if let Some(x) = args.objects { - builder.add_objects(x); - } - builder.finish() - } - - #[inline] - pub fn objects(&self) -> flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>, - >>(Schema::VT_OBJECTS, None) - .unwrap() - } - } - #[inline] - pub fn enums(&self) -> flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>, - >>(Schema::VT_ENUMS, None) - .unwrap() - } - } - #[inline] - pub fn file_ident(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(Schema::VT_FILE_IDENT, None) - } - } - #[inline] - pub fn file_ext(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(Schema::VT_FILE_EXT, None) - } - } - #[inline] - pub fn root_table(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>(Schema::VT_ROOT_TABLE, None) - } - } - #[inline] - pub fn services( - &self, - ) -> Option>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab.get::>, - >>(Schema::VT_SERVICES, None) - } - } - #[inline] - pub fn advanced_features(&self) -> AdvancedFeatures { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::(Schema::VT_ADVANCED_FEATURES, Some(Default::default())) - .unwrap() - } - } - /// All the files used in this compilation. Files are relative to where - /// flatc was invoked. - #[inline] - pub fn fbs_files( - &self, - ) -> Option>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab.get::>, - >>(Schema::VT_FBS_FILES, None) - } - } - } - - impl flatbuffers::Verifiable for Schema<'_> { - #[inline] - fn run_verifier( - v: &mut flatbuffers::Verifier, - pos: usize, - ) -> Result<(), flatbuffers::InvalidFlatbuffer> { - use self::flatbuffers::Verifiable; - v.visit_table(pos)? - .visit_field::>, - >>("objects", Self::VT_OBJECTS, true)? - .visit_field::>, - >>("enums", Self::VT_ENUMS, true)? - .visit_field::>( - "file_ident", - Self::VT_FILE_IDENT, - false, - )? - .visit_field::>( - "file_ext", - Self::VT_FILE_EXT, - false, - )? - .visit_field::>( - "root_table", - Self::VT_ROOT_TABLE, - false, - )? - .visit_field::>, - >>("services", Self::VT_SERVICES, false)? - .visit_field::( - "advanced_features", - Self::VT_ADVANCED_FEATURES, - false, - )? - .visit_field::>, - >>("fbs_files", Self::VT_FBS_FILES, false)? - .finish(); - Ok(()) - } - } - pub struct SchemaArgs<'a> { - pub objects: Option< - flatbuffers::WIPOffset< - flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>>, - >, - >, - pub enums: Option< - flatbuffers::WIPOffset>>>, - >, - pub file_ident: Option>, - pub file_ext: Option>, - pub root_table: Option>>, - pub services: Option< - flatbuffers::WIPOffset< - flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>>, - >, - >, - pub advanced_features: AdvancedFeatures, - pub fbs_files: Option< - flatbuffers::WIPOffset< - flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>>, - >, - >, - } - impl<'a> Default for SchemaArgs<'a> { - #[inline] - fn default() -> Self { - SchemaArgs { - objects: None, // required field - enums: None, // required field - file_ident: None, - file_ext: None, - root_table: None, - services: None, - advanced_features: Default::default(), - fbs_files: None, - } - } - } - - pub struct SchemaBuilder<'a: 'b, 'b> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, - start_: flatbuffers::WIPOffset, - } - impl<'a: 'b, 'b> SchemaBuilder<'a, 'b> { - #[inline] - pub fn add_objects( - &mut self, - objects: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, - >, - ) { - self.fbb_ - .push_slot_always::>(Schema::VT_OBJECTS, objects); - } - #[inline] - pub fn add_enums( - &mut self, - enums: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, - >, - ) { - self.fbb_ - .push_slot_always::>(Schema::VT_ENUMS, enums); - } - #[inline] - pub fn add_file_ident(&mut self, file_ident: flatbuffers::WIPOffset<&'b str>) { - self.fbb_ - .push_slot_always::>(Schema::VT_FILE_IDENT, file_ident); - } - #[inline] - pub fn add_file_ext(&mut self, file_ext: flatbuffers::WIPOffset<&'b str>) { - self.fbb_ - .push_slot_always::>(Schema::VT_FILE_EXT, file_ext); - } - #[inline] - pub fn add_root_table(&mut self, root_table: flatbuffers::WIPOffset>) { - self.fbb_ - .push_slot_always::>( - Schema::VT_ROOT_TABLE, - root_table, - ); - } - #[inline] - pub fn add_services( - &mut self, - services: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, - >, - ) { - self.fbb_ - .push_slot_always::>(Schema::VT_SERVICES, services); - } - #[inline] - pub fn add_advanced_features(&mut self, advanced_features: AdvancedFeatures) { - self.fbb_.push_slot::( - Schema::VT_ADVANCED_FEATURES, - advanced_features, - Default::default(), - ); - } - #[inline] - pub fn add_fbs_files( - &mut self, - fbs_files: flatbuffers::WIPOffset< - flatbuffers::Vector<'b, flatbuffers::ForwardsUOffset>>, - >, - ) { - self.fbb_ - .push_slot_always::>(Schema::VT_FBS_FILES, fbs_files); - } - #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> SchemaBuilder<'a, 'b> { - let start = _fbb.start_table(); - SchemaBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - self.fbb_.required(o, Schema::VT_OBJECTS, "objects"); - self.fbb_.required(o, Schema::VT_ENUMS, "enums"); - flatbuffers::WIPOffset::new(o.value()) - } - } - - impl core::fmt::Debug for Schema<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("Schema"); - ds.field("objects", &self.objects()); - ds.field("enums", &self.enums()); - ds.field("file_ident", &self.file_ident()); - ds.field("file_ext", &self.file_ext()); - ds.field("root_table", &self.root_table()); - ds.field("services", &self.services()); - ds.field("advanced_features", &self.advanced_features()); - ds.field("fbs_files", &self.fbs_files()); - ds.finish() - } - } - #[inline] - /// Verifies that a buffer of bytes contains a `Schema` - /// and returns it. - /// Note that verification is still experimental and may not - /// catch every error, or be maximally performant. For the - /// previous, unchecked, behavior use - /// `root_as_schema_unchecked`. - pub fn root_as_schema(buf: &[u8]) -> Result { - flatbuffers::root::(buf) - } - #[inline] - /// Verifies that a buffer of bytes contains a size prefixed - /// `Schema` and returns it. - /// Note that verification is still experimental and may not - /// catch every error, or be maximally performant. For the - /// previous, unchecked, behavior use - /// `size_prefixed_root_as_schema_unchecked`. - pub fn size_prefixed_root_as_schema( - buf: &[u8], - ) -> Result { - flatbuffers::size_prefixed_root::(buf) - } - #[inline] - /// Verifies, with the given options, that a buffer of bytes - /// contains a `Schema` and returns it. - /// Note that verification is still experimental and may not - /// catch every error, or be maximally performant. For the - /// previous, unchecked, behavior use - /// `root_as_schema_unchecked`. - pub fn root_as_schema_with_opts<'b, 'o>( - opts: &'o flatbuffers::VerifierOptions, - buf: &'b [u8], - ) -> Result, flatbuffers::InvalidFlatbuffer> { - flatbuffers::root_with_opts::>(opts, buf) - } - #[inline] - /// Verifies, with the given verifier options, that a buffer of - /// bytes contains a size prefixed `Schema` and returns - /// it. Note that verification is still experimental and may not - /// catch every error, or be maximally performant. For the - /// previous, unchecked, behavior use - /// `root_as_schema_unchecked`. - pub fn size_prefixed_root_as_schema_with_opts<'b, 'o>( - opts: &'o flatbuffers::VerifierOptions, - buf: &'b [u8], - ) -> Result, flatbuffers::InvalidFlatbuffer> { - flatbuffers::size_prefixed_root_with_opts::>(opts, buf) - } - #[inline] - /// Assumes, without verification, that a buffer of bytes contains a Schema and returns it. - /// # Safety - /// Callers must trust the given bytes do indeed contain a valid `Schema`. - pub unsafe fn root_as_schema_unchecked(buf: &[u8]) -> Schema { - flatbuffers::root_unchecked::(buf) - } + use core::mem; + use core::cmp::Ordering; + + extern crate flatbuffers; + use self::flatbuffers::{EndianScalar, Follow}; + +#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] +pub const ENUM_MIN_BASE_TYPE: i8 = 0; +#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] +pub const ENUM_MAX_BASE_TYPE: i8 = 19; +#[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_BASE_TYPE: [BaseType; 20] = [ + BaseType::None, + BaseType::UType, + BaseType::Bool, + BaseType::Byte, + BaseType::UByte, + BaseType::Short, + BaseType::UShort, + BaseType::Int, + BaseType::UInt, + BaseType::Long, + BaseType::ULong, + BaseType::Float, + BaseType::Double, + BaseType::String, + BaseType::Vector, + BaseType::Obj, + BaseType::Union, + BaseType::Array, + BaseType::Vector64, + BaseType::MaxBaseType, +]; + +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] +#[repr(transparent)] +pub struct BaseType(pub i8); +#[allow(non_upper_case_globals)] +impl BaseType { + pub const None: Self = Self(0); + pub const UType: Self = Self(1); + pub const Bool: Self = Self(2); + pub const Byte: Self = Self(3); + pub const UByte: Self = Self(4); + pub const Short: Self = Self(5); + pub const UShort: Self = Self(6); + pub const Int: Self = Self(7); + pub const UInt: Self = Self(8); + pub const Long: Self = Self(9); + pub const ULong: Self = Self(10); + pub const Float: Self = Self(11); + pub const Double: Self = Self(12); + pub const String: Self = Self(13); + pub const Vector: Self = Self(14); + pub const Obj: Self = Self(15); + pub const Union: Self = Self(16); + pub const Array: Self = Self(17); + pub const Vector64: Self = Self(18); + pub const MaxBaseType: Self = Self(19); + + pub const ENUM_MIN: i8 = 0; + pub const ENUM_MAX: i8 = 19; + pub const ENUM_VALUES: &'static [Self] = &[ + Self::None, + Self::UType, + Self::Bool, + Self::Byte, + Self::UByte, + Self::Short, + Self::UShort, + Self::Int, + Self::UInt, + Self::Long, + Self::ULong, + Self::Float, + Self::Double, + Self::String, + Self::Vector, + Self::Obj, + Self::Union, + Self::Array, + Self::Vector64, + Self::MaxBaseType, + ]; + /// Returns the variant's name or "" if unknown. + pub fn variant_name(self) -> Option<&'static str> { + match self { + Self::None => Some("None"), + Self::UType => Some("UType"), + Self::Bool => Some("Bool"), + Self::Byte => Some("Byte"), + Self::UByte => Some("UByte"), + Self::Short => Some("Short"), + Self::UShort => Some("UShort"), + Self::Int => Some("Int"), + Self::UInt => Some("UInt"), + Self::Long => Some("Long"), + Self::ULong => Some("ULong"), + Self::Float => Some("Float"), + Self::Double => Some("Double"), + Self::String => Some("String"), + Self::Vector => Some("Vector"), + Self::Obj => Some("Obj"), + Self::Union => Some("Union"), + Self::Array => Some("Array"), + Self::Vector64 => Some("Vector64"), + Self::MaxBaseType => Some("MaxBaseType"), + _ => None, + } + } +} +impl core::fmt::Debug for BaseType { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + if let Some(name) = self.variant_name() { + f.write_str(name) + } else { + f.write_fmt(format_args!("", self.0)) + } + } +} +impl<'a> flatbuffers::Follow<'a> for BaseType { + type Inner = Self; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + let b = flatbuffers::read_scalar_at::(buf, loc); + Self(b) + } +} + +impl flatbuffers::Push for BaseType { + type Output = BaseType; #[inline] - /// Assumes, without verification, that a buffer of bytes contains a size prefixed Schema and returns it. - /// # Safety - /// Callers must trust the given bytes do indeed contain a valid size prefixed `Schema`. - pub unsafe fn size_prefixed_root_as_schema_unchecked(buf: &[u8]) -> Schema { - flatbuffers::size_prefixed_root_unchecked::(buf) - } - pub const SCHEMA_IDENTIFIER: &str = "BFBS"; - - #[inline] - pub fn schema_buffer_has_identifier(buf: &[u8]) -> bool { - flatbuffers::buffer_has_identifier(buf, SCHEMA_IDENTIFIER, false) - } - - #[inline] - pub fn schema_size_prefixed_buffer_has_identifier(buf: &[u8]) -> bool { - flatbuffers::buffer_has_identifier(buf, SCHEMA_IDENTIFIER, true) - } - - pub const SCHEMA_EXTENSION: &str = "bfbs"; - + unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { + flatbuffers::emplace_scalar::(dst, self.0); + } +} + +impl flatbuffers::EndianScalar for BaseType { + type Scalar = i8; + #[inline] + fn to_little_endian(self) -> i8 { + self.0.to_le() + } + #[inline] + #[allow(clippy::wrong_self_convention)] + fn from_little_endian(v: i8) -> Self { + let b = i8::from_le(v); + Self(b) + } +} + +impl<'a> flatbuffers::Verifiable for BaseType { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + i8::run_verifier(v, pos) + } +} + +impl flatbuffers::SimpleToVerifyInSlice for BaseType {} +#[allow(non_upper_case_globals)] +mod bitflags_advanced_features { + flatbuffers::bitflags::bitflags! { + /// New schema language features that are not supported by old code generators. + #[derive(Default, Debug, Clone, Copy, PartialEq)] + pub struct AdvancedFeatures: u64 { + const AdvancedArrayFeatures = 1; + const AdvancedUnionFeatures = 2; + const OptionalScalars = 4; + const DefaultVectorsAndStrings = 8; + } + } +} +pub use self::bitflags_advanced_features::AdvancedFeatures; + +impl<'a> flatbuffers::Follow<'a> for AdvancedFeatures { + type Inner = Self; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + let b = flatbuffers::read_scalar_at::(buf, loc); + Self::from_bits_retain(b) + } +} + +impl flatbuffers::Push for AdvancedFeatures { + type Output = AdvancedFeatures; #[inline] - pub fn finish_schema_buffer<'a, 'b>( - fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, - root: flatbuffers::WIPOffset>, - ) { - fbb.finish(root, Some(SCHEMA_IDENTIFIER)); - } + unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { + flatbuffers::emplace_scalar::(dst, self.bits()); + } +} + +impl flatbuffers::EndianScalar for AdvancedFeatures { + type Scalar = u64; + #[inline] + fn to_little_endian(self) -> u64 { + self.bits().to_le() + } + #[inline] + #[allow(clippy::wrong_self_convention)] + fn from_little_endian(v: u64) -> Self { + let b = u64::from_le(v); + Self::from_bits_retain(b) + } +} + +impl<'a> flatbuffers::Verifiable for AdvancedFeatures { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + u64::run_verifier(v, pos) + } +} + +impl flatbuffers::SimpleToVerifyInSlice for AdvancedFeatures {} +pub enum TypeOffset {} +#[derive(Copy, Clone, PartialEq)] + +pub struct Type<'a> { + pub _tab: flatbuffers::Table<'a>, +} + +impl<'a> flatbuffers::Follow<'a> for Type<'a> { + type Inner = Type<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } +} + +impl<'a> Type<'a> { + pub const VT_BASE_TYPE: flatbuffers::VOffsetT = 4; + pub const VT_ELEMENT: flatbuffers::VOffsetT = 6; + pub const VT_INDEX: flatbuffers::VOffsetT = 8; + pub const VT_FIXED_LENGTH: flatbuffers::VOffsetT = 10; + pub const VT_BASE_SIZE: flatbuffers::VOffsetT = 12; + pub const VT_ELEMENT_SIZE: flatbuffers::VOffsetT = 14; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + Type { _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>, + args: &'args TypeArgs + ) -> flatbuffers::WIPOffset> { + let mut builder = TypeBuilder::new(_fbb); + builder.add_element_size(args.element_size); + builder.add_base_size(args.base_size); + builder.add_index(args.index); + builder.add_fixed_length(args.fixed_length); + builder.add_element(args.element); + builder.add_base_type(args.base_type); + builder.finish() + } + + + #[inline] + pub fn base_type(&self) -> BaseType { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Type::VT_BASE_TYPE, Some(BaseType::None)).unwrap()} + } + #[inline] + pub fn element(&self) -> BaseType { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Type::VT_ELEMENT, Some(BaseType::None)).unwrap()} + } + #[inline] + pub fn index(&self) -> i32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Type::VT_INDEX, Some(-1)).unwrap()} + } + #[inline] + pub fn fixed_length(&self) -> u16 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Type::VT_FIXED_LENGTH, Some(0)).unwrap()} + } + /// The size (octets) of the `base_type` field. + #[inline] + pub fn base_size(&self) -> u32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Type::VT_BASE_SIZE, Some(4)).unwrap()} + } + /// The size (octets) of the `element` field, if present. + #[inline] + pub fn element_size(&self) -> u32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Type::VT_ELEMENT_SIZE, Some(0)).unwrap()} + } +} + +impl flatbuffers::Verifiable for Type<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::("base_type", Self::VT_BASE_TYPE, false)? + .visit_field::("element", Self::VT_ELEMENT, false)? + .visit_field::("index", Self::VT_INDEX, false)? + .visit_field::("fixed_length", Self::VT_FIXED_LENGTH, false)? + .visit_field::("base_size", Self::VT_BASE_SIZE, false)? + .visit_field::("element_size", Self::VT_ELEMENT_SIZE, false)? + .finish(); + Ok(()) + } +} +pub struct TypeArgs { + pub base_type: BaseType, + pub element: BaseType, + pub index: i32, + pub fixed_length: u16, + pub base_size: u32, + pub element_size: u32, +} +impl<'a> Default for TypeArgs { + #[inline] + fn default() -> Self { + TypeArgs { + base_type: BaseType::None, + element: BaseType::None, + index: -1, + fixed_length: 0, + base_size: 4, + element_size: 0, + } + } +} + +pub struct TypeBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> TypeBuilder<'a, 'b, A> { + #[inline] + pub fn add_base_type(&mut self, base_type: BaseType) { + self.fbb_.push_slot::(Type::VT_BASE_TYPE, base_type, BaseType::None); + } + #[inline] + pub fn add_element(&mut self, element: BaseType) { + self.fbb_.push_slot::(Type::VT_ELEMENT, element, BaseType::None); + } + #[inline] + pub fn add_index(&mut self, index: i32) { + self.fbb_.push_slot::(Type::VT_INDEX, index, -1); + } + #[inline] + pub fn add_fixed_length(&mut self, fixed_length: u16) { + self.fbb_.push_slot::(Type::VT_FIXED_LENGTH, fixed_length, 0); + } + #[inline] + pub fn add_base_size(&mut self, base_size: u32) { + self.fbb_.push_slot::(Type::VT_BASE_SIZE, base_size, 4); + } + #[inline] + pub fn add_element_size(&mut self, element_size: u32) { + self.fbb_.push_slot::(Type::VT_ELEMENT_SIZE, element_size, 0); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> TypeBuilder<'a, 'b, A> { + let start = _fbb.start_table(); + TypeBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + flatbuffers::WIPOffset::new(o.value()) + } +} + +impl core::fmt::Debug for Type<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("Type"); + ds.field("base_type", &self.base_type()); + ds.field("element", &self.element()); + ds.field("index", &self.index()); + ds.field("fixed_length", &self.fixed_length()); + ds.field("base_size", &self.base_size()); + ds.field("element_size", &self.element_size()); + ds.finish() + } +} +pub enum KeyValueOffset {} +#[derive(Copy, Clone, PartialEq)] + +pub struct KeyValue<'a> { + pub _tab: flatbuffers::Table<'a>, +} + +impl<'a> flatbuffers::Follow<'a> for KeyValue<'a> { + type Inner = KeyValue<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } +} + +impl<'a> KeyValue<'a> { + pub const VT_KEY: flatbuffers::VOffsetT = 4; + pub const VT_VALUE: flatbuffers::VOffsetT = 6; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + KeyValue { _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>, + args: &'args KeyValueArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = KeyValueBuilder::new(_fbb); + if let Some(x) = args.value { builder.add_value(x); } + if let Some(x) = args.key { builder.add_key(x); } + builder.finish() + } + + + #[inline] + pub fn key(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(KeyValue::VT_KEY, None).unwrap()} + } + #[inline] + pub fn key_compare_less_than(&self, o: &KeyValue) -> bool { + self.key() < o.key() + } + + #[inline] + pub fn key_compare_with_value(&self, val: & str) -> ::core::cmp::Ordering { + let key = self.key(); + key.cmp(val) + } + #[inline] + pub fn value(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(KeyValue::VT_VALUE, None)} + } +} + +impl flatbuffers::Verifiable for KeyValue<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>("key", Self::VT_KEY, true)? + .visit_field::>("value", Self::VT_VALUE, false)? + .finish(); + Ok(()) + } +} +pub struct KeyValueArgs<'a> { + pub key: Option>, + pub value: Option>, +} +impl<'a> Default for KeyValueArgs<'a> { + #[inline] + fn default() -> Self { + KeyValueArgs { + key: None, // required field + value: None, + } + } +} + +pub struct KeyValueBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> KeyValueBuilder<'a, 'b, A> { + #[inline] + pub fn add_key(&mut self, key: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(KeyValue::VT_KEY, key); + } + #[inline] + pub fn add_value(&mut self, value: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(KeyValue::VT_VALUE, value); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> KeyValueBuilder<'a, 'b, A> { + let start = _fbb.start_table(); + KeyValueBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + self.fbb_.required(o, KeyValue::VT_KEY,"key"); + flatbuffers::WIPOffset::new(o.value()) + } +} + +impl core::fmt::Debug for KeyValue<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("KeyValue"); + ds.field("key", &self.key()); + ds.field("value", &self.value()); + ds.finish() + } +} +pub enum EnumValOffset {} +#[derive(Copy, Clone, PartialEq)] + +pub struct EnumVal<'a> { + pub _tab: flatbuffers::Table<'a>, +} + +impl<'a> flatbuffers::Follow<'a> for EnumVal<'a> { + type Inner = EnumVal<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } +} + +impl<'a> EnumVal<'a> { + pub const VT_NAME: flatbuffers::VOffsetT = 4; + pub const VT_VALUE: flatbuffers::VOffsetT = 6; + pub const VT_UNION_TYPE: flatbuffers::VOffsetT = 10; + pub const VT_DOCUMENTATION: flatbuffers::VOffsetT = 12; + pub const VT_ATTRIBUTES: flatbuffers::VOffsetT = 14; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + EnumVal { _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>, + args: &'args EnumValArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = EnumValBuilder::new(_fbb); + builder.add_value(args.value); + if let Some(x) = args.attributes { builder.add_attributes(x); } + if let Some(x) = args.documentation { builder.add_documentation(x); } + if let Some(x) = args.union_type { builder.add_union_type(x); } + if let Some(x) = args.name { builder.add_name(x); } + builder.finish() + } + + + #[inline] + pub fn name(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(EnumVal::VT_NAME, None).unwrap()} + } + #[inline] + pub fn value(&self) -> i64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(EnumVal::VT_VALUE, Some(0)).unwrap()} + } + #[inline] + pub fn key_compare_less_than(&self, o: &EnumVal) -> bool { + self.value() < o.value() + } + + #[inline] + pub fn key_compare_with_value(&self, val: i64) -> ::core::cmp::Ordering { + let key = self.value(); + key.cmp(&val) + } + #[inline] + pub fn union_type(&self) -> Option> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(EnumVal::VT_UNION_TYPE, None)} + } + #[inline] + pub fn documentation(&self) -> Option>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>>(EnumVal::VT_DOCUMENTATION, None)} + } + #[inline] + pub fn attributes(&self) -> Option>>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>>(EnumVal::VT_ATTRIBUTES, None)} + } +} + +impl flatbuffers::Verifiable for EnumVal<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>("name", Self::VT_NAME, true)? + .visit_field::("value", Self::VT_VALUE, false)? + .visit_field::>("union_type", Self::VT_UNION_TYPE, false)? + .visit_field::>>>("documentation", Self::VT_DOCUMENTATION, false)? + .visit_field::>>>("attributes", Self::VT_ATTRIBUTES, false)? + .finish(); + Ok(()) + } +} +pub struct EnumValArgs<'a> { + pub name: Option>, + pub value: i64, + pub union_type: Option>>, + pub documentation: Option>>>, + pub attributes: Option>>>>, +} +impl<'a> Default for EnumValArgs<'a> { + #[inline] + fn default() -> Self { + EnumValArgs { + name: None, // required field + value: 0, + union_type: None, + documentation: None, + attributes: None, + } + } +} + +pub struct EnumValBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> EnumValBuilder<'a, 'b, A> { + #[inline] + pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(EnumVal::VT_NAME, name); + } + #[inline] + pub fn add_value(&mut self, value: i64) { + self.fbb_.push_slot::(EnumVal::VT_VALUE, value, 0); + } + #[inline] + pub fn add_union_type(&mut self, union_type: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(EnumVal::VT_UNION_TYPE, union_type); + } + #[inline] + pub fn add_documentation(&mut self, documentation: flatbuffers::WIPOffset>>) { + self.fbb_.push_slot_always::>(EnumVal::VT_DOCUMENTATION, documentation); + } + #[inline] + pub fn add_attributes(&mut self, attributes: flatbuffers::WIPOffset>>>) { + self.fbb_.push_slot_always::>(EnumVal::VT_ATTRIBUTES, attributes); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> EnumValBuilder<'a, 'b, A> { + let start = _fbb.start_table(); + EnumValBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + self.fbb_.required(o, EnumVal::VT_NAME,"name"); + flatbuffers::WIPOffset::new(o.value()) + } +} + +impl core::fmt::Debug for EnumVal<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("EnumVal"); + ds.field("name", &self.name()); + ds.field("value", &self.value()); + ds.field("union_type", &self.union_type()); + ds.field("documentation", &self.documentation()); + ds.field("attributes", &self.attributes()); + ds.finish() + } +} +pub enum EnumOffset {} +#[derive(Copy, Clone, PartialEq)] + +pub struct Enum<'a> { + pub _tab: flatbuffers::Table<'a>, +} + +impl<'a> flatbuffers::Follow<'a> for Enum<'a> { + type Inner = Enum<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } +} + +impl<'a> Enum<'a> { + pub const VT_NAME: flatbuffers::VOffsetT = 4; + pub const VT_VALUES: flatbuffers::VOffsetT = 6; + pub const VT_IS_UNION: flatbuffers::VOffsetT = 8; + pub const VT_UNDERLYING_TYPE: flatbuffers::VOffsetT = 10; + pub const VT_ATTRIBUTES: flatbuffers::VOffsetT = 12; + pub const VT_DOCUMENTATION: flatbuffers::VOffsetT = 14; + pub const VT_DECLARATION_FILE: flatbuffers::VOffsetT = 16; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + Enum { _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>, + args: &'args EnumArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = EnumBuilder::new(_fbb); + if let Some(x) = args.declaration_file { builder.add_declaration_file(x); } + if let Some(x) = args.documentation { builder.add_documentation(x); } + if let Some(x) = args.attributes { builder.add_attributes(x); } + if let Some(x) = args.underlying_type { builder.add_underlying_type(x); } + if let Some(x) = args.values { builder.add_values(x); } + if let Some(x) = args.name { builder.add_name(x); } + builder.add_is_union(args.is_union); + builder.finish() + } + + + #[inline] + pub fn name(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(Enum::VT_NAME, None).unwrap()} + } + #[inline] + pub fn key_compare_less_than(&self, o: &Enum) -> bool { + self.name() < o.name() + } + + #[inline] + pub fn key_compare_with_value(&self, val: & str) -> ::core::cmp::Ordering { + let key = self.name(); + key.cmp(val) + } + #[inline] + pub fn values(&self) -> flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>>(Enum::VT_VALUES, None).unwrap()} + } + #[inline] + pub fn is_union(&self) -> bool { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Enum::VT_IS_UNION, Some(false)).unwrap()} + } + #[inline] + pub fn underlying_type(&self) -> Type<'a> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(Enum::VT_UNDERLYING_TYPE, None).unwrap()} + } + #[inline] + pub fn attributes(&self) -> Option>>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>>(Enum::VT_ATTRIBUTES, None)} + } + #[inline] + pub fn documentation(&self) -> Option>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>>(Enum::VT_DOCUMENTATION, None)} + } + /// File that this Enum is declared in. + #[inline] + pub fn declaration_file(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(Enum::VT_DECLARATION_FILE, None)} + } +} + +impl flatbuffers::Verifiable for Enum<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>("name", Self::VT_NAME, true)? + .visit_field::>>>("values", Self::VT_VALUES, true)? + .visit_field::("is_union", Self::VT_IS_UNION, false)? + .visit_field::>("underlying_type", Self::VT_UNDERLYING_TYPE, true)? + .visit_field::>>>("attributes", Self::VT_ATTRIBUTES, false)? + .visit_field::>>>("documentation", Self::VT_DOCUMENTATION, false)? + .visit_field::>("declaration_file", Self::VT_DECLARATION_FILE, false)? + .finish(); + Ok(()) + } +} +pub struct EnumArgs<'a> { + pub name: Option>, + pub values: Option>>>>, + pub is_union: bool, + pub underlying_type: Option>>, + pub attributes: Option>>>>, + pub documentation: Option>>>, + pub declaration_file: Option>, +} +impl<'a> Default for EnumArgs<'a> { + #[inline] + fn default() -> Self { + EnumArgs { + name: None, // required field + values: None, // required field + is_union: false, + underlying_type: None, // required field + attributes: None, + documentation: None, + declaration_file: None, + } + } +} + +pub struct EnumBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> EnumBuilder<'a, 'b, A> { + #[inline] + pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(Enum::VT_NAME, name); + } + #[inline] + pub fn add_values(&mut self, values: flatbuffers::WIPOffset>>>) { + self.fbb_.push_slot_always::>(Enum::VT_VALUES, values); + } + #[inline] + pub fn add_is_union(&mut self, is_union: bool) { + self.fbb_.push_slot::(Enum::VT_IS_UNION, is_union, false); + } + #[inline] + pub fn add_underlying_type(&mut self, underlying_type: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(Enum::VT_UNDERLYING_TYPE, underlying_type); + } + #[inline] + pub fn add_attributes(&mut self, attributes: flatbuffers::WIPOffset>>>) { + self.fbb_.push_slot_always::>(Enum::VT_ATTRIBUTES, attributes); + } + #[inline] + pub fn add_documentation(&mut self, documentation: flatbuffers::WIPOffset>>) { + self.fbb_.push_slot_always::>(Enum::VT_DOCUMENTATION, documentation); + } + #[inline] + pub fn add_declaration_file(&mut self, declaration_file: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(Enum::VT_DECLARATION_FILE, declaration_file); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> EnumBuilder<'a, 'b, A> { + let start = _fbb.start_table(); + EnumBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + self.fbb_.required(o, Enum::VT_NAME,"name"); + self.fbb_.required(o, Enum::VT_VALUES,"values"); + self.fbb_.required(o, Enum::VT_UNDERLYING_TYPE,"underlying_type"); + flatbuffers::WIPOffset::new(o.value()) + } +} + +impl core::fmt::Debug for Enum<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("Enum"); + ds.field("name", &self.name()); + ds.field("values", &self.values()); + ds.field("is_union", &self.is_union()); + ds.field("underlying_type", &self.underlying_type()); + ds.field("attributes", &self.attributes()); + ds.field("documentation", &self.documentation()); + ds.field("declaration_file", &self.declaration_file()); + ds.finish() + } +} +pub enum FieldOffset {} +#[derive(Copy, Clone, PartialEq)] + +pub struct Field<'a> { + pub _tab: flatbuffers::Table<'a>, +} + +impl<'a> flatbuffers::Follow<'a> for Field<'a> { + type Inner = Field<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } +} + +impl<'a> Field<'a> { + pub const VT_NAME: flatbuffers::VOffsetT = 4; + pub const VT_TYPE_: flatbuffers::VOffsetT = 6; + pub const VT_ID: flatbuffers::VOffsetT = 8; + pub const VT_OFFSET: flatbuffers::VOffsetT = 10; + pub const VT_DEFAULT_INTEGER: flatbuffers::VOffsetT = 12; + pub const VT_DEFAULT_REAL: flatbuffers::VOffsetT = 14; + pub const VT_DEPRECATED: flatbuffers::VOffsetT = 16; + pub const VT_REQUIRED: flatbuffers::VOffsetT = 18; + pub const VT_KEY: flatbuffers::VOffsetT = 20; + pub const VT_ATTRIBUTES: flatbuffers::VOffsetT = 22; + pub const VT_DOCUMENTATION: flatbuffers::VOffsetT = 24; + pub const VT_OPTIONAL: flatbuffers::VOffsetT = 26; + pub const VT_PADDING: flatbuffers::VOffsetT = 28; + pub const VT_OFFSET64: flatbuffers::VOffsetT = 30; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + Field { _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>, + args: &'args FieldArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = FieldBuilder::new(_fbb); + builder.add_default_real(args.default_real); + builder.add_default_integer(args.default_integer); + if let Some(x) = args.documentation { builder.add_documentation(x); } + if let Some(x) = args.attributes { builder.add_attributes(x); } + if let Some(x) = args.type_ { builder.add_type_(x); } + if let Some(x) = args.name { builder.add_name(x); } + builder.add_padding(args.padding); + builder.add_offset(args.offset); + builder.add_id(args.id); + builder.add_offset64(args.offset64); + builder.add_optional(args.optional); + builder.add_key(args.key); + builder.add_required(args.required); + builder.add_deprecated(args.deprecated); + builder.finish() + } + + + #[inline] + pub fn name(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(Field::VT_NAME, None).unwrap()} + } + #[inline] + pub fn key_compare_less_than(&self, o: &Field) -> bool { + self.name() < o.name() + } + + #[inline] + pub fn key_compare_with_value(&self, val: & str) -> ::core::cmp::Ordering { + let key = self.name(); + key.cmp(val) + } + #[inline] + pub fn type_(&self) -> Type<'a> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(Field::VT_TYPE_, None).unwrap()} + } + #[inline] + pub fn id(&self) -> u16 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Field::VT_ID, Some(0)).unwrap()} + } + #[inline] + pub fn offset(&self) -> u16 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Field::VT_OFFSET, Some(0)).unwrap()} + } + #[inline] + pub fn default_integer(&self) -> i64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Field::VT_DEFAULT_INTEGER, Some(0)).unwrap()} + } + #[inline] + pub fn default_real(&self) -> f64 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Field::VT_DEFAULT_REAL, Some(0.0)).unwrap()} + } + #[inline] + pub fn deprecated(&self) -> bool { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Field::VT_DEPRECATED, Some(false)).unwrap()} + } + #[inline] + pub fn required(&self) -> bool { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Field::VT_REQUIRED, Some(false)).unwrap()} + } + #[inline] + pub fn key(&self) -> bool { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Field::VT_KEY, Some(false)).unwrap()} + } + #[inline] + pub fn attributes(&self) -> Option>>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>>(Field::VT_ATTRIBUTES, None)} + } + #[inline] + pub fn documentation(&self) -> Option>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>>(Field::VT_DOCUMENTATION, None)} + } + #[inline] + pub fn optional(&self) -> bool { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Field::VT_OPTIONAL, Some(false)).unwrap()} + } + /// Number of padding octets to always add after this field. Structs only. + #[inline] + pub fn padding(&self) -> u16 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Field::VT_PADDING, Some(0)).unwrap()} + } + /// If the field uses 64-bit offsets. + #[inline] + pub fn offset64(&self) -> bool { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Field::VT_OFFSET64, Some(false)).unwrap()} + } +} + +impl flatbuffers::Verifiable for Field<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>("name", Self::VT_NAME, true)? + .visit_field::>("type_", Self::VT_TYPE_, true)? + .visit_field::("id", Self::VT_ID, false)? + .visit_field::("offset", Self::VT_OFFSET, false)? + .visit_field::("default_integer", Self::VT_DEFAULT_INTEGER, false)? + .visit_field::("default_real", Self::VT_DEFAULT_REAL, false)? + .visit_field::("deprecated", Self::VT_DEPRECATED, false)? + .visit_field::("required", Self::VT_REQUIRED, false)? + .visit_field::("key", Self::VT_KEY, false)? + .visit_field::>>>("attributes", Self::VT_ATTRIBUTES, false)? + .visit_field::>>>("documentation", Self::VT_DOCUMENTATION, false)? + .visit_field::("optional", Self::VT_OPTIONAL, false)? + .visit_field::("padding", Self::VT_PADDING, false)? + .visit_field::("offset64", Self::VT_OFFSET64, false)? + .finish(); + Ok(()) + } +} +pub struct FieldArgs<'a> { + pub name: Option>, + pub type_: Option>>, + pub id: u16, + pub offset: u16, + pub default_integer: i64, + pub default_real: f64, + pub deprecated: bool, + pub required: bool, + pub key: bool, + pub attributes: Option>>>>, + pub documentation: Option>>>, + pub optional: bool, + pub padding: u16, + pub offset64: bool, +} +impl<'a> Default for FieldArgs<'a> { + #[inline] + fn default() -> Self { + FieldArgs { + name: None, // required field + type_: None, // required field + id: 0, + offset: 0, + default_integer: 0, + default_real: 0.0, + deprecated: false, + required: false, + key: false, + attributes: None, + documentation: None, + optional: false, + padding: 0, + offset64: false, + } + } +} + +pub struct FieldBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> FieldBuilder<'a, 'b, A> { + #[inline] + pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(Field::VT_NAME, name); + } + #[inline] + pub fn add_type_(&mut self, type_: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(Field::VT_TYPE_, type_); + } + #[inline] + pub fn add_id(&mut self, id: u16) { + self.fbb_.push_slot::(Field::VT_ID, id, 0); + } + #[inline] + pub fn add_offset(&mut self, offset: u16) { + self.fbb_.push_slot::(Field::VT_OFFSET, offset, 0); + } + #[inline] + pub fn add_default_integer(&mut self, default_integer: i64) { + self.fbb_.push_slot::(Field::VT_DEFAULT_INTEGER, default_integer, 0); + } + #[inline] + pub fn add_default_real(&mut self, default_real: f64) { + self.fbb_.push_slot::(Field::VT_DEFAULT_REAL, default_real, 0.0); + } + #[inline] + pub fn add_deprecated(&mut self, deprecated: bool) { + self.fbb_.push_slot::(Field::VT_DEPRECATED, deprecated, false); + } + #[inline] + pub fn add_required(&mut self, required: bool) { + self.fbb_.push_slot::(Field::VT_REQUIRED, required, false); + } + #[inline] + pub fn add_key(&mut self, key: bool) { + self.fbb_.push_slot::(Field::VT_KEY, key, false); + } + #[inline] + pub fn add_attributes(&mut self, attributes: flatbuffers::WIPOffset>>>) { + self.fbb_.push_slot_always::>(Field::VT_ATTRIBUTES, attributes); + } + #[inline] + pub fn add_documentation(&mut self, documentation: flatbuffers::WIPOffset>>) { + self.fbb_.push_slot_always::>(Field::VT_DOCUMENTATION, documentation); + } + #[inline] + pub fn add_optional(&mut self, optional: bool) { + self.fbb_.push_slot::(Field::VT_OPTIONAL, optional, false); + } + #[inline] + pub fn add_padding(&mut self, padding: u16) { + self.fbb_.push_slot::(Field::VT_PADDING, padding, 0); + } + #[inline] + pub fn add_offset64(&mut self, offset64: bool) { + self.fbb_.push_slot::(Field::VT_OFFSET64, offset64, false); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> FieldBuilder<'a, 'b, A> { + let start = _fbb.start_table(); + FieldBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + self.fbb_.required(o, Field::VT_NAME,"name"); + self.fbb_.required(o, Field::VT_TYPE_,"type_"); + flatbuffers::WIPOffset::new(o.value()) + } +} + +impl core::fmt::Debug for Field<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("Field"); + ds.field("name", &self.name()); + ds.field("type_", &self.type_()); + ds.field("id", &self.id()); + ds.field("offset", &self.offset()); + ds.field("default_integer", &self.default_integer()); + ds.field("default_real", &self.default_real()); + ds.field("deprecated", &self.deprecated()); + ds.field("required", &self.required()); + ds.field("key", &self.key()); + ds.field("attributes", &self.attributes()); + ds.field("documentation", &self.documentation()); + ds.field("optional", &self.optional()); + ds.field("padding", &self.padding()); + ds.field("offset64", &self.offset64()); + ds.finish() + } +} +pub enum ObjectOffset {} +#[derive(Copy, Clone, PartialEq)] + +pub struct Object<'a> { + pub _tab: flatbuffers::Table<'a>, +} + +impl<'a> flatbuffers::Follow<'a> for Object<'a> { + type Inner = Object<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } +} + +impl<'a> Object<'a> { + pub const VT_NAME: flatbuffers::VOffsetT = 4; + pub const VT_FIELDS: flatbuffers::VOffsetT = 6; + pub const VT_IS_STRUCT: flatbuffers::VOffsetT = 8; + pub const VT_MINALIGN: flatbuffers::VOffsetT = 10; + pub const VT_BYTESIZE: flatbuffers::VOffsetT = 12; + pub const VT_ATTRIBUTES: flatbuffers::VOffsetT = 14; + pub const VT_DOCUMENTATION: flatbuffers::VOffsetT = 16; + pub const VT_DECLARATION_FILE: flatbuffers::VOffsetT = 18; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + Object { _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>, + args: &'args ObjectArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = ObjectBuilder::new(_fbb); + if let Some(x) = args.declaration_file { builder.add_declaration_file(x); } + if let Some(x) = args.documentation { builder.add_documentation(x); } + if let Some(x) = args.attributes { builder.add_attributes(x); } + builder.add_bytesize(args.bytesize); + builder.add_minalign(args.minalign); + if let Some(x) = args.fields { builder.add_fields(x); } + if let Some(x) = args.name { builder.add_name(x); } + builder.add_is_struct(args.is_struct); + builder.finish() + } + + + #[inline] + pub fn name(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(Object::VT_NAME, None).unwrap()} + } + #[inline] + pub fn key_compare_less_than(&self, o: &Object) -> bool { + self.name() < o.name() + } + + #[inline] + pub fn key_compare_with_value(&self, val: & str) -> ::core::cmp::Ordering { + let key = self.name(); + key.cmp(val) + } + #[inline] + pub fn fields(&self) -> flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>>(Object::VT_FIELDS, None).unwrap()} + } + #[inline] + pub fn is_struct(&self) -> bool { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Object::VT_IS_STRUCT, Some(false)).unwrap()} + } + #[inline] + pub fn minalign(&self) -> i32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Object::VT_MINALIGN, Some(0)).unwrap()} + } + #[inline] + pub fn bytesize(&self) -> i32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Object::VT_BYTESIZE, Some(0)).unwrap()} + } + #[inline] + pub fn attributes(&self) -> Option>>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>>(Object::VT_ATTRIBUTES, None)} + } + #[inline] + pub fn documentation(&self) -> Option>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>>(Object::VT_DOCUMENTATION, None)} + } + /// File that this Object is declared in. + #[inline] + pub fn declaration_file(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(Object::VT_DECLARATION_FILE, None)} + } +} + +impl flatbuffers::Verifiable for Object<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>("name", Self::VT_NAME, true)? + .visit_field::>>>("fields", Self::VT_FIELDS, true)? + .visit_field::("is_struct", Self::VT_IS_STRUCT, false)? + .visit_field::("minalign", Self::VT_MINALIGN, false)? + .visit_field::("bytesize", Self::VT_BYTESIZE, false)? + .visit_field::>>>("attributes", Self::VT_ATTRIBUTES, false)? + .visit_field::>>>("documentation", Self::VT_DOCUMENTATION, false)? + .visit_field::>("declaration_file", Self::VT_DECLARATION_FILE, false)? + .finish(); + Ok(()) + } +} +pub struct ObjectArgs<'a> { + pub name: Option>, + pub fields: Option>>>>, + pub is_struct: bool, + pub minalign: i32, + pub bytesize: i32, + pub attributes: Option>>>>, + pub documentation: Option>>>, + pub declaration_file: Option>, +} +impl<'a> Default for ObjectArgs<'a> { + #[inline] + fn default() -> Self { + ObjectArgs { + name: None, // required field + fields: None, // required field + is_struct: false, + minalign: 0, + bytesize: 0, + attributes: None, + documentation: None, + declaration_file: None, + } + } +} + +pub struct ObjectBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> ObjectBuilder<'a, 'b, A> { + #[inline] + pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(Object::VT_NAME, name); + } + #[inline] + pub fn add_fields(&mut self, fields: flatbuffers::WIPOffset>>>) { + self.fbb_.push_slot_always::>(Object::VT_FIELDS, fields); + } + #[inline] + pub fn add_is_struct(&mut self, is_struct: bool) { + self.fbb_.push_slot::(Object::VT_IS_STRUCT, is_struct, false); + } + #[inline] + pub fn add_minalign(&mut self, minalign: i32) { + self.fbb_.push_slot::(Object::VT_MINALIGN, minalign, 0); + } + #[inline] + pub fn add_bytesize(&mut self, bytesize: i32) { + self.fbb_.push_slot::(Object::VT_BYTESIZE, bytesize, 0); + } + #[inline] + pub fn add_attributes(&mut self, attributes: flatbuffers::WIPOffset>>>) { + self.fbb_.push_slot_always::>(Object::VT_ATTRIBUTES, attributes); + } + #[inline] + pub fn add_documentation(&mut self, documentation: flatbuffers::WIPOffset>>) { + self.fbb_.push_slot_always::>(Object::VT_DOCUMENTATION, documentation); + } + #[inline] + pub fn add_declaration_file(&mut self, declaration_file: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(Object::VT_DECLARATION_FILE, declaration_file); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> ObjectBuilder<'a, 'b, A> { + let start = _fbb.start_table(); + ObjectBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + self.fbb_.required(o, Object::VT_NAME,"name"); + self.fbb_.required(o, Object::VT_FIELDS,"fields"); + flatbuffers::WIPOffset::new(o.value()) + } +} + +impl core::fmt::Debug for Object<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("Object"); + ds.field("name", &self.name()); + ds.field("fields", &self.fields()); + ds.field("is_struct", &self.is_struct()); + ds.field("minalign", &self.minalign()); + ds.field("bytesize", &self.bytesize()); + ds.field("attributes", &self.attributes()); + ds.field("documentation", &self.documentation()); + ds.field("declaration_file", &self.declaration_file()); + ds.finish() + } +} +pub enum RPCCallOffset {} +#[derive(Copy, Clone, PartialEq)] + +pub struct RPCCall<'a> { + pub _tab: flatbuffers::Table<'a>, +} + +impl<'a> flatbuffers::Follow<'a> for RPCCall<'a> { + type Inner = RPCCall<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } +} + +impl<'a> RPCCall<'a> { + pub const VT_NAME: flatbuffers::VOffsetT = 4; + pub const VT_REQUEST: flatbuffers::VOffsetT = 6; + pub const VT_RESPONSE: flatbuffers::VOffsetT = 8; + pub const VT_ATTRIBUTES: flatbuffers::VOffsetT = 10; + pub const VT_DOCUMENTATION: flatbuffers::VOffsetT = 12; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + RPCCall { _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>, + args: &'args RPCCallArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = RPCCallBuilder::new(_fbb); + if let Some(x) = args.documentation { builder.add_documentation(x); } + if let Some(x) = args.attributes { builder.add_attributes(x); } + if let Some(x) = args.response { builder.add_response(x); } + if let Some(x) = args.request { builder.add_request(x); } + if let Some(x) = args.name { builder.add_name(x); } + builder.finish() + } + + + #[inline] + pub fn name(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(RPCCall::VT_NAME, None).unwrap()} + } + #[inline] + pub fn key_compare_less_than(&self, o: &RPCCall) -> bool { + self.name() < o.name() + } + + #[inline] + pub fn key_compare_with_value(&self, val: & str) -> ::core::cmp::Ordering { + let key = self.name(); + key.cmp(val) + } + #[inline] + pub fn request(&self) -> Object<'a> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(RPCCall::VT_REQUEST, None).unwrap()} + } + #[inline] + pub fn response(&self) -> Object<'a> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(RPCCall::VT_RESPONSE, None).unwrap()} + } + #[inline] + pub fn attributes(&self) -> Option>>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>>(RPCCall::VT_ATTRIBUTES, None)} + } + #[inline] + pub fn documentation(&self) -> Option>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>>(RPCCall::VT_DOCUMENTATION, None)} + } +} + +impl flatbuffers::Verifiable for RPCCall<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>("name", Self::VT_NAME, true)? + .visit_field::>("request", Self::VT_REQUEST, true)? + .visit_field::>("response", Self::VT_RESPONSE, true)? + .visit_field::>>>("attributes", Self::VT_ATTRIBUTES, false)? + .visit_field::>>>("documentation", Self::VT_DOCUMENTATION, false)? + .finish(); + Ok(()) + } +} +pub struct RPCCallArgs<'a> { + pub name: Option>, + pub request: Option>>, + pub response: Option>>, + pub attributes: Option>>>>, + pub documentation: Option>>>, +} +impl<'a> Default for RPCCallArgs<'a> { + #[inline] + fn default() -> Self { + RPCCallArgs { + name: None, // required field + request: None, // required field + response: None, // required field + attributes: None, + documentation: None, + } + } +} + +pub struct RPCCallBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> RPCCallBuilder<'a, 'b, A> { + #[inline] + pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(RPCCall::VT_NAME, name); + } + #[inline] + pub fn add_request(&mut self, request: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(RPCCall::VT_REQUEST, request); + } + #[inline] + pub fn add_response(&mut self, response: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(RPCCall::VT_RESPONSE, response); + } + #[inline] + pub fn add_attributes(&mut self, attributes: flatbuffers::WIPOffset>>>) { + self.fbb_.push_slot_always::>(RPCCall::VT_ATTRIBUTES, attributes); + } + #[inline] + pub fn add_documentation(&mut self, documentation: flatbuffers::WIPOffset>>) { + self.fbb_.push_slot_always::>(RPCCall::VT_DOCUMENTATION, documentation); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> RPCCallBuilder<'a, 'b, A> { + let start = _fbb.start_table(); + RPCCallBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + self.fbb_.required(o, RPCCall::VT_NAME,"name"); + self.fbb_.required(o, RPCCall::VT_REQUEST,"request"); + self.fbb_.required(o, RPCCall::VT_RESPONSE,"response"); + flatbuffers::WIPOffset::new(o.value()) + } +} + +impl core::fmt::Debug for RPCCall<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("RPCCall"); + ds.field("name", &self.name()); + ds.field("request", &self.request()); + ds.field("response", &self.response()); + ds.field("attributes", &self.attributes()); + ds.field("documentation", &self.documentation()); + ds.finish() + } +} +pub enum ServiceOffset {} +#[derive(Copy, Clone, PartialEq)] + +pub struct Service<'a> { + pub _tab: flatbuffers::Table<'a>, +} + +impl<'a> flatbuffers::Follow<'a> for Service<'a> { + type Inner = Service<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } +} + +impl<'a> Service<'a> { + pub const VT_NAME: flatbuffers::VOffsetT = 4; + pub const VT_CALLS: flatbuffers::VOffsetT = 6; + pub const VT_ATTRIBUTES: flatbuffers::VOffsetT = 8; + pub const VT_DOCUMENTATION: flatbuffers::VOffsetT = 10; + pub const VT_DECLARATION_FILE: flatbuffers::VOffsetT = 12; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + Service { _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>, + args: &'args ServiceArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = ServiceBuilder::new(_fbb); + if let Some(x) = args.declaration_file { builder.add_declaration_file(x); } + if let Some(x) = args.documentation { builder.add_documentation(x); } + if let Some(x) = args.attributes { builder.add_attributes(x); } + if let Some(x) = args.calls { builder.add_calls(x); } + if let Some(x) = args.name { builder.add_name(x); } + builder.finish() + } + + + #[inline] + pub fn name(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(Service::VT_NAME, None).unwrap()} + } + #[inline] + pub fn key_compare_less_than(&self, o: &Service) -> bool { + self.name() < o.name() + } + + #[inline] + pub fn key_compare_with_value(&self, val: & str) -> ::core::cmp::Ordering { + let key = self.name(); + key.cmp(val) + } + #[inline] + pub fn calls(&self) -> Option>>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>>(Service::VT_CALLS, None)} + } + #[inline] + pub fn attributes(&self) -> Option>>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>>(Service::VT_ATTRIBUTES, None)} + } + #[inline] + pub fn documentation(&self) -> Option>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>>(Service::VT_DOCUMENTATION, None)} + } + /// File that this Service is declared in. + #[inline] + pub fn declaration_file(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(Service::VT_DECLARATION_FILE, None)} + } +} + +impl flatbuffers::Verifiable for Service<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>("name", Self::VT_NAME, true)? + .visit_field::>>>("calls", Self::VT_CALLS, false)? + .visit_field::>>>("attributes", Self::VT_ATTRIBUTES, false)? + .visit_field::>>>("documentation", Self::VT_DOCUMENTATION, false)? + .visit_field::>("declaration_file", Self::VT_DECLARATION_FILE, false)? + .finish(); + Ok(()) + } +} +pub struct ServiceArgs<'a> { + pub name: Option>, + pub calls: Option>>>>, + pub attributes: Option>>>>, + pub documentation: Option>>>, + pub declaration_file: Option>, +} +impl<'a> Default for ServiceArgs<'a> { + #[inline] + fn default() -> Self { + ServiceArgs { + name: None, // required field + calls: None, + attributes: None, + documentation: None, + declaration_file: None, + } + } +} + +pub struct ServiceBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> ServiceBuilder<'a, 'b, A> { + #[inline] + pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(Service::VT_NAME, name); + } + #[inline] + pub fn add_calls(&mut self, calls: flatbuffers::WIPOffset>>>) { + self.fbb_.push_slot_always::>(Service::VT_CALLS, calls); + } + #[inline] + pub fn add_attributes(&mut self, attributes: flatbuffers::WIPOffset>>>) { + self.fbb_.push_slot_always::>(Service::VT_ATTRIBUTES, attributes); + } + #[inline] + pub fn add_documentation(&mut self, documentation: flatbuffers::WIPOffset>>) { + self.fbb_.push_slot_always::>(Service::VT_DOCUMENTATION, documentation); + } + #[inline] + pub fn add_declaration_file(&mut self, declaration_file: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(Service::VT_DECLARATION_FILE, declaration_file); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> ServiceBuilder<'a, 'b, A> { + let start = _fbb.start_table(); + ServiceBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + self.fbb_.required(o, Service::VT_NAME,"name"); + flatbuffers::WIPOffset::new(o.value()) + } +} + +impl core::fmt::Debug for Service<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("Service"); + ds.field("name", &self.name()); + ds.field("calls", &self.calls()); + ds.field("attributes", &self.attributes()); + ds.field("documentation", &self.documentation()); + ds.field("declaration_file", &self.declaration_file()); + ds.finish() + } +} +pub enum SchemaFileOffset {} +#[derive(Copy, Clone, PartialEq)] + +/// File specific information. +/// Symbols declared within a file may be recovered by iterating over all +/// symbols and examining the `declaration_file` field. +pub struct SchemaFile<'a> { + pub _tab: flatbuffers::Table<'a>, +} + +impl<'a> flatbuffers::Follow<'a> for SchemaFile<'a> { + type Inner = SchemaFile<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } +} + +impl<'a> SchemaFile<'a> { + pub const VT_FILENAME: flatbuffers::VOffsetT = 4; + pub const VT_INCLUDED_FILENAMES: flatbuffers::VOffsetT = 6; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + SchemaFile { _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>, + args: &'args SchemaFileArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = SchemaFileBuilder::new(_fbb); + if let Some(x) = args.included_filenames { builder.add_included_filenames(x); } + if let Some(x) = args.filename { builder.add_filename(x); } + builder.finish() + } + + + /// Filename, relative to project root. + #[inline] + pub fn filename(&self) -> &'a str { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(SchemaFile::VT_FILENAME, None).unwrap()} + } + #[inline] + pub fn key_compare_less_than(&self, o: &SchemaFile) -> bool { + self.filename() < o.filename() + } + + #[inline] + pub fn key_compare_with_value(&self, val: & str) -> ::core::cmp::Ordering { + let key = self.filename(); + key.cmp(val) + } + /// Names of included files, relative to project root. + #[inline] + pub fn included_filenames(&self) -> Option>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>>(SchemaFile::VT_INCLUDED_FILENAMES, None)} + } +} + +impl flatbuffers::Verifiable for SchemaFile<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>("filename", Self::VT_FILENAME, true)? + .visit_field::>>>("included_filenames", Self::VT_INCLUDED_FILENAMES, false)? + .finish(); + Ok(()) + } +} +pub struct SchemaFileArgs<'a> { + pub filename: Option>, + pub included_filenames: Option>>>, +} +impl<'a> Default for SchemaFileArgs<'a> { + #[inline] + fn default() -> Self { + SchemaFileArgs { + filename: None, // required field + included_filenames: None, + } + } +} + +pub struct SchemaFileBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> SchemaFileBuilder<'a, 'b, A> { + #[inline] + pub fn add_filename(&mut self, filename: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(SchemaFile::VT_FILENAME, filename); + } + #[inline] + pub fn add_included_filenames(&mut self, included_filenames: flatbuffers::WIPOffset>>) { + self.fbb_.push_slot_always::>(SchemaFile::VT_INCLUDED_FILENAMES, included_filenames); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> SchemaFileBuilder<'a, 'b, A> { + let start = _fbb.start_table(); + SchemaFileBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + self.fbb_.required(o, SchemaFile::VT_FILENAME,"filename"); + flatbuffers::WIPOffset::new(o.value()) + } +} + +impl core::fmt::Debug for SchemaFile<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("SchemaFile"); + ds.field("filename", &self.filename()); + ds.field("included_filenames", &self.included_filenames()); + ds.finish() + } +} +pub enum SchemaOffset {} +#[derive(Copy, Clone, PartialEq)] + +pub struct Schema<'a> { + pub _tab: flatbuffers::Table<'a>, +} + +impl<'a> flatbuffers::Follow<'a> for Schema<'a> { + type Inner = Schema<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } +} + +impl<'a> Schema<'a> { + pub const VT_OBJECTS: flatbuffers::VOffsetT = 4; + pub const VT_ENUMS: flatbuffers::VOffsetT = 6; + pub const VT_FILE_IDENT: flatbuffers::VOffsetT = 8; + pub const VT_FILE_EXT: flatbuffers::VOffsetT = 10; + pub const VT_ROOT_TABLE: flatbuffers::VOffsetT = 12; + pub const VT_SERVICES: flatbuffers::VOffsetT = 14; + pub const VT_ADVANCED_FEATURES: flatbuffers::VOffsetT = 16; + pub const VT_FBS_FILES: flatbuffers::VOffsetT = 18; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + Schema { _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>, + args: &'args SchemaArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = SchemaBuilder::new(_fbb); + builder.add_advanced_features(args.advanced_features); + if let Some(x) = args.fbs_files { builder.add_fbs_files(x); } + if let Some(x) = args.services { builder.add_services(x); } + if let Some(x) = args.root_table { builder.add_root_table(x); } + if let Some(x) = args.file_ext { builder.add_file_ext(x); } + if let Some(x) = args.file_ident { builder.add_file_ident(x); } + if let Some(x) = args.enums { builder.add_enums(x); } + if let Some(x) = args.objects { builder.add_objects(x); } + builder.finish() + } + + + #[inline] + pub fn objects(&self) -> flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>>(Schema::VT_OBJECTS, None).unwrap()} + } + #[inline] + pub fn enums(&self) -> flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>>(Schema::VT_ENUMS, None).unwrap()} + } + #[inline] + pub fn file_ident(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(Schema::VT_FILE_IDENT, None)} + } + #[inline] + pub fn file_ext(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(Schema::VT_FILE_EXT, None)} + } + #[inline] + pub fn root_table(&self) -> Option> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(Schema::VT_ROOT_TABLE, None)} + } + #[inline] + pub fn services(&self) -> Option>>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>>(Schema::VT_SERVICES, None)} + } + #[inline] + pub fn advanced_features(&self) -> AdvancedFeatures { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(Schema::VT_ADVANCED_FEATURES, Some(Default::default())).unwrap()} + } + /// All the files used in this compilation. Files are relative to where + /// flatc was invoked. + #[inline] + pub fn fbs_files(&self) -> Option>>> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>>(Schema::VT_FBS_FILES, None)} + } +} + +impl flatbuffers::Verifiable for Schema<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>>>("objects", Self::VT_OBJECTS, true)? + .visit_field::>>>("enums", Self::VT_ENUMS, true)? + .visit_field::>("file_ident", Self::VT_FILE_IDENT, false)? + .visit_field::>("file_ext", Self::VT_FILE_EXT, false)? + .visit_field::>("root_table", Self::VT_ROOT_TABLE, false)? + .visit_field::>>>("services", Self::VT_SERVICES, false)? + .visit_field::("advanced_features", Self::VT_ADVANCED_FEATURES, false)? + .visit_field::>>>("fbs_files", Self::VT_FBS_FILES, false)? + .finish(); + Ok(()) + } +} +pub struct SchemaArgs<'a> { + pub objects: Option>>>>, + pub enums: Option>>>>, + pub file_ident: Option>, + pub file_ext: Option>, + pub root_table: Option>>, + pub services: Option>>>>, + pub advanced_features: AdvancedFeatures, + pub fbs_files: Option>>>>, +} +impl<'a> Default for SchemaArgs<'a> { + #[inline] + fn default() -> Self { + SchemaArgs { + objects: None, // required field + enums: None, // required field + file_ident: None, + file_ext: None, + root_table: None, + services: None, + advanced_features: Default::default(), + fbs_files: None, + } + } +} + +pub struct SchemaBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> SchemaBuilder<'a, 'b, A> { + #[inline] + pub fn add_objects(&mut self, objects: flatbuffers::WIPOffset>>>) { + self.fbb_.push_slot_always::>(Schema::VT_OBJECTS, objects); + } + #[inline] + pub fn add_enums(&mut self, enums: flatbuffers::WIPOffset>>>) { + self.fbb_.push_slot_always::>(Schema::VT_ENUMS, enums); + } + #[inline] + pub fn add_file_ident(&mut self, file_ident: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(Schema::VT_FILE_IDENT, file_ident); + } + #[inline] + pub fn add_file_ext(&mut self, file_ext: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(Schema::VT_FILE_EXT, file_ext); + } + #[inline] + pub fn add_root_table(&mut self, root_table: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(Schema::VT_ROOT_TABLE, root_table); + } + #[inline] + pub fn add_services(&mut self, services: flatbuffers::WIPOffset>>>) { + self.fbb_.push_slot_always::>(Schema::VT_SERVICES, services); + } + #[inline] + pub fn add_advanced_features(&mut self, advanced_features: AdvancedFeatures) { + self.fbb_.push_slot::(Schema::VT_ADVANCED_FEATURES, advanced_features, Default::default()); + } + #[inline] + pub fn add_fbs_files(&mut self, fbs_files: flatbuffers::WIPOffset>>>) { + self.fbb_.push_slot_always::>(Schema::VT_FBS_FILES, fbs_files); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> SchemaBuilder<'a, 'b, A> { + let start = _fbb.start_table(); + SchemaBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + self.fbb_.required(o, Schema::VT_OBJECTS,"objects"); + self.fbb_.required(o, Schema::VT_ENUMS,"enums"); + flatbuffers::WIPOffset::new(o.value()) + } +} + +impl core::fmt::Debug for Schema<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("Schema"); + ds.field("objects", &self.objects()); + ds.field("enums", &self.enums()); + ds.field("file_ident", &self.file_ident()); + ds.field("file_ext", &self.file_ext()); + ds.field("root_table", &self.root_table()); + ds.field("services", &self.services()); + ds.field("advanced_features", &self.advanced_features()); + ds.field("fbs_files", &self.fbs_files()); + ds.finish() + } +} +#[inline] +/// Verifies that a buffer of bytes contains a `Schema` +/// and returns it. +/// Note that verification is still experimental and may not +/// catch every error, or be maximally performant. For the +/// previous, unchecked, behavior use +/// `root_as_schema_unchecked`. +pub fn root_as_schema(buf: &[u8]) -> Result { + flatbuffers::root::(buf) +} +#[inline] +/// Verifies that a buffer of bytes contains a size prefixed +/// `Schema` and returns it. +/// Note that verification is still experimental and may not +/// catch every error, or be maximally performant. For the +/// previous, unchecked, behavior use +/// `size_prefixed_root_as_schema_unchecked`. +pub fn size_prefixed_root_as_schema(buf: &[u8]) -> Result { + flatbuffers::size_prefixed_root::(buf) +} +#[inline] +/// Verifies, with the given options, that a buffer of bytes +/// contains a `Schema` and returns it. +/// Note that verification is still experimental and may not +/// catch every error, or be maximally performant. For the +/// previous, unchecked, behavior use +/// `root_as_schema_unchecked`. +pub fn root_as_schema_with_opts<'b, 'o>( + opts: &'o flatbuffers::VerifierOptions, + buf: &'b [u8], +) -> Result, flatbuffers::InvalidFlatbuffer> { + flatbuffers::root_with_opts::>(opts, buf) +} +#[inline] +/// Verifies, with the given verifier options, that a buffer of +/// bytes contains a size prefixed `Schema` and returns +/// it. Note that verification is still experimental and may not +/// catch every error, or be maximally performant. For the +/// previous, unchecked, behavior use +/// `root_as_schema_unchecked`. +pub fn size_prefixed_root_as_schema_with_opts<'b, 'o>( + opts: &'o flatbuffers::VerifierOptions, + buf: &'b [u8], +) -> Result, flatbuffers::InvalidFlatbuffer> { + flatbuffers::size_prefixed_root_with_opts::>(opts, buf) +} +#[inline] +/// Assumes, without verification, that a buffer of bytes contains a Schema and returns it. +/// # Safety +/// Callers must trust the given bytes do indeed contain a valid `Schema`. +pub unsafe fn root_as_schema_unchecked(buf: &[u8]) -> Schema { + flatbuffers::root_unchecked::(buf) +} +#[inline] +/// Assumes, without verification, that a buffer of bytes contains a size prefixed Schema and returns it. +/// # Safety +/// Callers must trust the given bytes do indeed contain a valid size prefixed `Schema`. +pub unsafe fn size_prefixed_root_as_schema_unchecked(buf: &[u8]) -> Schema { + flatbuffers::size_prefixed_root_unchecked::(buf) +} +pub const SCHEMA_IDENTIFIER: &str = "BFBS"; + +#[inline] +pub fn schema_buffer_has_identifier(buf: &[u8]) -> bool { + flatbuffers::buffer_has_identifier(buf, SCHEMA_IDENTIFIER, false) +} + +#[inline] +pub fn schema_size_prefixed_buffer_has_identifier(buf: &[u8]) -> bool { + flatbuffers::buffer_has_identifier(buf, SCHEMA_IDENTIFIER, true) +} + +pub const SCHEMA_EXTENSION: &str = "bfbs"; + +#[inline] +pub fn finish_schema_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>( + fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + root: flatbuffers::WIPOffset>) { + fbb.finish(root, Some(SCHEMA_IDENTIFIER)); +} + +#[inline] +pub fn finish_size_prefixed_schema_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, root: flatbuffers::WIPOffset>) { + fbb.finish_size_prefixed(root, Some(SCHEMA_IDENTIFIER)); +} +} // pub mod reflection - #[inline] - pub fn finish_size_prefixed_schema_buffer<'a, 'b>( - fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, - root: flatbuffers::WIPOffset>, - ) { - fbb.finish_size_prefixed(root, Some(SCHEMA_IDENTIFIER)); - } -} // pub mod reflection From 7691730fec54974e66ef998836c61c7fcbe0c39e Mon Sep 17 00:00:00 2001 From: Marcin Radomski Date: Thu, 30 Jan 2025 18:16:08 +0000 Subject: [PATCH 09/11] ts/BUILD.bazel: add missing import Found by Buildifire presubmit: Function "sh_binary" is not global anymore and needs to be loaded from "@rules_shell//shell:sh_binary.bzl". Signed-off-by: Marcin Radomski --- MODULE.bazel | 4 ++++ ts/BUILD.bazel | 1 + 2 files changed, 5 insertions(+) diff --git a/MODULE.bazel b/MODULE.bazel index 2bf556d9262..08408110cad 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -43,6 +43,10 @@ bazel_dep( name = "rules_nodejs", version = "6.3.3", ) +bazel_dep( + name = "rules_shell", + version = "0.3.0", +) bazel_dep( name = "rules_swift", version = "1.18.0", diff --git a/ts/BUILD.bazel b/ts/BUILD.bazel index 581dfe1f7ea..827244a95b4 100644 --- a/ts/BUILD.bazel +++ b/ts/BUILD.bazel @@ -1,6 +1,7 @@ load("@aspect_rules_js//npm:defs.bzl", "npm_package") load("@aspect_rules_ts//ts:defs.bzl", "ts_project") load("@flatbuffers_npm//:defs.bzl", "npm_link_all_packages") +load("@rules_shell//shell:sh_binary.bzl", "sh_binary") filegroup( name = "distribution", From 89f1c8e4c959bd9da1f2631d9e826852bf8668b3 Mon Sep 17 00:00:00 2001 From: Marcin Radomski Date: Fri, 31 Jan 2025 18:52:03 +0100 Subject: [PATCH 10/11] Update expected value in generated_code_debug_prints_correctly test In bitflags v2, the debug string representation of enum values is different than it was in v1: Blue -> Color(Blue) (empty) -> LongEnum(0x0) This change adjusts the expected test value. Signed-off-by: Marcin Radomski --- .../rust_usage_test/tests/integration_test.rs | 71 ++++++++++--------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/tests/rust_usage_test/tests/integration_test.rs b/tests/rust_usage_test/tests/integration_test.rs index a1d5a02b532..d3dc731ceeb 100644 --- a/tests/rust_usage_test/tests/integration_test.rs +++ b/tests/rust_usage_test/tests/integration_test.rs @@ -1767,19 +1767,19 @@ mod write_and_read_examples { assert_eq!( format!("{:.5?}", &m), "Monster { pos: Some(Vec3 { x: 1.00000, y: 2.00000, z: 3.00000, \ - test1: 3.00000, test2: Green, test3: Test { a: 5, b: 6 } }), \ - mana: 150, hp: 80, name: \"MyMonster\", \ - inventory: Some([0, 1, 2, 3, 4]), color: Blue, test_type: Monster, \ - test: Monster { pos: None, mana: 150, hp: 100, name: \"Fred\", \ - inventory: None, color: Blue, test_type: NONE, test: None, \ - test4: None, testarrayofstring: None, testarrayoftables: None, \ - enemy: None, testnestedflatbuffer: None, testempty: None, \ - testbool: false, testhashs32_fnv1: 0, testhashu32_fnv1: 0, \ - testhashs64_fnv1: 0, testhashu64_fnv1: 0, testhashs32_fnv1a: 0, \ - testhashu32_fnv1a: 0, testhashs64_fnv1a: 0, testhashu64_fnv1a: 0, \ - testarrayofbools: None, testf: 3.14159, testf2: 3.00000, testf3: 0.00000, \ - testarrayofstring2: None, testarrayofsortedstruct: None, flex: None, \ - test5: None, vector_of_longs: None, vector_of_doubles: None, \ + test1: 3.00000, test2: Color(Green), test3: Test { a: 5, b: 6 } \ + }), mana: 150, hp: 80, name: \"MyMonster\", inventory: Some([0, 1, \ + 2, 3, 4]), color: Color(Blue), test_type: Monster, test: Monster { \ + pos: None, mana: 150, hp: 100, name: \"Fred\", inventory: None, \ + color: Color(Blue), test_type: NONE, test: None, test4: None, \ + testarrayofstring: None, testarrayoftables: None, enemy: None, \ + testnestedflatbuffer: None, testempty: None, testbool: false, \ + testhashs32_fnv1: 0, testhashu32_fnv1: 0, testhashs64_fnv1: 0, \ + testhashu64_fnv1: 0, testhashs32_fnv1a: 0, testhashu32_fnv1a: 0, \ + testhashs64_fnv1a: 0, testhashu64_fnv1a: 0, testarrayofbools: \ + None, testf: 3.14159, testf2: 3.00000, testf3: 0.00000, \ + testarrayofstring2: None, testarrayofsortedstruct: None, flex: \ + None, test5: None, vector_of_longs: None, vector_of_doubles: None, \ parent_namespace_test: None, vector_of_referrables: None, \ single_weak_reference: 0, vector_of_weak_references: None, \ vector_of_strong_referrables: None, co_owning_reference: 0, \ @@ -1787,22 +1787,22 @@ mod write_and_read_examples { vector_of_non_owning_references: None, any_unique_type: NONE, \ any_unique: None, any_ambiguous_type: NONE, any_ambiguous: None, \ vector_of_enums: None, signed_enum: None, \ - testrequirednestedflatbuffer: None, scalar_key_sorted_tables: None, \ - native_inline: None, long_enum_non_enum_default: (empty), \ - long_enum_normal_default: LongOne, nan_default: NaN, inf_default: \ - inf, positive_inf_default: inf, infinity_default: inf, \ - positive_infinity_default: inf, negative_inf_default: -inf, \ - negative_infinity_default: -inf, double_inf_default: inf }, \ - test4: Some([Test { a: 10, b: 20 }, Test { a: 30, b: 40 }]), \ - testarrayofstring: Some([\"test1\", \"test2\"]), \ - testarrayoftables: None, enemy: None, testnestedflatbuffer: None, \ - testempty: None, testbool: false, testhashs32_fnv1: 0, \ - testhashu32_fnv1: 0, testhashs64_fnv1: 0, testhashu64_fnv1: 0, \ - testhashs32_fnv1a: 0, testhashu32_fnv1a: 0, testhashs64_fnv1a: 0, \ - testhashu64_fnv1a: 0, testarrayofbools: None, testf: 3.14159, \ - testf2: 3.00000, testf3: 0.00000, testarrayofstring2: None, \ - testarrayofsortedstruct: None, flex: None, test5: None, \ - vector_of_longs: None, vector_of_doubles: None, \ + testrequirednestedflatbuffer: None, scalar_key_sorted_tables: \ + None, native_inline: None, long_enum_non_enum_default: \ + LongEnum(0x0), long_enum_normal_default: LongEnum(LongOne), \ + nan_default: NaN, inf_default: inf, positive_inf_default: inf, \ + infinity_default: inf, positive_infinity_default: inf, \ + negative_inf_default: -inf, negative_infinity_default: -inf, \ + double_inf_default: inf }, test4: Some([Test { a: 10, b: 20 }, \ + Test { a: 30, b: 40 }]), testarrayofstring: Some([\"test1\", \ + \"test2\"]), testarrayoftables: None, enemy: None, \ + testnestedflatbuffer: None, testempty: None, testbool: false, \ + testhashs32_fnv1: 0, testhashu32_fnv1: 0, testhashs64_fnv1: 0, \ + testhashu64_fnv1: 0, testhashs32_fnv1a: 0, testhashu32_fnv1a: 0, \ + testhashs64_fnv1a: 0, testhashu64_fnv1a: 0, testarrayofbools: \ + None, testf: 3.14159, testf2: 3.00000, testf3: 0.00000, \ + testarrayofstring2: None, testarrayofsortedstruct: None, flex: \ + None, test5: None, vector_of_longs: None, vector_of_doubles: None, \ parent_namespace_test: None, vector_of_referrables: None, \ single_weak_reference: 0, vector_of_weak_references: None, \ vector_of_strong_referrables: None, co_owning_reference: 0, \ @@ -1810,12 +1810,13 @@ mod write_and_read_examples { vector_of_non_owning_references: None, any_unique_type: NONE, \ any_unique: None, any_ambiguous_type: NONE, any_ambiguous: None, \ vector_of_enums: None, signed_enum: None, \ - testrequirednestedflatbuffer: None, scalar_key_sorted_tables: None, \ - native_inline: None, long_enum_non_enum_default: (empty), \ - long_enum_normal_default: LongOne, nan_default: NaN, inf_default: \ - inf, positive_inf_default: inf, infinity_default: inf, \ - positive_infinity_default: inf, negative_inf_default: -inf, \ - negative_infinity_default: -inf, double_inf_default: inf }" + testrequirednestedflatbuffer: None, scalar_key_sorted_tables: \ + None, native_inline: None, long_enum_non_enum_default: \ + LongEnum(0x0), long_enum_normal_default: LongEnum(LongOne), \ + nan_default: NaN, inf_default: inf, positive_inf_default: inf, \ + infinity_default: inf, positive_infinity_default: inf, \ + negative_inf_default: -inf, negative_infinity_default: -inf, \ + double_inf_default: inf }" ); } From 76bf7359aadf7699605dab161d154c657c99640f Mon Sep 17 00:00:00 2001 From: Marcin Radomski Date: Mon, 3 Feb 2025 20:37:34 +0100 Subject: [PATCH 11/11] Fix tests build on Swift 5.8 grpc-swift 1.4.1 depends on swift-nio-ssl 2.14.0+ [1]. swift-nio-ssl 2.29.1 published on 2025-01-30, introduced some code [2] that uses a "switch expression syntax" supported since Swift 5.9 [3]. Attempts to compile it with Swift 5.8 cause build errors. swift-nio-ssl project doesn't seem to support Swift 5.8. A commit from 2024-10-29 removes a "deprecated reference to a Swift 5.8 pipeline" [4]. swift-nio-ssl 2.29.0 is the last version that can be compiled with Swift 5.8. This commit pins it to that exact version. [1] https://github.com/grpc/grpc-swift/blob/66e27d7e84a2f51df6b8d5c4c3649639cfe478c1/Package.swift#L33 [2] https://github.com/apple/swift-nio-ssl/commit/3cb4d5ad12723b87f29d7031de902280f7084c81#diff-bc1db1321ff689c2819245dcce1a3080554f0fc13f81b8d326c97e7d42717c8fR54 [3] https://github.com/swiftlang/swift-evolution/blob/main/proposals/0380-if-switch-expressions.md [4] https://github.com/apple/swift-nio-ssl/commit/8a6b89d9a4079207dfdfb5c54e14f4d27301c306 --- tests/swift/tests/Package.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/swift/tests/Package.swift b/tests/swift/tests/Package.swift index c9a621e640e..723d4fc7270 100644 --- a/tests/swift/tests/Package.swift +++ b/tests/swift/tests/Package.swift @@ -26,6 +26,10 @@ let package = Package( dependencies: [ .package(path: "../../.."), .package(url: "https://github.com/grpc/grpc-swift.git", from: "1.4.1"), + // Prevent the build system from pulling 2.29.1 to prevent Swift 5.8 build breaks. + // The patch update introduced code that uses "switch expression syntax" that wasn't valid until Swift 5.9 [1]. + // [1] https://github.com/swiftlang/swift-evolution/blob/main/proposals/0380-if-switch-expressions.md + .package(url: "https://github.com/apple/swift-nio-ssl.git", exact: "2.29.0"), ], targets: [ .executableTarget(