├── .github └── workflows │ └── CI.yaml ├── .gitignore ├── Cargo.toml ├── LICENSE ├── README.md ├── about.hbs ├── about.toml ├── build.rs ├── rust ├── benches │ └── void.rs ├── examples │ └── simple.rs ├── gen_flatbuffers │ ├── mod.rs │ ├── sig_bin │ │ ├── basic_block_generated.rs │ │ ├── data_generated.rs │ │ ├── function_constraint_generated.rs │ │ ├── function_constraints_generated.rs │ │ └── function_generated.rs │ ├── symbol_bin │ │ ├── data_symbol_class_generated.rs │ │ ├── function_symbol_class_generated.rs │ │ ├── symbol_class_generated.rs │ │ ├── symbol_generated.rs │ │ └── symbol_modifiers_generated.rs │ └── type_bin │ │ ├── access_alignment_generated.rs │ │ ├── array_generated.rs │ │ ├── array_modifiers_generated.rs │ │ ├── bit_offset_generated.rs │ │ ├── bit_shift_generated.rs │ │ ├── bit_size_generated.rs │ │ ├── bit_width_generated.rs │ │ ├── boolean_generated.rs │ │ ├── calling_convention_generated.rs │ │ ├── character_generated.rs │ │ ├── computed_type_generated.rs │ │ ├── constant_modifier_class_generated.rs │ │ ├── data_generated.rs │ │ ├── descriptor_modifier_class_generated.rs │ │ ├── enumeration_generated.rs │ │ ├── enumeration_member_generated.rs │ │ ├── fixed_alignment_generated.rs │ │ ├── float_generated.rs │ │ ├── function_generated.rs │ │ ├── function_member_generated.rs │ │ ├── function_member_location_generated.rs │ │ ├── integer_generated.rs │ │ ├── location_class_generated.rs │ │ ├── metadata_modifier_class_generated.rs │ │ ├── pointer_addressing_generated.rs │ │ ├── pointer_generated.rs │ │ ├── referrer_generated.rs │ │ ├── register_location_generated.rs │ │ ├── stack_location_generated.rs │ │ ├── structure_generated.rs │ │ ├── structure_member_generated.rs │ │ ├── structure_member_modifiers_generated.rs │ │ ├── type_alignment_generated.rs │ │ ├── type_class_generated.rs │ │ ├── type_generated.rs │ │ ├── type_modifier_class_generated.rs │ │ ├── type_modifier_generated.rs │ │ ├── union_generated.rs │ │ ├── union_member_generated.rs │ │ ├── unsigned_bit_offset_generated.rs │ │ ├── void_generated.rs │ │ └── volatile_modifier_class_generated.rs ├── lib.rs ├── signature.rs ├── signature │ ├── basic_block.rs │ ├── function.rs │ └── function │ │ └── constraints.rs ├── symbol.rs ├── symbol │ └── class.rs ├── type.rs └── type │ ├── class.rs │ ├── class │ ├── array.rs │ ├── boolean.rs │ ├── character.rs │ ├── enumeration.rs │ ├── float.rs │ ├── function.rs │ ├── integer.rs │ ├── pointer.rs │ ├── referrer.rs │ ├── structure.rs │ ├── union.rs │ └── void.rs │ ├── guid.rs │ └── modifier.rs ├── signature.fbs ├── sigview ├── Cargo.toml └── src │ ├── graph.rs │ └── main.rs ├── symbol.fbs └── type.fbs /.github/workflows/CI.yaml: -------------------------------------------------------------------------------- 1 | name: "CI" 2 | on: 3 | push: 4 | pull_request: 5 | 6 | jobs: 7 | test: 8 | name: cargo test 9 | runs-on: ${{ matrix.os }} 10 | strategy: 11 | matrix: 12 | os: [ ubuntu-latest, windows-latest, macos-latest ] 13 | steps: 14 | - uses: actions/checkout@v4 15 | - uses: actions-rust-lang/setup-rust-toolchain@v1 16 | - run: cargo test 17 | 18 | # Check formatting with rustfmt 19 | formatting: 20 | name: cargo fmt 21 | runs-on: ubuntu-latest 22 | steps: 23 | - uses: actions/checkout@v4 24 | # Ensure rustfmt is installed and setup problem matcher 25 | - uses: actions-rust-lang/setup-rust-toolchain@v1 26 | with: 27 | components: rustfmt 28 | - name: Rustfmt Check 29 | uses: actions-rust-lang/rustfmt@v1 30 | 31 | # Check licensing and produce a list of licenses 32 | licensing: 33 | runs-on: ubuntu-latest 34 | steps: 35 | - uses: actions/checkout@v4 36 | - name: Install cargo-about 37 | uses: baptiste0928/cargo-install@v3 38 | with: 39 | crate: cargo-about 40 | version: "0.6.4" 41 | - name: Run license check 42 | run: cargo about generate about.hbs > license.html 43 | - name: Archive license file 44 | uses: actions/upload-artifact@v4 45 | with: 46 | name: license 47 | path: license.html -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and dependencies 2 | /target/ 3 | **/target/ 4 | 5 | # Remove Cargo.lock from gitignore if it's already checked in 6 | Cargo.lock 7 | 8 | # Best practice for something like this, the python scripts are not meant to be "deployed" from this repo state. 9 | poetry.lock 10 | 11 | # These are backup files generated by rustfmt 12 | **/*.rs.bk 13 | 14 | # Temporary files generated by editors 15 | *~ 16 | *.swp 17 | *.swo 18 | 19 | # IntelliJ and CLion directories 20 | .idea/ 21 | *.iml 22 | *.iws 23 | *.ipr 24 | 25 | # MacOS specific ignores 26 | .DS_Store 27 | ._* 28 | 29 | # Rust documentations 30 | /target/doc/ 31 | 32 | # Build files 33 | **/build/ 34 | 35 | # Generated files and directories 36 | generated/ 37 | 38 | # Node.js directories (if any) 39 | /node_modules/ 40 | 41 | # Logs 42 | *.log 43 | 44 | # Output directories 45 | *.out 46 | *.log.* 47 | 48 | **/[Tt]humbs.db 49 | **/[Dd]esktop.ini 50 | 51 | **/ubuntu 52 | **/downloads 53 | **/msvc 54 | **/windows 55 | 56 | **/out 57 | 58 | *.vsix 59 | *.deb -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "warp" 3 | version = "0.1.0" 4 | edition = "2021" 5 | license = "Apache-2.0" 6 | 7 | [lib] 8 | path = "rust/lib.rs" 9 | 10 | [dependencies] 11 | flatbuffers = "24.3.25" 12 | bon = "2.3.0" 13 | uuid = { version = "1.11.0", features = ["v5"]} 14 | rand = "0.8.5" 15 | flate2 = "1.0.34" 16 | 17 | [features] 18 | default = [] 19 | gen_flatbuffers = ["dep:flatbuffers-build"] 20 | 21 | [dev-dependencies] 22 | criterion = "0.5.1" 23 | 24 | [build-dependencies] 25 | flatbuffers-build = { git = "https://github.com/emesare/flatbuffers-build", features = ["vendored"], optional = true } 26 | 27 | [profile.release] 28 | panic = "abort" 29 | lto = true 30 | debug = "full" 31 | 32 | [profile.bench] 33 | lto = true 34 | 35 | [[example]] 36 | name = "simple" 37 | path = "rust/examples/simple.rs" 38 | 39 | [[bench]] 40 | name = "void" 41 | path = "rust/benches/void.rs" 42 | harness = false -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020-2024 Vector 35 Inc. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WARP 2 | 3 | **WARP** provides a common format for transferring and applying function information across binary analysis tools. 4 | 5 | ## WARP Integrations 6 | 7 | ### Binary Ninja 8 | 9 | WARP integration is available as an [open source](https://github.com/Vector35/binaryninja-api/tree/dev/plugins/warp) first-party plugin for [Binary Ninja] and as such ships by default. 10 | 11 | ## Function Identification 12 | 13 | Function identification is the main way to interact with **WARP**, allowing tooling to utilize **WARP**'s dataset to identify 14 | common functions within any binary efficiently and accurately. 15 | 16 | ### Integration Requirements 17 | 18 | To integrate with **WARP** function matching you must be able to: 19 | 20 | 1. Disassemble instructions 21 | 2. Identify basic blocks that make up a function 22 | 3. Identify register groups with implicit extend operation 23 | 4. Identify relocatable instructions (see [What is considered a relocatable operand?](#what-is-considered-a-relocatable-operand)) 24 | 25 | ### Creating a Function GUID 26 | 27 | The function GUID is the UUIDv5 of the basic block GUID's (sorted highest to lowest start address) that make up the function. 28 | 29 | #### Example 30 | 31 | Given the following sorted basic blocks: 32 | 33 | 1. `036cccf0-8239-5b84-a811-60efc2d7eeb0` 34 | 2. `3ed5c023-658d-5511-9710-40814f31af50` 35 | 3. `8a076c92-0ba0-540d-b724-7fd5838da9df` 36 | 37 | The function GUID will be `7a55be03-76b7-5cb5-bae9-4edcf47795ac`. 38 | 39 | ##### Example Code 40 | 41 | ```py 42 | import uuid 43 | 44 | def uuid5(namespace, name_bytes): 45 | """Generate a UUID from the SHA-1 hash of a namespace UUID and a name bytes.""" 46 | from hashlib import sha1 47 | hash = sha1(namespace.bytes + name_bytes).digest() 48 | return uuid.UUID(bytes=hash[:16], version=5) 49 | 50 | function_namespace = uuid.UUID('0192a179-61ac-7cef-88ed-012296e9492f') 51 | bb1 = uuid.UUID("036cccf0-8239-5b84-a811-60efc2d7eeb0") 52 | bb2 = uuid.UUID("3ed5c023-658d-5511-9710-40814f31af50") 53 | bb3 = uuid.UUID("8a076c92-0ba0-540d-b724-7fd5838da9df") 54 | function = uuid5(function_namespace, bb1.bytes + bb2.bytes + bb3.bytes) 55 | ``` 56 | 57 | #### What is the UUIDv5 namespace? 58 | 59 | The namespace for Function GUID's is `0192a179-61ac-7cef-88ed-012296e9492f`. 60 | 61 | ### Creating a Basic Block GUID 62 | 63 | The basic block GUID is the UUIDv5 of the byte sequence of the instructions (sorted in execution order) with the following properties: 64 | 65 | 1. Zero out all instructions containing a relocatable operand. 66 | 2. Exclude all NOP instructions. 67 | 3. Exclude all instructions that set a register to itself if they are effectively NOPs. 68 | 69 | #### When are instructions that set a register to itself removed? 70 | 71 | To support hot-patching we must remove them as they can be injected by the compiler at the start of a function (see: [1] and [2]). 72 | This does not affect the accuracy of the function GUID as they are only removed when the instruction is a NOP: 73 | 74 | - Register groups with no implicit extension will be removed (see: [3] (under 3.4.1.1)) 75 | 76 | For the `x86_64` architecture this means `mov edi, edi` will _not_ be removed, but it _will_ be removed for the `x86` architecture. 77 | 78 | #### What is considered a relocatable operand? 79 | 80 | An operand that is used as a pointer to a mapped region. 81 | 82 | For the `x86` architecture the instruction `e8b55b0100` (or `call 0x15bba`) would be zeroed. 83 | 84 | #### What is the UUIDv5 namespace? 85 | 86 | The namespace for Basic Block GUID's is `0192a178-7a5f-7936-8653-3cbaa7d6afe7`. 87 | 88 | ### Function Constraints 89 | 90 | Function constraints allow us to further disambiguate between functions with the same GUID, when creating the functions we store information about the following: 91 | 92 | - Called functions 93 | - Caller functions 94 | - Adjacent functions 95 | 96 | Each entry in the lists above is referred to as a "constraint" that can be used to further reduce the number of matches for a given function GUID. 97 | 98 | ##### Why don't we require matching on constraints for trivial functions? 99 | 100 | The decision to match on constraints is left to the user. While requiring constraint matching for functions 101 | from all datasets can reduce false positives, it may not always be necessary. For example, when transferring functions 102 | from one version of a binary to another version of the same binary, not matching on constraints for trivial functions 103 | might be acceptable. 104 | 105 | ## Comparison of Function Recognition Tools 106 | 107 | ### WARP vs FLIRT 108 | 109 | The main difference between **WARP** and **FLIRT** is the approach to identification. 110 | 111 | #### Function Identification 112 | 113 | - **WARP** the function identification is described [here](#function-identification). 114 | - **FLIRT** uses incomplete function byte sequence with a mask where there is a single function entry (see: [IDA FLIRT Documentation] for a full description). 115 | 116 | What this means in practice is **WARP** will have less false positives based solely off the initial function identification. 117 | When the returned set of functions is greater than one, we can use the list of [Function Constraints](#function-constraints) to select the best possible match. 118 | However, that comes at the cost of requiring a computed GUID to be created whenever the lookup is requested and that the function GUID is _**always**_ the same. 119 | 120 | 121 | [1]: https://devblogs.microsoft.com/oldnewthing/20110921-00/?p=9583 122 | [2]: https://devblogs.microsoft.com/oldnewthing/20221109-00/?p=107373 123 | [3]: https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-vol-1-manual.pdf 124 | [IDA FLIRT Documentation]: https://docs.hex-rays.com/user-guide/signatures/flirt/ida-f.l.i.r.t.-technology-in-depth 125 | [Binary Ninja]: https://binary.ninja 126 | [Binary Ninja Integration]: https://github.com/Vector35/binaryninja-api/tree/dev/plugins/warp -------------------------------------------------------------------------------- /about.hbs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 37 | Third Party Licenses 38 | 39 | 40 | 41 |
42 |
43 |

Third Party Licenses

44 |

This page lists the licenses of the projects used in warp.

45 |
46 | 47 |

Overview of licenses:

48 | 53 | 54 |

All license text:

55 | 69 |
70 | 71 | 72 | -------------------------------------------------------------------------------- /about.toml: -------------------------------------------------------------------------------- 1 | # Used in conjuction with `cargo-about` to generate a list of licenses. 2 | accepted = [ 3 | "Apache-2.0", 4 | "MIT", 5 | "Unicode-DFS-2016", 6 | "OFL-1.1", 7 | "BSL-1.0", 8 | "BSD-3-Clause", 9 | "BSD-2-Clause", 10 | "LicenseRef-UFL-1.0", 11 | "NOASSERTION", 12 | "ISC", 13 | "Zlib", 14 | "OpenSSL" 15 | ] -------------------------------------------------------------------------------- /build.rs: -------------------------------------------------------------------------------- 1 | #[cfg(not(feature = "gen_flatbuffers"))] 2 | pub fn main() {} 3 | 4 | #[cfg(feature = "gen_flatbuffers")] 5 | pub fn main() { 6 | use flatbuffers_build::BuilderOptions; 7 | use std::path::PathBuf; 8 | 9 | // Remove leftover symlink dir. 10 | let _ = std::fs::remove_dir_all("rust/gen_flatbuffers"); 11 | let workspace_dir: PathBuf = std::env::var("CARGO_MANIFEST_DIR").unwrap().into(); 12 | BuilderOptions::new_with_files([ 13 | workspace_dir.join("type.fbs"), 14 | workspace_dir.join("symbol.fbs"), 15 | workspace_dir.join("signature.fbs"), 16 | ]) 17 | .set_output_path("rust/gen_flatbuffers") 18 | .compile() 19 | .expect("flatbuffer compilation failed"); 20 | } 21 | -------------------------------------------------------------------------------- /rust/benches/void.rs: -------------------------------------------------------------------------------- 1 | use criterion::{criterion_group, criterion_main, Criterion}; 2 | use warp::r#type::class::TypeClass; 3 | use warp::r#type::guid::TypeGUID; 4 | use warp::r#type::Type; 5 | 6 | pub fn void_benchmark(c: &mut Criterion) { 7 | let void_type = Type::builder() 8 | .name("my_void".to_owned()) 9 | .class(TypeClass::Void) 10 | .build(); 11 | 12 | c.bench_function("uuid void", |b| { 13 | b.iter(|| { 14 | let _ = TypeGUID::from(&void_type); 15 | }) 16 | }); 17 | 18 | c.bench_function("computed void", |b| b.iter(|| void_type.to_bytes())); 19 | } 20 | 21 | criterion_group!(benches, void_benchmark); 22 | criterion_main!(benches); 23 | -------------------------------------------------------------------------------- /rust/examples/simple.rs: -------------------------------------------------------------------------------- 1 | use warp::r#type::class::{ 2 | ArrayClass, BooleanClass, EnumerationClass, EnumerationMember, FunctionClass, FunctionMember, 3 | IntegerClass, PointerClass, StructureClass, StructureMember, TypeClass, UnionClass, 4 | UnionMember, 5 | }; 6 | use warp::r#type::Type; 7 | 8 | fn main() { 9 | let void_type = Type::builder() 10 | .name("my_void".to_owned()) 11 | .class(TypeClass::Void) 12 | .build(); 13 | dbg!(&void_type); 14 | 15 | let bool_class = BooleanClass::builder().width(8).build(); 16 | let bool_type = Type::builder() 17 | .name("my_bool".to_owned()) 18 | .class(bool_class) 19 | .build(); 20 | dbg!(&bool_type); 21 | 22 | let int_class = IntegerClass::builder().width(8).signed(false).build(); 23 | let int_type = Type::builder() 24 | .name("my_int".to_owned()) 25 | .class(int_class) 26 | .build(); 27 | dbg!(&int_type); 28 | 29 | let ptr_class = PointerClass::builder() 30 | .width(8) 31 | .child_type(void_type.clone()) 32 | .build(); 33 | let ptr_type = Type::builder() 34 | .name("my_ptr".to_owned()) 35 | .class(ptr_class) 36 | .build(); 37 | dbg!(&ptr_type); 38 | 39 | let array_class = ArrayClass::builder() 40 | .length(4) 41 | .member_type(void_type.clone()) 42 | .build(); 43 | let array_type = Type::builder() 44 | .name("my_array".to_owned()) 45 | .class(array_class) 46 | .build(); 47 | dbg!(&array_type); 48 | 49 | let enum_class = EnumerationClass::new( 50 | int_type.clone(), 51 | vec![ 52 | EnumerationMember::builder().name("one").constant(1).build(), 53 | EnumerationMember::builder().name("two").constant(2).build(), 54 | EnumerationMember::builder() 55 | .name("five") 56 | .constant(5) 57 | .build(), 58 | EnumerationMember::builder().constant(6).build(), 59 | ], 60 | ); 61 | let enum_type = Type::builder() 62 | .name("my_enum".to_owned()) 63 | .class(enum_class) 64 | .build(); 65 | dbg!(&enum_type); 66 | 67 | let union_class = UnionClass::new(vec![ 68 | UnionMember::new("int".to_owned(), int_type.clone()), 69 | UnionMember::new("bool".to_owned(), bool_type.clone()), 70 | UnionMember::new("ptr".to_owned(), ptr_type.clone()), 71 | UnionMember::new("enum".to_owned(), enum_type.clone()), 72 | UnionMember::new("array".to_owned(), array_type.clone()), 73 | ]); 74 | let union_type = Type::builder() 75 | .name("my_union".to_owned()) 76 | .class(union_class) 77 | .build(); 78 | dbg!(&union_type); 79 | 80 | let struct_class = StructureClass::new(vec![ 81 | StructureMember::builder() 82 | .name("int") 83 | .ty(int_type.clone()) 84 | .offset(0) 85 | .build(), 86 | StructureMember::builder() 87 | .name("bool") 88 | .ty(bool_type.clone()) 89 | .offset(64) 90 | .build(), 91 | StructureMember::builder() 92 | .name("pointer") 93 | .ty(ptr_type.clone()) 94 | .offset(72) 95 | .build(), 96 | StructureMember::builder() 97 | .name("enum") 98 | .ty(enum_type.clone()) 99 | .offset(136) 100 | .build(), 101 | StructureMember::builder() 102 | .name("array") 103 | .ty(array_type.clone()) 104 | .offset(200) 105 | .build(), 106 | ]); 107 | let struct_type = Type::builder() 108 | .name("my_struct".to_owned()) 109 | .class(struct_class) 110 | .build(); 111 | dbg!(&struct_type); 112 | 113 | let func_class = FunctionClass::new( 114 | None, 115 | vec![ 116 | FunctionMember::builder() 117 | .name("param_0") 118 | .ty(int_type.clone()) 119 | .build(), 120 | FunctionMember::builder() 121 | .name("param_1") 122 | .ty(bool_type.clone()) 123 | .build(), 124 | ], 125 | vec![], 126 | ); 127 | let func_type = Type::builder() 128 | .name("my_func".to_owned()) 129 | .class(func_class) 130 | .build(); 131 | dbg!(&func_type); 132 | } 133 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/mod.rs: -------------------------------------------------------------------------------- 1 | // Automatically generated by the Flatbuffers compiler. Do not modify. 2 | // @generated 3 | pub mod sig_bin { 4 | use super::*; 5 | mod basic_block_generated; 6 | pub use self::basic_block_generated::*; 7 | mod function_constraint_generated; 8 | pub use self::function_constraint_generated::*; 9 | mod function_constraints_generated; 10 | pub use self::function_constraints_generated::*; 11 | mod function_generated; 12 | pub use self::function_generated::*; 13 | mod data_generated; 14 | pub use self::data_generated::*; 15 | } // sig_bin 16 | pub mod symbol_bin { 17 | use super::*; 18 | mod symbol_class_generated; 19 | pub use self::symbol_class_generated::*; 20 | mod symbol_modifiers_generated; 21 | pub use self::symbol_modifiers_generated::*; 22 | mod function_symbol_class_generated; 23 | pub use self::function_symbol_class_generated::*; 24 | mod data_symbol_class_generated; 25 | pub use self::data_symbol_class_generated::*; 26 | mod symbol_generated; 27 | pub use self::symbol_generated::*; 28 | } // symbol_bin 29 | pub mod type_bin { 30 | use super::*; 31 | mod type_modifier_class_generated; 32 | pub use self::type_modifier_class_generated::*; 33 | mod type_alignment_generated; 34 | pub use self::type_alignment_generated::*; 35 | mod pointer_addressing_generated; 36 | pub use self::pointer_addressing_generated::*; 37 | mod array_modifiers_generated; 38 | pub use self::array_modifiers_generated::*; 39 | mod structure_member_modifiers_generated; 40 | pub use self::structure_member_modifiers_generated::*; 41 | mod location_class_generated; 42 | pub use self::location_class_generated::*; 43 | mod type_class_generated; 44 | pub use self::type_class_generated::*; 45 | mod unsigned_bit_offset_generated; 46 | pub use self::unsigned_bit_offset_generated::*; 47 | mod bit_offset_generated; 48 | pub use self::bit_offset_generated::*; 49 | mod bit_shift_generated; 50 | pub use self::bit_shift_generated::*; 51 | mod bit_size_generated; 52 | pub use self::bit_size_generated::*; 53 | mod bit_width_generated; 54 | pub use self::bit_width_generated::*; 55 | mod constant_modifier_class_generated; 56 | pub use self::constant_modifier_class_generated::*; 57 | mod volatile_modifier_class_generated; 58 | pub use self::volatile_modifier_class_generated::*; 59 | mod descriptor_modifier_class_generated; 60 | pub use self::descriptor_modifier_class_generated::*; 61 | mod metadata_modifier_class_generated; 62 | pub use self::metadata_modifier_class_generated::*; 63 | mod type_modifier_generated; 64 | pub use self::type_modifier_generated::*; 65 | mod access_alignment_generated; 66 | pub use self::access_alignment_generated::*; 67 | mod fixed_alignment_generated; 68 | pub use self::fixed_alignment_generated::*; 69 | mod void_generated; 70 | pub use self::void_generated::*; 71 | mod boolean_generated; 72 | pub use self::boolean_generated::*; 73 | mod float_generated; 74 | pub use self::float_generated::*; 75 | mod character_generated; 76 | pub use self::character_generated::*; 77 | mod integer_generated; 78 | pub use self::integer_generated::*; 79 | mod pointer_generated; 80 | pub use self::pointer_generated::*; 81 | mod array_generated; 82 | pub use self::array_generated::*; 83 | mod structure_member_generated; 84 | pub use self::structure_member_generated::*; 85 | mod structure_generated; 86 | pub use self::structure_generated::*; 87 | mod enumeration_member_generated; 88 | pub use self::enumeration_member_generated::*; 89 | mod enumeration_generated; 90 | pub use self::enumeration_generated::*; 91 | mod union_member_generated; 92 | pub use self::union_member_generated::*; 93 | mod union_generated; 94 | pub use self::union_generated::*; 95 | mod calling_convention_generated; 96 | pub use self::calling_convention_generated::*; 97 | mod register_location_generated; 98 | pub use self::register_location_generated::*; 99 | mod stack_location_generated; 100 | pub use self::stack_location_generated::*; 101 | mod function_member_location_generated; 102 | pub use self::function_member_location_generated::*; 103 | mod function_member_generated; 104 | pub use self::function_member_generated::*; 105 | mod function_generated; 106 | pub use self::function_generated::*; 107 | mod referrer_generated; 108 | pub use self::referrer_generated::*; 109 | mod type_generated; 110 | pub use self::type_generated::*; 111 | mod computed_type_generated; 112 | pub use self::computed_type_generated::*; 113 | mod data_generated; 114 | pub use self::data_generated::*; 115 | } // type_bin 116 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/sig_bin/basic_block_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum BasicBlockOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct BasicBlock<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for BasicBlock<'a> { 20 | type Inner = BasicBlock<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> BasicBlock<'a> { 28 | pub const VT_GUID: flatbuffers::VOffsetT = 4; 29 | 30 | #[inline] 31 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 32 | BasicBlock { _tab: table } 33 | } 34 | #[allow(unused_mut)] 35 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 36 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 37 | args: &'args BasicBlockArgs<'args> 38 | ) -> flatbuffers::WIPOffset> { 39 | let mut builder = BasicBlockBuilder::new(_fbb); 40 | if let Some(x) = args.guid { builder.add_guid(x); } 41 | builder.finish() 42 | } 43 | 44 | 45 | #[inline] 46 | pub fn guid(&self) -> &'a str { 47 | // Safety: 48 | // Created from valid Table for this object 49 | // which contains a valid value in this slot 50 | unsafe { self._tab.get::>(BasicBlock::VT_GUID, None).unwrap()} 51 | } 52 | } 53 | 54 | impl flatbuffers::Verifiable for BasicBlock<'_> { 55 | #[inline] 56 | fn run_verifier( 57 | v: &mut flatbuffers::Verifier, pos: usize 58 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 59 | use self::flatbuffers::Verifiable; 60 | v.visit_table(pos)? 61 | .visit_field::>("guid", Self::VT_GUID, true)? 62 | .finish(); 63 | Ok(()) 64 | } 65 | } 66 | pub struct BasicBlockArgs<'a> { 67 | pub guid: Option>, 68 | } 69 | impl<'a> Default for BasicBlockArgs<'a> { 70 | #[inline] 71 | fn default() -> Self { 72 | BasicBlockArgs { 73 | guid: None, // required field 74 | } 75 | } 76 | } 77 | 78 | pub struct BasicBlockBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 79 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 80 | start_: flatbuffers::WIPOffset, 81 | } 82 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> BasicBlockBuilder<'a, 'b, A> { 83 | #[inline] 84 | pub fn add_guid(&mut self, guid: flatbuffers::WIPOffset<&'b str>) { 85 | self.fbb_.push_slot_always::>(BasicBlock::VT_GUID, guid); 86 | } 87 | #[inline] 88 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> BasicBlockBuilder<'a, 'b, A> { 89 | let start = _fbb.start_table(); 90 | BasicBlockBuilder { 91 | fbb_: _fbb, 92 | start_: start, 93 | } 94 | } 95 | #[inline] 96 | pub fn finish(self) -> flatbuffers::WIPOffset> { 97 | let o = self.fbb_.end_table(self.start_); 98 | self.fbb_.required(o, BasicBlock::VT_GUID,"guid"); 99 | flatbuffers::WIPOffset::new(o.value()) 100 | } 101 | } 102 | 103 | impl core::fmt::Debug for BasicBlock<'_> { 104 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 105 | let mut ds = f.debug_struct("BasicBlock"); 106 | ds.field("guid", &self.guid()); 107 | ds.finish() 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/sig_bin/function_constraint_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum FunctionConstraintOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct FunctionConstraint<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for FunctionConstraint<'a> { 20 | type Inner = FunctionConstraint<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> FunctionConstraint<'a> { 28 | pub const VT_GUID: flatbuffers::VOffsetT = 4; 29 | pub const VT_SYMBOL: flatbuffers::VOffsetT = 6; 30 | pub const VT_OFFSET: flatbuffers::VOffsetT = 8; 31 | 32 | #[inline] 33 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 34 | FunctionConstraint { _tab: table } 35 | } 36 | #[allow(unused_mut)] 37 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 38 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 39 | args: &'args FunctionConstraintArgs<'args> 40 | ) -> flatbuffers::WIPOffset> { 41 | let mut builder = FunctionConstraintBuilder::new(_fbb); 42 | builder.add_offset(args.offset); 43 | if let Some(x) = args.symbol { builder.add_symbol(x); } 44 | if let Some(x) = args.guid { builder.add_guid(x); } 45 | builder.finish() 46 | } 47 | 48 | 49 | #[inline] 50 | pub fn guid(&self) -> Option<&'a str> { 51 | // Safety: 52 | // Created from valid Table for this object 53 | // which contains a valid value in this slot 54 | unsafe { self._tab.get::>(FunctionConstraint::VT_GUID, None)} 55 | } 56 | #[inline] 57 | pub fn symbol(&self) -> Option> { 58 | // Safety: 59 | // Created from valid Table for this object 60 | // which contains a valid value in this slot 61 | unsafe { self._tab.get::>(FunctionConstraint::VT_SYMBOL, None)} 62 | } 63 | #[inline] 64 | pub fn offset(&self) -> i64 { 65 | // Safety: 66 | // Created from valid Table for this object 67 | // which contains a valid value in this slot 68 | unsafe { self._tab.get::(FunctionConstraint::VT_OFFSET, Some(0)).unwrap()} 69 | } 70 | } 71 | 72 | impl flatbuffers::Verifiable for FunctionConstraint<'_> { 73 | #[inline] 74 | fn run_verifier( 75 | v: &mut flatbuffers::Verifier, pos: usize 76 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 77 | use self::flatbuffers::Verifiable; 78 | v.visit_table(pos)? 79 | .visit_field::>("guid", Self::VT_GUID, false)? 80 | .visit_field::>("symbol", Self::VT_SYMBOL, false)? 81 | .visit_field::("offset", Self::VT_OFFSET, false)? 82 | .finish(); 83 | Ok(()) 84 | } 85 | } 86 | pub struct FunctionConstraintArgs<'a> { 87 | pub guid: Option>, 88 | pub symbol: Option>>, 89 | pub offset: i64, 90 | } 91 | impl<'a> Default for FunctionConstraintArgs<'a> { 92 | #[inline] 93 | fn default() -> Self { 94 | FunctionConstraintArgs { 95 | guid: None, 96 | symbol: None, 97 | offset: 0, 98 | } 99 | } 100 | } 101 | 102 | pub struct FunctionConstraintBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 103 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 104 | start_: flatbuffers::WIPOffset, 105 | } 106 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> FunctionConstraintBuilder<'a, 'b, A> { 107 | #[inline] 108 | pub fn add_guid(&mut self, guid: flatbuffers::WIPOffset<&'b str>) { 109 | self.fbb_.push_slot_always::>(FunctionConstraint::VT_GUID, guid); 110 | } 111 | #[inline] 112 | pub fn add_symbol(&mut self, symbol: flatbuffers::WIPOffset>) { 113 | self.fbb_.push_slot_always::>(FunctionConstraint::VT_SYMBOL, symbol); 114 | } 115 | #[inline] 116 | pub fn add_offset(&mut self, offset: i64) { 117 | self.fbb_.push_slot::(FunctionConstraint::VT_OFFSET, offset, 0); 118 | } 119 | #[inline] 120 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> FunctionConstraintBuilder<'a, 'b, A> { 121 | let start = _fbb.start_table(); 122 | FunctionConstraintBuilder { 123 | fbb_: _fbb, 124 | start_: start, 125 | } 126 | } 127 | #[inline] 128 | pub fn finish(self) -> flatbuffers::WIPOffset> { 129 | let o = self.fbb_.end_table(self.start_); 130 | flatbuffers::WIPOffset::new(o.value()) 131 | } 132 | } 133 | 134 | impl core::fmt::Debug for FunctionConstraint<'_> { 135 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 136 | let mut ds = f.debug_struct("FunctionConstraint"); 137 | ds.field("guid", &self.guid()); 138 | ds.field("symbol", &self.symbol()); 139 | ds.field("offset", &self.offset()); 140 | ds.finish() 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/symbol_bin/data_symbol_class_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum DataSymbolClassOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct DataSymbolClass<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for DataSymbolClass<'a> { 20 | type Inner = DataSymbolClass<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> DataSymbolClass<'a> { 28 | 29 | #[inline] 30 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 31 | DataSymbolClass { _tab: table } 32 | } 33 | #[allow(unused_mut)] 34 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 35 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 36 | _args: &'args DataSymbolClassArgs 37 | ) -> flatbuffers::WIPOffset> { 38 | let mut builder = DataSymbolClassBuilder::new(_fbb); 39 | builder.finish() 40 | } 41 | 42 | } 43 | 44 | impl flatbuffers::Verifiable for DataSymbolClass<'_> { 45 | #[inline] 46 | fn run_verifier( 47 | v: &mut flatbuffers::Verifier, pos: usize 48 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 49 | use self::flatbuffers::Verifiable; 50 | v.visit_table(pos)? 51 | .finish(); 52 | Ok(()) 53 | } 54 | } 55 | pub struct DataSymbolClassArgs { 56 | } 57 | impl<'a> Default for DataSymbolClassArgs { 58 | #[inline] 59 | fn default() -> Self { 60 | DataSymbolClassArgs { 61 | } 62 | } 63 | } 64 | 65 | pub struct DataSymbolClassBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 66 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 67 | start_: flatbuffers::WIPOffset, 68 | } 69 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> DataSymbolClassBuilder<'a, 'b, A> { 70 | #[inline] 71 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> DataSymbolClassBuilder<'a, 'b, A> { 72 | let start = _fbb.start_table(); 73 | DataSymbolClassBuilder { 74 | fbb_: _fbb, 75 | start_: start, 76 | } 77 | } 78 | #[inline] 79 | pub fn finish(self) -> flatbuffers::WIPOffset> { 80 | let o = self.fbb_.end_table(self.start_); 81 | flatbuffers::WIPOffset::new(o.value()) 82 | } 83 | } 84 | 85 | impl core::fmt::Debug for DataSymbolClass<'_> { 86 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 87 | let mut ds = f.debug_struct("DataSymbolClass"); 88 | ds.finish() 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/symbol_bin/function_symbol_class_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum FunctionSymbolClassOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct FunctionSymbolClass<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for FunctionSymbolClass<'a> { 20 | type Inner = FunctionSymbolClass<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> FunctionSymbolClass<'a> { 28 | 29 | #[inline] 30 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 31 | FunctionSymbolClass { _tab: table } 32 | } 33 | #[allow(unused_mut)] 34 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 35 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 36 | _args: &'args FunctionSymbolClassArgs 37 | ) -> flatbuffers::WIPOffset> { 38 | let mut builder = FunctionSymbolClassBuilder::new(_fbb); 39 | builder.finish() 40 | } 41 | 42 | } 43 | 44 | impl flatbuffers::Verifiable for FunctionSymbolClass<'_> { 45 | #[inline] 46 | fn run_verifier( 47 | v: &mut flatbuffers::Verifier, pos: usize 48 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 49 | use self::flatbuffers::Verifiable; 50 | v.visit_table(pos)? 51 | .finish(); 52 | Ok(()) 53 | } 54 | } 55 | pub struct FunctionSymbolClassArgs { 56 | } 57 | impl<'a> Default for FunctionSymbolClassArgs { 58 | #[inline] 59 | fn default() -> Self { 60 | FunctionSymbolClassArgs { 61 | } 62 | } 63 | } 64 | 65 | pub struct FunctionSymbolClassBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 66 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 67 | start_: flatbuffers::WIPOffset, 68 | } 69 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> FunctionSymbolClassBuilder<'a, 'b, A> { 70 | #[inline] 71 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> FunctionSymbolClassBuilder<'a, 'b, A> { 72 | let start = _fbb.start_table(); 73 | FunctionSymbolClassBuilder { 74 | fbb_: _fbb, 75 | start_: start, 76 | } 77 | } 78 | #[inline] 79 | pub fn finish(self) -> flatbuffers::WIPOffset> { 80 | let o = self.fbb_.end_table(self.start_); 81 | flatbuffers::WIPOffset::new(o.value()) 82 | } 83 | } 84 | 85 | impl core::fmt::Debug for FunctionSymbolClass<'_> { 86 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 87 | let mut ds = f.debug_struct("FunctionSymbolClass"); 88 | ds.finish() 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/symbol_bin/symbol_class_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 13 | pub const ENUM_MIN_SYMBOL_CLASS: u8 = 0; 14 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 15 | pub const ENUM_MAX_SYMBOL_CLASS: u8 = 2; 16 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 17 | #[allow(non_camel_case_types)] 18 | pub const ENUM_VALUES_SYMBOL_CLASS: [SymbolClass; 3] = [ 19 | SymbolClass::NONE, 20 | SymbolClass::FunctionSymbolClass, 21 | SymbolClass::DataSymbolClass, 22 | ]; 23 | 24 | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] 25 | #[repr(transparent)] 26 | pub struct SymbolClass(pub u8); 27 | #[allow(non_upper_case_globals)] 28 | impl SymbolClass { 29 | pub const NONE: Self = Self(0); 30 | pub const FunctionSymbolClass: Self = Self(1); 31 | pub const DataSymbolClass: Self = Self(2); 32 | 33 | pub const ENUM_MIN: u8 = 0; 34 | pub const ENUM_MAX: u8 = 2; 35 | pub const ENUM_VALUES: &'static [Self] = &[ 36 | Self::NONE, 37 | Self::FunctionSymbolClass, 38 | Self::DataSymbolClass, 39 | ]; 40 | /// Returns the variant's name or "" if unknown. 41 | pub fn variant_name(self) -> Option<&'static str> { 42 | match self { 43 | Self::NONE => Some("NONE"), 44 | Self::FunctionSymbolClass => Some("FunctionSymbolClass"), 45 | Self::DataSymbolClass => Some("DataSymbolClass"), 46 | _ => None, 47 | } 48 | } 49 | } 50 | impl core::fmt::Debug for SymbolClass { 51 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 52 | if let Some(name) = self.variant_name() { 53 | f.write_str(name) 54 | } else { 55 | f.write_fmt(format_args!("", self.0)) 56 | } 57 | } 58 | } 59 | impl<'a> flatbuffers::Follow<'a> for SymbolClass { 60 | type Inner = Self; 61 | #[inline] 62 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 63 | let b = flatbuffers::read_scalar_at::(buf, loc); 64 | Self(b) 65 | } 66 | } 67 | 68 | impl flatbuffers::Push for SymbolClass { 69 | type Output = SymbolClass; 70 | #[inline] 71 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 72 | flatbuffers::emplace_scalar::(dst, self.0); 73 | } 74 | } 75 | 76 | impl flatbuffers::EndianScalar for SymbolClass { 77 | type Scalar = u8; 78 | #[inline] 79 | fn to_little_endian(self) -> u8 { 80 | self.0.to_le() 81 | } 82 | #[inline] 83 | #[allow(clippy::wrong_self_convention)] 84 | fn from_little_endian(v: u8) -> Self { 85 | let b = u8::from_le(v); 86 | Self(b) 87 | } 88 | } 89 | 90 | impl<'a> flatbuffers::Verifiable for SymbolClass { 91 | #[inline] 92 | fn run_verifier( 93 | v: &mut flatbuffers::Verifier, pos: usize 94 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 95 | use self::flatbuffers::Verifiable; 96 | u8::run_verifier(v, pos) 97 | } 98 | } 99 | 100 | impl flatbuffers::SimpleToVerifyInSlice for SymbolClass {} 101 | pub struct SymbolClassUnionTableOffset {} 102 | 103 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/symbol_bin/symbol_modifiers_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | #[allow(non_upper_case_globals)] 13 | mod bitflags_symbol_modifiers { 14 | flatbuffers::bitflags::bitflags! { 15 | #[derive(Default)] 16 | pub struct SymbolModifiers: u8 { 17 | const External = 1; 18 | const Exported = 2; 19 | } 20 | } 21 | } 22 | pub use self::bitflags_symbol_modifiers::SymbolModifiers; 23 | 24 | impl<'a> flatbuffers::Follow<'a> for SymbolModifiers { 25 | type Inner = Self; 26 | #[inline] 27 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 28 | let b = flatbuffers::read_scalar_at::(buf, loc); 29 | // Safety: 30 | // This is safe because we know bitflags is implemented with a repr transparent uint of the correct size. 31 | // from_bits_unchecked will be replaced by an equivalent but safe from_bits_retain in bitflags 2.0 32 | // https://github.com/bitflags/bitflags/issues/262 33 | Self::from_bits_unchecked(b) 34 | } 35 | } 36 | 37 | impl flatbuffers::Push for SymbolModifiers { 38 | type Output = SymbolModifiers; 39 | #[inline] 40 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 41 | flatbuffers::emplace_scalar::(dst, self.bits()); 42 | } 43 | } 44 | 45 | impl flatbuffers::EndianScalar for SymbolModifiers { 46 | type Scalar = u8; 47 | #[inline] 48 | fn to_little_endian(self) -> u8 { 49 | self.bits().to_le() 50 | } 51 | #[inline] 52 | #[allow(clippy::wrong_self_convention)] 53 | fn from_little_endian(v: u8) -> Self { 54 | let b = u8::from_le(v); 55 | // Safety: 56 | // This is safe because we know bitflags is implemented with a repr transparent uint of the correct size. 57 | // from_bits_unchecked will be replaced by an equivalent but safe from_bits_retain in bitflags 2.0 58 | // https://github.com/bitflags/bitflags/issues/262 59 | unsafe { Self::from_bits_unchecked(b) } 60 | } 61 | } 62 | 63 | impl<'a> flatbuffers::Verifiable for SymbolModifiers { 64 | #[inline] 65 | fn run_verifier( 66 | v: &mut flatbuffers::Verifier, pos: usize 67 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 68 | use self::flatbuffers::Verifiable; 69 | u8::run_verifier(v, pos) 70 | } 71 | } 72 | 73 | impl flatbuffers::SimpleToVerifyInSlice for SymbolModifiers {} 74 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/access_alignment_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum AccessAlignmentOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct AccessAlignment<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for AccessAlignment<'a> { 20 | type Inner = AccessAlignment<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> AccessAlignment<'a> { 28 | 29 | #[inline] 30 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 31 | AccessAlignment { _tab: table } 32 | } 33 | #[allow(unused_mut)] 34 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 35 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 36 | _args: &'args AccessAlignmentArgs 37 | ) -> flatbuffers::WIPOffset> { 38 | let mut builder = AccessAlignmentBuilder::new(_fbb); 39 | builder.finish() 40 | } 41 | 42 | } 43 | 44 | impl flatbuffers::Verifiable for AccessAlignment<'_> { 45 | #[inline] 46 | fn run_verifier( 47 | v: &mut flatbuffers::Verifier, pos: usize 48 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 49 | use self::flatbuffers::Verifiable; 50 | v.visit_table(pos)? 51 | .finish(); 52 | Ok(()) 53 | } 54 | } 55 | pub struct AccessAlignmentArgs { 56 | } 57 | impl<'a> Default for AccessAlignmentArgs { 58 | #[inline] 59 | fn default() -> Self { 60 | AccessAlignmentArgs { 61 | } 62 | } 63 | } 64 | 65 | pub struct AccessAlignmentBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 66 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 67 | start_: flatbuffers::WIPOffset, 68 | } 69 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> AccessAlignmentBuilder<'a, 'b, A> { 70 | #[inline] 71 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> AccessAlignmentBuilder<'a, 'b, A> { 72 | let start = _fbb.start_table(); 73 | AccessAlignmentBuilder { 74 | fbb_: _fbb, 75 | start_: start, 76 | } 77 | } 78 | #[inline] 79 | pub fn finish(self) -> flatbuffers::WIPOffset> { 80 | let o = self.fbb_.end_table(self.start_); 81 | flatbuffers::WIPOffset::new(o.value()) 82 | } 83 | } 84 | 85 | impl core::fmt::Debug for AccessAlignment<'_> { 86 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 87 | let mut ds = f.debug_struct("AccessAlignment"); 88 | ds.finish() 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/array_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum ArrayOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct Array<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for Array<'a> { 20 | type Inner = Array<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> Array<'a> { 28 | pub const VT_TYPE_: flatbuffers::VOffsetT = 4; 29 | pub const VT_LENGTH: flatbuffers::VOffsetT = 6; 30 | pub const VT_MODIFIERS: flatbuffers::VOffsetT = 8; 31 | 32 | #[inline] 33 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 34 | Array { _tab: table } 35 | } 36 | #[allow(unused_mut)] 37 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 38 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 39 | args: &'args ArrayArgs<'args> 40 | ) -> flatbuffers::WIPOffset> { 41 | let mut builder = ArrayBuilder::new(_fbb); 42 | builder.add_length(args.length); 43 | if let Some(x) = args.type_ { builder.add_type_(x); } 44 | builder.add_modifiers(args.modifiers); 45 | builder.finish() 46 | } 47 | 48 | 49 | #[inline] 50 | pub fn type_(&self) -> Type<'a> { 51 | // Safety: 52 | // Created from valid Table for this object 53 | // which contains a valid value in this slot 54 | unsafe { self._tab.get::>(Array::VT_TYPE_, None).unwrap()} 55 | } 56 | #[inline] 57 | pub fn length(&self) -> u64 { 58 | // Safety: 59 | // Created from valid Table for this object 60 | // which contains a valid value in this slot 61 | unsafe { self._tab.get::(Array::VT_LENGTH, Some(0)).unwrap()} 62 | } 63 | #[inline] 64 | pub fn modifiers(&self) -> ArrayModifiers { 65 | // Safety: 66 | // Created from valid Table for this object 67 | // which contains a valid value in this slot 68 | unsafe { self._tab.get::(Array::VT_MODIFIERS, Some(Default::default())).unwrap()} 69 | } 70 | } 71 | 72 | impl flatbuffers::Verifiable for Array<'_> { 73 | #[inline] 74 | fn run_verifier( 75 | v: &mut flatbuffers::Verifier, pos: usize 76 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 77 | use self::flatbuffers::Verifiable; 78 | v.visit_table(pos)? 79 | .visit_field::>("type_", Self::VT_TYPE_, true)? 80 | .visit_field::("length", Self::VT_LENGTH, false)? 81 | .visit_field::("modifiers", Self::VT_MODIFIERS, false)? 82 | .finish(); 83 | Ok(()) 84 | } 85 | } 86 | pub struct ArrayArgs<'a> { 87 | pub type_: Option>>, 88 | pub length: u64, 89 | pub modifiers: ArrayModifiers, 90 | } 91 | impl<'a> Default for ArrayArgs<'a> { 92 | #[inline] 93 | fn default() -> Self { 94 | ArrayArgs { 95 | type_: None, // required field 96 | length: 0, 97 | modifiers: Default::default(), 98 | } 99 | } 100 | } 101 | 102 | pub struct ArrayBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 103 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 104 | start_: flatbuffers::WIPOffset, 105 | } 106 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> ArrayBuilder<'a, 'b, A> { 107 | #[inline] 108 | pub fn add_type_(&mut self, type_: flatbuffers::WIPOffset>) { 109 | self.fbb_.push_slot_always::>(Array::VT_TYPE_, type_); 110 | } 111 | #[inline] 112 | pub fn add_length(&mut self, length: u64) { 113 | self.fbb_.push_slot::(Array::VT_LENGTH, length, 0); 114 | } 115 | #[inline] 116 | pub fn add_modifiers(&mut self, modifiers: ArrayModifiers) { 117 | self.fbb_.push_slot::(Array::VT_MODIFIERS, modifiers, Default::default()); 118 | } 119 | #[inline] 120 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> ArrayBuilder<'a, 'b, A> { 121 | let start = _fbb.start_table(); 122 | ArrayBuilder { 123 | fbb_: _fbb, 124 | start_: start, 125 | } 126 | } 127 | #[inline] 128 | pub fn finish(self) -> flatbuffers::WIPOffset> { 129 | let o = self.fbb_.end_table(self.start_); 130 | self.fbb_.required(o, Array::VT_TYPE_,"type_"); 131 | flatbuffers::WIPOffset::new(o.value()) 132 | } 133 | } 134 | 135 | impl core::fmt::Debug for Array<'_> { 136 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 137 | let mut ds = f.debug_struct("Array"); 138 | ds.field("type_", &self.type_()); 139 | ds.field("length", &self.length()); 140 | ds.field("modifiers", &self.modifiers()); 141 | ds.finish() 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/array_modifiers_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | #[allow(non_upper_case_globals)] 13 | mod bitflags_array_modifiers { 14 | flatbuffers::bitflags::bitflags! { 15 | #[derive(Default)] 16 | pub struct ArrayModifiers: u8 { 17 | const NullTerminated = 1; 18 | } 19 | } 20 | } 21 | pub use self::bitflags_array_modifiers::ArrayModifiers; 22 | 23 | impl<'a> flatbuffers::Follow<'a> for ArrayModifiers { 24 | type Inner = Self; 25 | #[inline] 26 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 27 | let b = flatbuffers::read_scalar_at::(buf, loc); 28 | // Safety: 29 | // This is safe because we know bitflags is implemented with a repr transparent uint of the correct size. 30 | // from_bits_unchecked will be replaced by an equivalent but safe from_bits_retain in bitflags 2.0 31 | // https://github.com/bitflags/bitflags/issues/262 32 | Self::from_bits_unchecked(b) 33 | } 34 | } 35 | 36 | impl flatbuffers::Push for ArrayModifiers { 37 | type Output = ArrayModifiers; 38 | #[inline] 39 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 40 | flatbuffers::emplace_scalar::(dst, self.bits()); 41 | } 42 | } 43 | 44 | impl flatbuffers::EndianScalar for ArrayModifiers { 45 | type Scalar = u8; 46 | #[inline] 47 | fn to_little_endian(self) -> u8 { 48 | self.bits().to_le() 49 | } 50 | #[inline] 51 | #[allow(clippy::wrong_self_convention)] 52 | fn from_little_endian(v: u8) -> Self { 53 | let b = u8::from_le(v); 54 | // Safety: 55 | // This is safe because we know bitflags is implemented with a repr transparent uint of the correct size. 56 | // from_bits_unchecked will be replaced by an equivalent but safe from_bits_retain in bitflags 2.0 57 | // https://github.com/bitflags/bitflags/issues/262 58 | unsafe { Self::from_bits_unchecked(b) } 59 | } 60 | } 61 | 62 | impl<'a> flatbuffers::Verifiable for ArrayModifiers { 63 | #[inline] 64 | fn run_verifier( 65 | v: &mut flatbuffers::Verifier, pos: usize 66 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 67 | use self::flatbuffers::Verifiable; 68 | u8::run_verifier(v, pos) 69 | } 70 | } 71 | 72 | impl flatbuffers::SimpleToVerifyInSlice for ArrayModifiers {} 73 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/bit_offset_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | // struct BitOffset, aligned to 8 13 | #[repr(transparent)] 14 | #[derive(Clone, Copy, PartialEq)] 15 | pub struct BitOffset(pub [u8; 8]); 16 | impl Default for BitOffset { 17 | fn default() -> Self { 18 | Self([0; 8]) 19 | } 20 | } 21 | impl core::fmt::Debug for BitOffset { 22 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 23 | f.debug_struct("BitOffset") 24 | .field("value", &self.value()) 25 | .finish() 26 | } 27 | } 28 | 29 | impl flatbuffers::SimpleToVerifyInSlice for BitOffset {} 30 | impl<'a> flatbuffers::Follow<'a> for BitOffset { 31 | type Inner = &'a BitOffset; 32 | #[inline] 33 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 34 | <&'a BitOffset>::follow(buf, loc) 35 | } 36 | } 37 | impl<'a> flatbuffers::Follow<'a> for &'a BitOffset { 38 | type Inner = &'a BitOffset; 39 | #[inline] 40 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 41 | flatbuffers::follow_cast_ref::(buf, loc) 42 | } 43 | } 44 | impl<'b> flatbuffers::Push for BitOffset { 45 | type Output = BitOffset; 46 | #[inline] 47 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 48 | let src = ::core::slice::from_raw_parts(self as *const BitOffset as *const u8, Self::size()); 49 | dst.copy_from_slice(src); 50 | } 51 | } 52 | 53 | impl<'a> flatbuffers::Verifiable for BitOffset { 54 | #[inline] 55 | fn run_verifier( 56 | v: &mut flatbuffers::Verifier, pos: usize 57 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 58 | use self::flatbuffers::Verifiable; 59 | v.in_buffer::(pos) 60 | } 61 | } 62 | 63 | impl<'a> BitOffset { 64 | #[allow(clippy::too_many_arguments)] 65 | pub fn new( 66 | value: i64, 67 | ) -> Self { 68 | let mut s = Self([0; 8]); 69 | s.set_value(value); 70 | s 71 | } 72 | 73 | pub fn value(&self) -> i64 { 74 | let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); 75 | // Safety: 76 | // Created from a valid Table for this object 77 | // Which contains a valid value in this slot 78 | EndianScalar::from_little_endian(unsafe { 79 | core::ptr::copy_nonoverlapping( 80 | self.0[0..].as_ptr(), 81 | mem.as_mut_ptr() as *mut u8, 82 | core::mem::size_of::<::Scalar>(), 83 | ); 84 | mem.assume_init() 85 | }) 86 | } 87 | 88 | pub fn set_value(&mut self, x: i64) { 89 | let x_le = x.to_little_endian(); 90 | // Safety: 91 | // Created from a valid Table for this object 92 | // Which contains a valid value in this slot 93 | unsafe { 94 | core::ptr::copy_nonoverlapping( 95 | &x_le as *const _ as *const u8, 96 | self.0[0..].as_mut_ptr(), 97 | core::mem::size_of::<::Scalar>(), 98 | ); 99 | } 100 | } 101 | 102 | } 103 | 104 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/bit_shift_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | // struct BitShift, aligned to 8 13 | #[repr(transparent)] 14 | #[derive(Clone, Copy, PartialEq)] 15 | pub struct BitShift(pub [u8; 8]); 16 | impl Default for BitShift { 17 | fn default() -> Self { 18 | Self([0; 8]) 19 | } 20 | } 21 | impl core::fmt::Debug for BitShift { 22 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 23 | f.debug_struct("BitShift") 24 | .field("value", &self.value()) 25 | .finish() 26 | } 27 | } 28 | 29 | impl flatbuffers::SimpleToVerifyInSlice for BitShift {} 30 | impl<'a> flatbuffers::Follow<'a> for BitShift { 31 | type Inner = &'a BitShift; 32 | #[inline] 33 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 34 | <&'a BitShift>::follow(buf, loc) 35 | } 36 | } 37 | impl<'a> flatbuffers::Follow<'a> for &'a BitShift { 38 | type Inner = &'a BitShift; 39 | #[inline] 40 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 41 | flatbuffers::follow_cast_ref::(buf, loc) 42 | } 43 | } 44 | impl<'b> flatbuffers::Push for BitShift { 45 | type Output = BitShift; 46 | #[inline] 47 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 48 | let src = ::core::slice::from_raw_parts(self as *const BitShift as *const u8, Self::size()); 49 | dst.copy_from_slice(src); 50 | } 51 | } 52 | 53 | impl<'a> flatbuffers::Verifiable for BitShift { 54 | #[inline] 55 | fn run_verifier( 56 | v: &mut flatbuffers::Verifier, pos: usize 57 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 58 | use self::flatbuffers::Verifiable; 59 | v.in_buffer::(pos) 60 | } 61 | } 62 | 63 | impl<'a> BitShift { 64 | #[allow(clippy::too_many_arguments)] 65 | pub fn new( 66 | value: i64, 67 | ) -> Self { 68 | let mut s = Self([0; 8]); 69 | s.set_value(value); 70 | s 71 | } 72 | 73 | pub fn value(&self) -> i64 { 74 | let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); 75 | // Safety: 76 | // Created from a valid Table for this object 77 | // Which contains a valid value in this slot 78 | EndianScalar::from_little_endian(unsafe { 79 | core::ptr::copy_nonoverlapping( 80 | self.0[0..].as_ptr(), 81 | mem.as_mut_ptr() as *mut u8, 82 | core::mem::size_of::<::Scalar>(), 83 | ); 84 | mem.assume_init() 85 | }) 86 | } 87 | 88 | pub fn set_value(&mut self, x: i64) { 89 | let x_le = x.to_little_endian(); 90 | // Safety: 91 | // Created from a valid Table for this object 92 | // Which contains a valid value in this slot 93 | unsafe { 94 | core::ptr::copy_nonoverlapping( 95 | &x_le as *const _ as *const u8, 96 | self.0[0..].as_mut_ptr(), 97 | core::mem::size_of::<::Scalar>(), 98 | ); 99 | } 100 | } 101 | 102 | } 103 | 104 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/bit_size_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | // struct BitSize, aligned to 8 13 | #[repr(transparent)] 14 | #[derive(Clone, Copy, PartialEq)] 15 | pub struct BitSize(pub [u8; 8]); 16 | impl Default for BitSize { 17 | fn default() -> Self { 18 | Self([0; 8]) 19 | } 20 | } 21 | impl core::fmt::Debug for BitSize { 22 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 23 | f.debug_struct("BitSize") 24 | .field("value", &self.value()) 25 | .finish() 26 | } 27 | } 28 | 29 | impl flatbuffers::SimpleToVerifyInSlice for BitSize {} 30 | impl<'a> flatbuffers::Follow<'a> for BitSize { 31 | type Inner = &'a BitSize; 32 | #[inline] 33 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 34 | <&'a BitSize>::follow(buf, loc) 35 | } 36 | } 37 | impl<'a> flatbuffers::Follow<'a> for &'a BitSize { 38 | type Inner = &'a BitSize; 39 | #[inline] 40 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 41 | flatbuffers::follow_cast_ref::(buf, loc) 42 | } 43 | } 44 | impl<'b> flatbuffers::Push for BitSize { 45 | type Output = BitSize; 46 | #[inline] 47 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 48 | let src = ::core::slice::from_raw_parts(self as *const BitSize as *const u8, Self::size()); 49 | dst.copy_from_slice(src); 50 | } 51 | } 52 | 53 | impl<'a> flatbuffers::Verifiable for BitSize { 54 | #[inline] 55 | fn run_verifier( 56 | v: &mut flatbuffers::Verifier, pos: usize 57 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 58 | use self::flatbuffers::Verifiable; 59 | v.in_buffer::(pos) 60 | } 61 | } 62 | 63 | impl<'a> BitSize { 64 | #[allow(clippy::too_many_arguments)] 65 | pub fn new( 66 | value: u64, 67 | ) -> Self { 68 | let mut s = Self([0; 8]); 69 | s.set_value(value); 70 | s 71 | } 72 | 73 | pub fn value(&self) -> u64 { 74 | let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); 75 | // Safety: 76 | // Created from a valid Table for this object 77 | // Which contains a valid value in this slot 78 | EndianScalar::from_little_endian(unsafe { 79 | core::ptr::copy_nonoverlapping( 80 | self.0[0..].as_ptr(), 81 | mem.as_mut_ptr() as *mut u8, 82 | core::mem::size_of::<::Scalar>(), 83 | ); 84 | mem.assume_init() 85 | }) 86 | } 87 | 88 | pub fn set_value(&mut self, x: u64) { 89 | let x_le = x.to_little_endian(); 90 | // Safety: 91 | // Created from a valid Table for this object 92 | // Which contains a valid value in this slot 93 | unsafe { 94 | core::ptr::copy_nonoverlapping( 95 | &x_le as *const _ as *const u8, 96 | self.0[0..].as_mut_ptr(), 97 | core::mem::size_of::<::Scalar>(), 98 | ); 99 | } 100 | } 101 | 102 | } 103 | 104 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/bit_width_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | // struct BitWidth, aligned to 2 13 | #[repr(transparent)] 14 | #[derive(Clone, Copy, PartialEq)] 15 | pub struct BitWidth(pub [u8; 2]); 16 | impl Default for BitWidth { 17 | fn default() -> Self { 18 | Self([0; 2]) 19 | } 20 | } 21 | impl core::fmt::Debug for BitWidth { 22 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 23 | f.debug_struct("BitWidth") 24 | .field("value", &self.value()) 25 | .finish() 26 | } 27 | } 28 | 29 | impl flatbuffers::SimpleToVerifyInSlice for BitWidth {} 30 | impl<'a> flatbuffers::Follow<'a> for BitWidth { 31 | type Inner = &'a BitWidth; 32 | #[inline] 33 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 34 | <&'a BitWidth>::follow(buf, loc) 35 | } 36 | } 37 | impl<'a> flatbuffers::Follow<'a> for &'a BitWidth { 38 | type Inner = &'a BitWidth; 39 | #[inline] 40 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 41 | flatbuffers::follow_cast_ref::(buf, loc) 42 | } 43 | } 44 | impl<'b> flatbuffers::Push for BitWidth { 45 | type Output = BitWidth; 46 | #[inline] 47 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 48 | let src = ::core::slice::from_raw_parts(self as *const BitWidth as *const u8, Self::size()); 49 | dst.copy_from_slice(src); 50 | } 51 | } 52 | 53 | impl<'a> flatbuffers::Verifiable for BitWidth { 54 | #[inline] 55 | fn run_verifier( 56 | v: &mut flatbuffers::Verifier, pos: usize 57 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 58 | use self::flatbuffers::Verifiable; 59 | v.in_buffer::(pos) 60 | } 61 | } 62 | 63 | impl<'a> BitWidth { 64 | #[allow(clippy::too_many_arguments)] 65 | pub fn new( 66 | value: u16, 67 | ) -> Self { 68 | let mut s = Self([0; 2]); 69 | s.set_value(value); 70 | s 71 | } 72 | 73 | pub fn value(&self) -> u16 { 74 | let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); 75 | // Safety: 76 | // Created from a valid Table for this object 77 | // Which contains a valid value in this slot 78 | EndianScalar::from_little_endian(unsafe { 79 | core::ptr::copy_nonoverlapping( 80 | self.0[0..].as_ptr(), 81 | mem.as_mut_ptr() as *mut u8, 82 | core::mem::size_of::<::Scalar>(), 83 | ); 84 | mem.assume_init() 85 | }) 86 | } 87 | 88 | pub fn set_value(&mut self, x: u16) { 89 | let x_le = x.to_little_endian(); 90 | // Safety: 91 | // Created from a valid Table for this object 92 | // Which contains a valid value in this slot 93 | unsafe { 94 | core::ptr::copy_nonoverlapping( 95 | &x_le as *const _ as *const u8, 96 | self.0[0..].as_mut_ptr(), 97 | core::mem::size_of::<::Scalar>(), 98 | ); 99 | } 100 | } 101 | 102 | } 103 | 104 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/boolean_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum BooleanOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct Boolean<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for Boolean<'a> { 20 | type Inner = Boolean<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> Boolean<'a> { 28 | pub const VT_WIDTH: flatbuffers::VOffsetT = 4; 29 | 30 | #[inline] 31 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 32 | Boolean { _tab: table } 33 | } 34 | #[allow(unused_mut)] 35 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 36 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 37 | args: &'args BooleanArgs<'args> 38 | ) -> flatbuffers::WIPOffset> { 39 | let mut builder = BooleanBuilder::new(_fbb); 40 | if let Some(x) = args.width { builder.add_width(x); } 41 | builder.finish() 42 | } 43 | 44 | 45 | #[inline] 46 | pub fn width(&self) -> Option<&'a BitWidth> { 47 | // Safety: 48 | // Created from valid Table for this object 49 | // which contains a valid value in this slot 50 | unsafe { self._tab.get::(Boolean::VT_WIDTH, None)} 51 | } 52 | } 53 | 54 | impl flatbuffers::Verifiable for Boolean<'_> { 55 | #[inline] 56 | fn run_verifier( 57 | v: &mut flatbuffers::Verifier, pos: usize 58 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 59 | use self::flatbuffers::Verifiable; 60 | v.visit_table(pos)? 61 | .visit_field::("width", Self::VT_WIDTH, false)? 62 | .finish(); 63 | Ok(()) 64 | } 65 | } 66 | pub struct BooleanArgs<'a> { 67 | pub width: Option<&'a BitWidth>, 68 | } 69 | impl<'a> Default for BooleanArgs<'a> { 70 | #[inline] 71 | fn default() -> Self { 72 | BooleanArgs { 73 | width: None, 74 | } 75 | } 76 | } 77 | 78 | pub struct BooleanBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 79 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 80 | start_: flatbuffers::WIPOffset, 81 | } 82 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> BooleanBuilder<'a, 'b, A> { 83 | #[inline] 84 | pub fn add_width(&mut self, width: &BitWidth) { 85 | self.fbb_.push_slot_always::<&BitWidth>(Boolean::VT_WIDTH, width); 86 | } 87 | #[inline] 88 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> BooleanBuilder<'a, 'b, A> { 89 | let start = _fbb.start_table(); 90 | BooleanBuilder { 91 | fbb_: _fbb, 92 | start_: start, 93 | } 94 | } 95 | #[inline] 96 | pub fn finish(self) -> flatbuffers::WIPOffset> { 97 | let o = self.fbb_.end_table(self.start_); 98 | flatbuffers::WIPOffset::new(o.value()) 99 | } 100 | } 101 | 102 | impl core::fmt::Debug for Boolean<'_> { 103 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 104 | let mut ds = f.debug_struct("Boolean"); 105 | ds.field("width", &self.width()); 106 | ds.finish() 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/calling_convention_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum CallingConventionOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct CallingConvention<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for CallingConvention<'a> { 20 | type Inner = CallingConvention<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> CallingConvention<'a> { 28 | pub const VT_NAME: flatbuffers::VOffsetT = 4; 29 | 30 | #[inline] 31 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 32 | CallingConvention { _tab: table } 33 | } 34 | #[allow(unused_mut)] 35 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 36 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 37 | args: &'args CallingConventionArgs<'args> 38 | ) -> flatbuffers::WIPOffset> { 39 | let mut builder = CallingConventionBuilder::new(_fbb); 40 | if let Some(x) = args.name { builder.add_name(x); } 41 | builder.finish() 42 | } 43 | 44 | 45 | #[inline] 46 | pub fn name(&self) -> Option<&'a str> { 47 | // Safety: 48 | // Created from valid Table for this object 49 | // which contains a valid value in this slot 50 | unsafe { self._tab.get::>(CallingConvention::VT_NAME, None)} 51 | } 52 | } 53 | 54 | impl flatbuffers::Verifiable for CallingConvention<'_> { 55 | #[inline] 56 | fn run_verifier( 57 | v: &mut flatbuffers::Verifier, pos: usize 58 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 59 | use self::flatbuffers::Verifiable; 60 | v.visit_table(pos)? 61 | .visit_field::>("name", Self::VT_NAME, false)? 62 | .finish(); 63 | Ok(()) 64 | } 65 | } 66 | pub struct CallingConventionArgs<'a> { 67 | pub name: Option>, 68 | } 69 | impl<'a> Default for CallingConventionArgs<'a> { 70 | #[inline] 71 | fn default() -> Self { 72 | CallingConventionArgs { 73 | name: None, 74 | } 75 | } 76 | } 77 | 78 | pub struct CallingConventionBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 79 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 80 | start_: flatbuffers::WIPOffset, 81 | } 82 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> CallingConventionBuilder<'a, 'b, A> { 83 | #[inline] 84 | pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { 85 | self.fbb_.push_slot_always::>(CallingConvention::VT_NAME, name); 86 | } 87 | #[inline] 88 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> CallingConventionBuilder<'a, 'b, A> { 89 | let start = _fbb.start_table(); 90 | CallingConventionBuilder { 91 | fbb_: _fbb, 92 | start_: start, 93 | } 94 | } 95 | #[inline] 96 | pub fn finish(self) -> flatbuffers::WIPOffset> { 97 | let o = self.fbb_.end_table(self.start_); 98 | flatbuffers::WIPOffset::new(o.value()) 99 | } 100 | } 101 | 102 | impl core::fmt::Debug for CallingConvention<'_> { 103 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 104 | let mut ds = f.debug_struct("CallingConvention"); 105 | ds.field("name", &self.name()); 106 | ds.finish() 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/character_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum CharacterOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct Character<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for Character<'a> { 20 | type Inner = Character<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> Character<'a> { 28 | pub const VT_WIDTH: flatbuffers::VOffsetT = 4; 29 | 30 | #[inline] 31 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 32 | Character { _tab: table } 33 | } 34 | #[allow(unused_mut)] 35 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 36 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 37 | args: &'args CharacterArgs<'args> 38 | ) -> flatbuffers::WIPOffset> { 39 | let mut builder = CharacterBuilder::new(_fbb); 40 | if let Some(x) = args.width { builder.add_width(x); } 41 | builder.finish() 42 | } 43 | 44 | 45 | #[inline] 46 | pub fn width(&self) -> Option<&'a BitWidth> { 47 | // Safety: 48 | // Created from valid Table for this object 49 | // which contains a valid value in this slot 50 | unsafe { self._tab.get::(Character::VT_WIDTH, None)} 51 | } 52 | } 53 | 54 | impl flatbuffers::Verifiable for Character<'_> { 55 | #[inline] 56 | fn run_verifier( 57 | v: &mut flatbuffers::Verifier, pos: usize 58 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 59 | use self::flatbuffers::Verifiable; 60 | v.visit_table(pos)? 61 | .visit_field::("width", Self::VT_WIDTH, false)? 62 | .finish(); 63 | Ok(()) 64 | } 65 | } 66 | pub struct CharacterArgs<'a> { 67 | pub width: Option<&'a BitWidth>, 68 | } 69 | impl<'a> Default for CharacterArgs<'a> { 70 | #[inline] 71 | fn default() -> Self { 72 | CharacterArgs { 73 | width: None, 74 | } 75 | } 76 | } 77 | 78 | pub struct CharacterBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 79 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 80 | start_: flatbuffers::WIPOffset, 81 | } 82 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> CharacterBuilder<'a, 'b, A> { 83 | #[inline] 84 | pub fn add_width(&mut self, width: &BitWidth) { 85 | self.fbb_.push_slot_always::<&BitWidth>(Character::VT_WIDTH, width); 86 | } 87 | #[inline] 88 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> CharacterBuilder<'a, 'b, A> { 89 | let start = _fbb.start_table(); 90 | CharacterBuilder { 91 | fbb_: _fbb, 92 | start_: start, 93 | } 94 | } 95 | #[inline] 96 | pub fn finish(self) -> flatbuffers::WIPOffset> { 97 | let o = self.fbb_.end_table(self.start_); 98 | flatbuffers::WIPOffset::new(o.value()) 99 | } 100 | } 101 | 102 | impl core::fmt::Debug for Character<'_> { 103 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 104 | let mut ds = f.debug_struct("Character"); 105 | ds.field("width", &self.width()); 106 | ds.finish() 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/computed_type_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum ComputedTypeOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct ComputedType<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for ComputedType<'a> { 20 | type Inner = ComputedType<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> ComputedType<'a> { 28 | pub const VT_GUID: flatbuffers::VOffsetT = 4; 29 | pub const VT_TYPE_: flatbuffers::VOffsetT = 6; 30 | 31 | #[inline] 32 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 33 | ComputedType { _tab: table } 34 | } 35 | #[allow(unused_mut)] 36 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 37 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 38 | args: &'args ComputedTypeArgs<'args> 39 | ) -> flatbuffers::WIPOffset> { 40 | let mut builder = ComputedTypeBuilder::new(_fbb); 41 | if let Some(x) = args.type_ { builder.add_type_(x); } 42 | if let Some(x) = args.guid { builder.add_guid(x); } 43 | builder.finish() 44 | } 45 | 46 | 47 | #[inline] 48 | pub fn guid(&self) -> &'a str { 49 | // Safety: 50 | // Created from valid Table for this object 51 | // which contains a valid value in this slot 52 | unsafe { self._tab.get::>(ComputedType::VT_GUID, None).unwrap()} 53 | } 54 | #[inline] 55 | pub fn type_(&self) -> Option> { 56 | // Safety: 57 | // Created from valid Table for this object 58 | // which contains a valid value in this slot 59 | unsafe { self._tab.get::>(ComputedType::VT_TYPE_, None)} 60 | } 61 | } 62 | 63 | impl flatbuffers::Verifiable for ComputedType<'_> { 64 | #[inline] 65 | fn run_verifier( 66 | v: &mut flatbuffers::Verifier, pos: usize 67 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 68 | use self::flatbuffers::Verifiable; 69 | v.visit_table(pos)? 70 | .visit_field::>("guid", Self::VT_GUID, true)? 71 | .visit_field::>("type_", Self::VT_TYPE_, false)? 72 | .finish(); 73 | Ok(()) 74 | } 75 | } 76 | pub struct ComputedTypeArgs<'a> { 77 | pub guid: Option>, 78 | pub type_: Option>>, 79 | } 80 | impl<'a> Default for ComputedTypeArgs<'a> { 81 | #[inline] 82 | fn default() -> Self { 83 | ComputedTypeArgs { 84 | guid: None, // required field 85 | type_: None, 86 | } 87 | } 88 | } 89 | 90 | pub struct ComputedTypeBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 91 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 92 | start_: flatbuffers::WIPOffset, 93 | } 94 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> ComputedTypeBuilder<'a, 'b, A> { 95 | #[inline] 96 | pub fn add_guid(&mut self, guid: flatbuffers::WIPOffset<&'b str>) { 97 | self.fbb_.push_slot_always::>(ComputedType::VT_GUID, guid); 98 | } 99 | #[inline] 100 | pub fn add_type_(&mut self, type_: flatbuffers::WIPOffset>) { 101 | self.fbb_.push_slot_always::>(ComputedType::VT_TYPE_, type_); 102 | } 103 | #[inline] 104 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> ComputedTypeBuilder<'a, 'b, A> { 105 | let start = _fbb.start_table(); 106 | ComputedTypeBuilder { 107 | fbb_: _fbb, 108 | start_: start, 109 | } 110 | } 111 | #[inline] 112 | pub fn finish(self) -> flatbuffers::WIPOffset> { 113 | let o = self.fbb_.end_table(self.start_); 114 | self.fbb_.required(o, ComputedType::VT_GUID,"guid"); 115 | flatbuffers::WIPOffset::new(o.value()) 116 | } 117 | } 118 | 119 | impl core::fmt::Debug for ComputedType<'_> { 120 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 121 | let mut ds = f.debug_struct("ComputedType"); 122 | ds.field("guid", &self.guid()); 123 | ds.field("type_", &self.type_()); 124 | ds.finish() 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/constant_modifier_class_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum ConstantModifierClassOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct ConstantModifierClass<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for ConstantModifierClass<'a> { 20 | type Inner = ConstantModifierClass<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> ConstantModifierClass<'a> { 28 | 29 | #[inline] 30 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 31 | ConstantModifierClass { _tab: table } 32 | } 33 | #[allow(unused_mut)] 34 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 35 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 36 | _args: &'args ConstantModifierClassArgs 37 | ) -> flatbuffers::WIPOffset> { 38 | let mut builder = ConstantModifierClassBuilder::new(_fbb); 39 | builder.finish() 40 | } 41 | 42 | } 43 | 44 | impl flatbuffers::Verifiable for ConstantModifierClass<'_> { 45 | #[inline] 46 | fn run_verifier( 47 | v: &mut flatbuffers::Verifier, pos: usize 48 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 49 | use self::flatbuffers::Verifiable; 50 | v.visit_table(pos)? 51 | .finish(); 52 | Ok(()) 53 | } 54 | } 55 | pub struct ConstantModifierClassArgs { 56 | } 57 | impl<'a> Default for ConstantModifierClassArgs { 58 | #[inline] 59 | fn default() -> Self { 60 | ConstantModifierClassArgs { 61 | } 62 | } 63 | } 64 | 65 | pub struct ConstantModifierClassBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 66 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 67 | start_: flatbuffers::WIPOffset, 68 | } 69 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> ConstantModifierClassBuilder<'a, 'b, A> { 70 | #[inline] 71 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> ConstantModifierClassBuilder<'a, 'b, A> { 72 | let start = _fbb.start_table(); 73 | ConstantModifierClassBuilder { 74 | fbb_: _fbb, 75 | start_: start, 76 | } 77 | } 78 | #[inline] 79 | pub fn finish(self) -> flatbuffers::WIPOffset> { 80 | let o = self.fbb_.end_table(self.start_); 81 | flatbuffers::WIPOffset::new(o.value()) 82 | } 83 | } 84 | 85 | impl core::fmt::Debug for ConstantModifierClass<'_> { 86 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 87 | let mut ds = f.debug_struct("ConstantModifierClass"); 88 | ds.finish() 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/descriptor_modifier_class_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum DescriptorModifierClassOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct DescriptorModifierClass<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for DescriptorModifierClass<'a> { 20 | type Inner = DescriptorModifierClass<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> DescriptorModifierClass<'a> { 28 | pub const VT_DESCRIPTION: flatbuffers::VOffsetT = 4; 29 | 30 | #[inline] 31 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 32 | DescriptorModifierClass { _tab: table } 33 | } 34 | #[allow(unused_mut)] 35 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 36 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 37 | args: &'args DescriptorModifierClassArgs<'args> 38 | ) -> flatbuffers::WIPOffset> { 39 | let mut builder = DescriptorModifierClassBuilder::new(_fbb); 40 | if let Some(x) = args.description { builder.add_description(x); } 41 | builder.finish() 42 | } 43 | 44 | 45 | #[inline] 46 | pub fn description(&self) -> Option<&'a str> { 47 | // Safety: 48 | // Created from valid Table for this object 49 | // which contains a valid value in this slot 50 | unsafe { self._tab.get::>(DescriptorModifierClass::VT_DESCRIPTION, None)} 51 | } 52 | } 53 | 54 | impl flatbuffers::Verifiable for DescriptorModifierClass<'_> { 55 | #[inline] 56 | fn run_verifier( 57 | v: &mut flatbuffers::Verifier, pos: usize 58 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 59 | use self::flatbuffers::Verifiable; 60 | v.visit_table(pos)? 61 | .visit_field::>("description", Self::VT_DESCRIPTION, false)? 62 | .finish(); 63 | Ok(()) 64 | } 65 | } 66 | pub struct DescriptorModifierClassArgs<'a> { 67 | pub description: Option>, 68 | } 69 | impl<'a> Default for DescriptorModifierClassArgs<'a> { 70 | #[inline] 71 | fn default() -> Self { 72 | DescriptorModifierClassArgs { 73 | description: None, 74 | } 75 | } 76 | } 77 | 78 | pub struct DescriptorModifierClassBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 79 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 80 | start_: flatbuffers::WIPOffset, 81 | } 82 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> DescriptorModifierClassBuilder<'a, 'b, A> { 83 | #[inline] 84 | pub fn add_description(&mut self, description: flatbuffers::WIPOffset<&'b str>) { 85 | self.fbb_.push_slot_always::>(DescriptorModifierClass::VT_DESCRIPTION, description); 86 | } 87 | #[inline] 88 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> DescriptorModifierClassBuilder<'a, 'b, A> { 89 | let start = _fbb.start_table(); 90 | DescriptorModifierClassBuilder { 91 | fbb_: _fbb, 92 | start_: start, 93 | } 94 | } 95 | #[inline] 96 | pub fn finish(self) -> flatbuffers::WIPOffset> { 97 | let o = self.fbb_.end_table(self.start_); 98 | flatbuffers::WIPOffset::new(o.value()) 99 | } 100 | } 101 | 102 | impl core::fmt::Debug for DescriptorModifierClass<'_> { 103 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 104 | let mut ds = f.debug_struct("DescriptorModifierClass"); 105 | ds.field("description", &self.description()); 106 | ds.finish() 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/enumeration_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum EnumerationOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct Enumeration<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for Enumeration<'a> { 20 | type Inner = Enumeration<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> Enumeration<'a> { 28 | pub const VT_MEMBER_TYPE: flatbuffers::VOffsetT = 4; 29 | pub const VT_MEMBERS: flatbuffers::VOffsetT = 6; 30 | 31 | #[inline] 32 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 33 | Enumeration { _tab: table } 34 | } 35 | #[allow(unused_mut)] 36 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 37 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 38 | args: &'args EnumerationArgs<'args> 39 | ) -> flatbuffers::WIPOffset> { 40 | let mut builder = EnumerationBuilder::new(_fbb); 41 | if let Some(x) = args.members { builder.add_members(x); } 42 | if let Some(x) = args.member_type { builder.add_member_type(x); } 43 | builder.finish() 44 | } 45 | 46 | 47 | #[inline] 48 | pub fn member_type(&self) -> Type<'a> { 49 | // Safety: 50 | // Created from valid Table for this object 51 | // which contains a valid value in this slot 52 | unsafe { self._tab.get::>(Enumeration::VT_MEMBER_TYPE, None).unwrap()} 53 | } 54 | #[inline] 55 | pub fn members(&self) -> Option>>> { 56 | // Safety: 57 | // Created from valid Table for this object 58 | // which contains a valid value in this slot 59 | unsafe { self._tab.get::>>>(Enumeration::VT_MEMBERS, None)} 60 | } 61 | } 62 | 63 | impl flatbuffers::Verifiable for Enumeration<'_> { 64 | #[inline] 65 | fn run_verifier( 66 | v: &mut flatbuffers::Verifier, pos: usize 67 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 68 | use self::flatbuffers::Verifiable; 69 | v.visit_table(pos)? 70 | .visit_field::>("member_type", Self::VT_MEMBER_TYPE, true)? 71 | .visit_field::>>>("members", Self::VT_MEMBERS, false)? 72 | .finish(); 73 | Ok(()) 74 | } 75 | } 76 | pub struct EnumerationArgs<'a> { 77 | pub member_type: Option>>, 78 | pub members: Option>>>>, 79 | } 80 | impl<'a> Default for EnumerationArgs<'a> { 81 | #[inline] 82 | fn default() -> Self { 83 | EnumerationArgs { 84 | member_type: None, // required field 85 | members: None, 86 | } 87 | } 88 | } 89 | 90 | pub struct EnumerationBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 91 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 92 | start_: flatbuffers::WIPOffset, 93 | } 94 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> EnumerationBuilder<'a, 'b, A> { 95 | #[inline] 96 | pub fn add_member_type(&mut self, member_type: flatbuffers::WIPOffset>) { 97 | self.fbb_.push_slot_always::>(Enumeration::VT_MEMBER_TYPE, member_type); 98 | } 99 | #[inline] 100 | pub fn add_members(&mut self, members: flatbuffers::WIPOffset>>>) { 101 | self.fbb_.push_slot_always::>(Enumeration::VT_MEMBERS, members); 102 | } 103 | #[inline] 104 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> EnumerationBuilder<'a, 'b, A> { 105 | let start = _fbb.start_table(); 106 | EnumerationBuilder { 107 | fbb_: _fbb, 108 | start_: start, 109 | } 110 | } 111 | #[inline] 112 | pub fn finish(self) -> flatbuffers::WIPOffset> { 113 | let o = self.fbb_.end_table(self.start_); 114 | self.fbb_.required(o, Enumeration::VT_MEMBER_TYPE,"member_type"); 115 | flatbuffers::WIPOffset::new(o.value()) 116 | } 117 | } 118 | 119 | impl core::fmt::Debug for Enumeration<'_> { 120 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 121 | let mut ds = f.debug_struct("Enumeration"); 122 | ds.field("member_type", &self.member_type()); 123 | ds.field("members", &self.members()); 124 | ds.finish() 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/enumeration_member_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum EnumerationMemberOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct EnumerationMember<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for EnumerationMember<'a> { 20 | type Inner = EnumerationMember<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> EnumerationMember<'a> { 28 | pub const VT_NAME: flatbuffers::VOffsetT = 4; 29 | pub const VT_CONSTANT: flatbuffers::VOffsetT = 6; 30 | 31 | #[inline] 32 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 33 | EnumerationMember { _tab: table } 34 | } 35 | #[allow(unused_mut)] 36 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 37 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 38 | args: &'args EnumerationMemberArgs<'args> 39 | ) -> flatbuffers::WIPOffset> { 40 | let mut builder = EnumerationMemberBuilder::new(_fbb); 41 | builder.add_constant(args.constant); 42 | if let Some(x) = args.name { builder.add_name(x); } 43 | builder.finish() 44 | } 45 | 46 | 47 | #[inline] 48 | pub fn name(&self) -> Option<&'a str> { 49 | // Safety: 50 | // Created from valid Table for this object 51 | // which contains a valid value in this slot 52 | unsafe { self._tab.get::>(EnumerationMember::VT_NAME, None)} 53 | } 54 | #[inline] 55 | pub fn constant(&self) -> u64 { 56 | // Safety: 57 | // Created from valid Table for this object 58 | // which contains a valid value in this slot 59 | unsafe { self._tab.get::(EnumerationMember::VT_CONSTANT, Some(0)).unwrap()} 60 | } 61 | } 62 | 63 | impl flatbuffers::Verifiable for EnumerationMember<'_> { 64 | #[inline] 65 | fn run_verifier( 66 | v: &mut flatbuffers::Verifier, pos: usize 67 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 68 | use self::flatbuffers::Verifiable; 69 | v.visit_table(pos)? 70 | .visit_field::>("name", Self::VT_NAME, false)? 71 | .visit_field::("constant", Self::VT_CONSTANT, false)? 72 | .finish(); 73 | Ok(()) 74 | } 75 | } 76 | pub struct EnumerationMemberArgs<'a> { 77 | pub name: Option>, 78 | pub constant: u64, 79 | } 80 | impl<'a> Default for EnumerationMemberArgs<'a> { 81 | #[inline] 82 | fn default() -> Self { 83 | EnumerationMemberArgs { 84 | name: None, 85 | constant: 0, 86 | } 87 | } 88 | } 89 | 90 | pub struct EnumerationMemberBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 91 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 92 | start_: flatbuffers::WIPOffset, 93 | } 94 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> EnumerationMemberBuilder<'a, 'b, A> { 95 | #[inline] 96 | pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { 97 | self.fbb_.push_slot_always::>(EnumerationMember::VT_NAME, name); 98 | } 99 | #[inline] 100 | pub fn add_constant(&mut self, constant: u64) { 101 | self.fbb_.push_slot::(EnumerationMember::VT_CONSTANT, constant, 0); 102 | } 103 | #[inline] 104 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> EnumerationMemberBuilder<'a, 'b, A> { 105 | let start = _fbb.start_table(); 106 | EnumerationMemberBuilder { 107 | fbb_: _fbb, 108 | start_: start, 109 | } 110 | } 111 | #[inline] 112 | pub fn finish(self) -> flatbuffers::WIPOffset> { 113 | let o = self.fbb_.end_table(self.start_); 114 | flatbuffers::WIPOffset::new(o.value()) 115 | } 116 | } 117 | 118 | impl core::fmt::Debug for EnumerationMember<'_> { 119 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 120 | let mut ds = f.debug_struct("EnumerationMember"); 121 | ds.field("name", &self.name()); 122 | ds.field("constant", &self.constant()); 123 | ds.finish() 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/fixed_alignment_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum FixedAlignmentOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct FixedAlignment<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for FixedAlignment<'a> { 20 | type Inner = FixedAlignment<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> FixedAlignment<'a> { 28 | pub const VT_WIDTH: flatbuffers::VOffsetT = 4; 29 | 30 | #[inline] 31 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 32 | FixedAlignment { _tab: table } 33 | } 34 | #[allow(unused_mut)] 35 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 36 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 37 | args: &'args FixedAlignmentArgs<'args> 38 | ) -> flatbuffers::WIPOffset> { 39 | let mut builder = FixedAlignmentBuilder::new(_fbb); 40 | if let Some(x) = args.width { builder.add_width(x); } 41 | builder.finish() 42 | } 43 | 44 | 45 | #[inline] 46 | pub fn width(&self) -> Option<&'a BitWidth> { 47 | // Safety: 48 | // Created from valid Table for this object 49 | // which contains a valid value in this slot 50 | unsafe { self._tab.get::(FixedAlignment::VT_WIDTH, None)} 51 | } 52 | } 53 | 54 | impl flatbuffers::Verifiable for FixedAlignment<'_> { 55 | #[inline] 56 | fn run_verifier( 57 | v: &mut flatbuffers::Verifier, pos: usize 58 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 59 | use self::flatbuffers::Verifiable; 60 | v.visit_table(pos)? 61 | .visit_field::("width", Self::VT_WIDTH, false)? 62 | .finish(); 63 | Ok(()) 64 | } 65 | } 66 | pub struct FixedAlignmentArgs<'a> { 67 | pub width: Option<&'a BitWidth>, 68 | } 69 | impl<'a> Default for FixedAlignmentArgs<'a> { 70 | #[inline] 71 | fn default() -> Self { 72 | FixedAlignmentArgs { 73 | width: None, 74 | } 75 | } 76 | } 77 | 78 | pub struct FixedAlignmentBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 79 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 80 | start_: flatbuffers::WIPOffset, 81 | } 82 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> FixedAlignmentBuilder<'a, 'b, A> { 83 | #[inline] 84 | pub fn add_width(&mut self, width: &BitWidth) { 85 | self.fbb_.push_slot_always::<&BitWidth>(FixedAlignment::VT_WIDTH, width); 86 | } 87 | #[inline] 88 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> FixedAlignmentBuilder<'a, 'b, A> { 89 | let start = _fbb.start_table(); 90 | FixedAlignmentBuilder { 91 | fbb_: _fbb, 92 | start_: start, 93 | } 94 | } 95 | #[inline] 96 | pub fn finish(self) -> flatbuffers::WIPOffset> { 97 | let o = self.fbb_.end_table(self.start_); 98 | flatbuffers::WIPOffset::new(o.value()) 99 | } 100 | } 101 | 102 | impl core::fmt::Debug for FixedAlignment<'_> { 103 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 104 | let mut ds = f.debug_struct("FixedAlignment"); 105 | ds.field("width", &self.width()); 106 | ds.finish() 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/float_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum FloatOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct Float<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for Float<'a> { 20 | type Inner = Float<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> Float<'a> { 28 | pub const VT_WIDTH: flatbuffers::VOffsetT = 4; 29 | 30 | #[inline] 31 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 32 | Float { _tab: table } 33 | } 34 | #[allow(unused_mut)] 35 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 36 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 37 | args: &'args FloatArgs<'args> 38 | ) -> flatbuffers::WIPOffset> { 39 | let mut builder = FloatBuilder::new(_fbb); 40 | if let Some(x) = args.width { builder.add_width(x); } 41 | builder.finish() 42 | } 43 | 44 | 45 | #[inline] 46 | pub fn width(&self) -> Option<&'a BitWidth> { 47 | // Safety: 48 | // Created from valid Table for this object 49 | // which contains a valid value in this slot 50 | unsafe { self._tab.get::(Float::VT_WIDTH, None)} 51 | } 52 | } 53 | 54 | impl flatbuffers::Verifiable for Float<'_> { 55 | #[inline] 56 | fn run_verifier( 57 | v: &mut flatbuffers::Verifier, pos: usize 58 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 59 | use self::flatbuffers::Verifiable; 60 | v.visit_table(pos)? 61 | .visit_field::("width", Self::VT_WIDTH, false)? 62 | .finish(); 63 | Ok(()) 64 | } 65 | } 66 | pub struct FloatArgs<'a> { 67 | pub width: Option<&'a BitWidth>, 68 | } 69 | impl<'a> Default for FloatArgs<'a> { 70 | #[inline] 71 | fn default() -> Self { 72 | FloatArgs { 73 | width: None, 74 | } 75 | } 76 | } 77 | 78 | pub struct FloatBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 79 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 80 | start_: flatbuffers::WIPOffset, 81 | } 82 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> FloatBuilder<'a, 'b, A> { 83 | #[inline] 84 | pub fn add_width(&mut self, width: &BitWidth) { 85 | self.fbb_.push_slot_always::<&BitWidth>(Float::VT_WIDTH, width); 86 | } 87 | #[inline] 88 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> FloatBuilder<'a, 'b, A> { 89 | let start = _fbb.start_table(); 90 | FloatBuilder { 91 | fbb_: _fbb, 92 | start_: start, 93 | } 94 | } 95 | #[inline] 96 | pub fn finish(self) -> flatbuffers::WIPOffset> { 97 | let o = self.fbb_.end_table(self.start_); 98 | flatbuffers::WIPOffset::new(o.value()) 99 | } 100 | } 101 | 102 | impl core::fmt::Debug for Float<'_> { 103 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 104 | let mut ds = f.debug_struct("Float"); 105 | ds.field("width", &self.width()); 106 | ds.finish() 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/integer_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum IntegerOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct Integer<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for Integer<'a> { 20 | type Inner = Integer<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> Integer<'a> { 28 | pub const VT_WIDTH: flatbuffers::VOffsetT = 4; 29 | pub const VT_SIGNED: flatbuffers::VOffsetT = 6; 30 | 31 | #[inline] 32 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 33 | Integer { _tab: table } 34 | } 35 | #[allow(unused_mut)] 36 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 37 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 38 | args: &'args IntegerArgs<'args> 39 | ) -> flatbuffers::WIPOffset> { 40 | let mut builder = IntegerBuilder::new(_fbb); 41 | if let Some(x) = args.width { builder.add_width(x); } 42 | builder.add_signed(args.signed); 43 | builder.finish() 44 | } 45 | 46 | 47 | #[inline] 48 | pub fn width(&self) -> Option<&'a BitWidth> { 49 | // Safety: 50 | // Created from valid Table for this object 51 | // which contains a valid value in this slot 52 | unsafe { self._tab.get::(Integer::VT_WIDTH, None)} 53 | } 54 | #[inline] 55 | pub fn signed(&self) -> bool { 56 | // Safety: 57 | // Created from valid Table for this object 58 | // which contains a valid value in this slot 59 | unsafe { self._tab.get::(Integer::VT_SIGNED, Some(false)).unwrap()} 60 | } 61 | } 62 | 63 | impl flatbuffers::Verifiable for Integer<'_> { 64 | #[inline] 65 | fn run_verifier( 66 | v: &mut flatbuffers::Verifier, pos: usize 67 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 68 | use self::flatbuffers::Verifiable; 69 | v.visit_table(pos)? 70 | .visit_field::("width", Self::VT_WIDTH, false)? 71 | .visit_field::("signed", Self::VT_SIGNED, false)? 72 | .finish(); 73 | Ok(()) 74 | } 75 | } 76 | pub struct IntegerArgs<'a> { 77 | pub width: Option<&'a BitWidth>, 78 | pub signed: bool, 79 | } 80 | impl<'a> Default for IntegerArgs<'a> { 81 | #[inline] 82 | fn default() -> Self { 83 | IntegerArgs { 84 | width: None, 85 | signed: false, 86 | } 87 | } 88 | } 89 | 90 | pub struct IntegerBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 91 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 92 | start_: flatbuffers::WIPOffset, 93 | } 94 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> IntegerBuilder<'a, 'b, A> { 95 | #[inline] 96 | pub fn add_width(&mut self, width: &BitWidth) { 97 | self.fbb_.push_slot_always::<&BitWidth>(Integer::VT_WIDTH, width); 98 | } 99 | #[inline] 100 | pub fn add_signed(&mut self, signed: bool) { 101 | self.fbb_.push_slot::(Integer::VT_SIGNED, signed, false); 102 | } 103 | #[inline] 104 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> IntegerBuilder<'a, 'b, A> { 105 | let start = _fbb.start_table(); 106 | IntegerBuilder { 107 | fbb_: _fbb, 108 | start_: start, 109 | } 110 | } 111 | #[inline] 112 | pub fn finish(self) -> flatbuffers::WIPOffset> { 113 | let o = self.fbb_.end_table(self.start_); 114 | flatbuffers::WIPOffset::new(o.value()) 115 | } 116 | } 117 | 118 | impl core::fmt::Debug for Integer<'_> { 119 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 120 | let mut ds = f.debug_struct("Integer"); 121 | ds.field("width", &self.width()); 122 | ds.field("signed", &self.signed()); 123 | ds.finish() 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/location_class_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 13 | pub const ENUM_MIN_LOCATION_CLASS: u8 = 0; 14 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 15 | pub const ENUM_MAX_LOCATION_CLASS: u8 = 2; 16 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 17 | #[allow(non_camel_case_types)] 18 | pub const ENUM_VALUES_LOCATION_CLASS: [LocationClass; 3] = [ 19 | LocationClass::NONE, 20 | LocationClass::RegisterLocation, 21 | LocationClass::StackLocation, 22 | ]; 23 | 24 | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] 25 | #[repr(transparent)] 26 | pub struct LocationClass(pub u8); 27 | #[allow(non_upper_case_globals)] 28 | impl LocationClass { 29 | pub const NONE: Self = Self(0); 30 | pub const RegisterLocation: Self = Self(1); 31 | pub const StackLocation: Self = Self(2); 32 | 33 | pub const ENUM_MIN: u8 = 0; 34 | pub const ENUM_MAX: u8 = 2; 35 | pub const ENUM_VALUES: &'static [Self] = &[ 36 | Self::NONE, 37 | Self::RegisterLocation, 38 | Self::StackLocation, 39 | ]; 40 | /// Returns the variant's name or "" if unknown. 41 | pub fn variant_name(self) -> Option<&'static str> { 42 | match self { 43 | Self::NONE => Some("NONE"), 44 | Self::RegisterLocation => Some("RegisterLocation"), 45 | Self::StackLocation => Some("StackLocation"), 46 | _ => None, 47 | } 48 | } 49 | } 50 | impl core::fmt::Debug for LocationClass { 51 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 52 | if let Some(name) = self.variant_name() { 53 | f.write_str(name) 54 | } else { 55 | f.write_fmt(format_args!("", self.0)) 56 | } 57 | } 58 | } 59 | impl<'a> flatbuffers::Follow<'a> for LocationClass { 60 | type Inner = Self; 61 | #[inline] 62 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 63 | let b = flatbuffers::read_scalar_at::(buf, loc); 64 | Self(b) 65 | } 66 | } 67 | 68 | impl flatbuffers::Push for LocationClass { 69 | type Output = LocationClass; 70 | #[inline] 71 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 72 | flatbuffers::emplace_scalar::(dst, self.0); 73 | } 74 | } 75 | 76 | impl flatbuffers::EndianScalar for LocationClass { 77 | type Scalar = u8; 78 | #[inline] 79 | fn to_little_endian(self) -> u8 { 80 | self.0.to_le() 81 | } 82 | #[inline] 83 | #[allow(clippy::wrong_self_convention)] 84 | fn from_little_endian(v: u8) -> Self { 85 | let b = u8::from_le(v); 86 | Self(b) 87 | } 88 | } 89 | 90 | impl<'a> flatbuffers::Verifiable for LocationClass { 91 | #[inline] 92 | fn run_verifier( 93 | v: &mut flatbuffers::Verifier, pos: usize 94 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 95 | use self::flatbuffers::Verifiable; 96 | u8::run_verifier(v, pos) 97 | } 98 | } 99 | 100 | impl flatbuffers::SimpleToVerifyInSlice for LocationClass {} 101 | pub struct LocationClassUnionTableOffset {} 102 | 103 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/metadata_modifier_class_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum MetadataModifierClassOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct MetadataModifierClass<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for MetadataModifierClass<'a> { 20 | type Inner = MetadataModifierClass<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> MetadataModifierClass<'a> { 28 | pub const VT_KEY: flatbuffers::VOffsetT = 4; 29 | pub const VT_VALUE: flatbuffers::VOffsetT = 6; 30 | 31 | #[inline] 32 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 33 | MetadataModifierClass { _tab: table } 34 | } 35 | #[allow(unused_mut)] 36 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 37 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 38 | args: &'args MetadataModifierClassArgs<'args> 39 | ) -> flatbuffers::WIPOffset> { 40 | let mut builder = MetadataModifierClassBuilder::new(_fbb); 41 | if let Some(x) = args.value { builder.add_value(x); } 42 | if let Some(x) = args.key { builder.add_key(x); } 43 | builder.finish() 44 | } 45 | 46 | 47 | #[inline] 48 | pub fn key(&self) -> Option<&'a str> { 49 | // Safety: 50 | // Created from valid Table for this object 51 | // which contains a valid value in this slot 52 | unsafe { self._tab.get::>(MetadataModifierClass::VT_KEY, None)} 53 | } 54 | #[inline] 55 | pub fn value(&self) -> Option> { 56 | // Safety: 57 | // Created from valid Table for this object 58 | // which contains a valid value in this slot 59 | unsafe { self._tab.get::>>(MetadataModifierClass::VT_VALUE, None)} 60 | } 61 | } 62 | 63 | impl flatbuffers::Verifiable for MetadataModifierClass<'_> { 64 | #[inline] 65 | fn run_verifier( 66 | v: &mut flatbuffers::Verifier, pos: usize 67 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 68 | use self::flatbuffers::Verifiable; 69 | v.visit_table(pos)? 70 | .visit_field::>("key", Self::VT_KEY, false)? 71 | .visit_field::>>("value", Self::VT_VALUE, false)? 72 | .finish(); 73 | Ok(()) 74 | } 75 | } 76 | pub struct MetadataModifierClassArgs<'a> { 77 | pub key: Option>, 78 | pub value: Option>>, 79 | } 80 | impl<'a> Default for MetadataModifierClassArgs<'a> { 81 | #[inline] 82 | fn default() -> Self { 83 | MetadataModifierClassArgs { 84 | key: None, 85 | value: None, 86 | } 87 | } 88 | } 89 | 90 | pub struct MetadataModifierClassBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 91 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 92 | start_: flatbuffers::WIPOffset, 93 | } 94 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> MetadataModifierClassBuilder<'a, 'b, A> { 95 | #[inline] 96 | pub fn add_key(&mut self, key: flatbuffers::WIPOffset<&'b str>) { 97 | self.fbb_.push_slot_always::>(MetadataModifierClass::VT_KEY, key); 98 | } 99 | #[inline] 100 | pub fn add_value(&mut self, value: flatbuffers::WIPOffset>) { 101 | self.fbb_.push_slot_always::>(MetadataModifierClass::VT_VALUE, value); 102 | } 103 | #[inline] 104 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> MetadataModifierClassBuilder<'a, 'b, A> { 105 | let start = _fbb.start_table(); 106 | MetadataModifierClassBuilder { 107 | fbb_: _fbb, 108 | start_: start, 109 | } 110 | } 111 | #[inline] 112 | pub fn finish(self) -> flatbuffers::WIPOffset> { 113 | let o = self.fbb_.end_table(self.start_); 114 | flatbuffers::WIPOffset::new(o.value()) 115 | } 116 | } 117 | 118 | impl core::fmt::Debug for MetadataModifierClass<'_> { 119 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 120 | let mut ds = f.debug_struct("MetadataModifierClass"); 121 | ds.field("key", &self.key()); 122 | ds.field("value", &self.value()); 123 | ds.finish() 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/pointer_addressing_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 13 | pub const ENUM_MIN_POINTER_ADDRESSING: i8 = 0; 14 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 15 | pub const ENUM_MAX_POINTER_ADDRESSING: i8 = 2; 16 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 17 | #[allow(non_camel_case_types)] 18 | pub const ENUM_VALUES_POINTER_ADDRESSING: [PointerAddressing; 3] = [ 19 | PointerAddressing::Absolute, 20 | PointerAddressing::RelativeBase, 21 | PointerAddressing::RelativeSelf, 22 | ]; 23 | 24 | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] 25 | #[repr(transparent)] 26 | pub struct PointerAddressing(pub i8); 27 | #[allow(non_upper_case_globals)] 28 | impl PointerAddressing { 29 | pub const Absolute: Self = Self(0); 30 | pub const RelativeBase: Self = Self(1); 31 | pub const RelativeSelf: Self = Self(2); 32 | 33 | pub const ENUM_MIN: i8 = 0; 34 | pub const ENUM_MAX: i8 = 2; 35 | pub const ENUM_VALUES: &'static [Self] = &[ 36 | Self::Absolute, 37 | Self::RelativeBase, 38 | Self::RelativeSelf, 39 | ]; 40 | /// Returns the variant's name or "" if unknown. 41 | pub fn variant_name(self) -> Option<&'static str> { 42 | match self { 43 | Self::Absolute => Some("Absolute"), 44 | Self::RelativeBase => Some("RelativeBase"), 45 | Self::RelativeSelf => Some("RelativeSelf"), 46 | _ => None, 47 | } 48 | } 49 | } 50 | impl core::fmt::Debug for PointerAddressing { 51 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 52 | if let Some(name) = self.variant_name() { 53 | f.write_str(name) 54 | } else { 55 | f.write_fmt(format_args!("", self.0)) 56 | } 57 | } 58 | } 59 | impl<'a> flatbuffers::Follow<'a> for PointerAddressing { 60 | type Inner = Self; 61 | #[inline] 62 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 63 | let b = flatbuffers::read_scalar_at::(buf, loc); 64 | Self(b) 65 | } 66 | } 67 | 68 | impl flatbuffers::Push for PointerAddressing { 69 | type Output = PointerAddressing; 70 | #[inline] 71 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 72 | flatbuffers::emplace_scalar::(dst, self.0); 73 | } 74 | } 75 | 76 | impl flatbuffers::EndianScalar for PointerAddressing { 77 | type Scalar = i8; 78 | #[inline] 79 | fn to_little_endian(self) -> i8 { 80 | self.0.to_le() 81 | } 82 | #[inline] 83 | #[allow(clippy::wrong_self_convention)] 84 | fn from_little_endian(v: i8) -> Self { 85 | let b = i8::from_le(v); 86 | Self(b) 87 | } 88 | } 89 | 90 | impl<'a> flatbuffers::Verifiable for PointerAddressing { 91 | #[inline] 92 | fn run_verifier( 93 | v: &mut flatbuffers::Verifier, pos: usize 94 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 95 | use self::flatbuffers::Verifiable; 96 | i8::run_verifier(v, pos) 97 | } 98 | } 99 | 100 | impl flatbuffers::SimpleToVerifyInSlice for PointerAddressing {} 101 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/referrer_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum ReferrerOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct Referrer<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for Referrer<'a> { 20 | type Inner = Referrer<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> Referrer<'a> { 28 | pub const VT_GUID: flatbuffers::VOffsetT = 4; 29 | pub const VT_NAME: flatbuffers::VOffsetT = 6; 30 | 31 | #[inline] 32 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 33 | Referrer { _tab: table } 34 | } 35 | #[allow(unused_mut)] 36 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 37 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 38 | args: &'args ReferrerArgs<'args> 39 | ) -> flatbuffers::WIPOffset> { 40 | let mut builder = ReferrerBuilder::new(_fbb); 41 | if let Some(x) = args.name { builder.add_name(x); } 42 | if let Some(x) = args.guid { builder.add_guid(x); } 43 | builder.finish() 44 | } 45 | 46 | 47 | #[inline] 48 | pub fn guid(&self) -> Option<&'a str> { 49 | // Safety: 50 | // Created from valid Table for this object 51 | // which contains a valid value in this slot 52 | unsafe { self._tab.get::>(Referrer::VT_GUID, None)} 53 | } 54 | #[inline] 55 | pub fn name(&self) -> Option<&'a str> { 56 | // Safety: 57 | // Created from valid Table for this object 58 | // which contains a valid value in this slot 59 | unsafe { self._tab.get::>(Referrer::VT_NAME, None)} 60 | } 61 | } 62 | 63 | impl flatbuffers::Verifiable for Referrer<'_> { 64 | #[inline] 65 | fn run_verifier( 66 | v: &mut flatbuffers::Verifier, pos: usize 67 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 68 | use self::flatbuffers::Verifiable; 69 | v.visit_table(pos)? 70 | .visit_field::>("guid", Self::VT_GUID, false)? 71 | .visit_field::>("name", Self::VT_NAME, false)? 72 | .finish(); 73 | Ok(()) 74 | } 75 | } 76 | pub struct ReferrerArgs<'a> { 77 | pub guid: Option>, 78 | pub name: Option>, 79 | } 80 | impl<'a> Default for ReferrerArgs<'a> { 81 | #[inline] 82 | fn default() -> Self { 83 | ReferrerArgs { 84 | guid: None, 85 | name: None, 86 | } 87 | } 88 | } 89 | 90 | pub struct ReferrerBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 91 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 92 | start_: flatbuffers::WIPOffset, 93 | } 94 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> ReferrerBuilder<'a, 'b, A> { 95 | #[inline] 96 | pub fn add_guid(&mut self, guid: flatbuffers::WIPOffset<&'b str>) { 97 | self.fbb_.push_slot_always::>(Referrer::VT_GUID, guid); 98 | } 99 | #[inline] 100 | pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { 101 | self.fbb_.push_slot_always::>(Referrer::VT_NAME, name); 102 | } 103 | #[inline] 104 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> ReferrerBuilder<'a, 'b, A> { 105 | let start = _fbb.start_table(); 106 | ReferrerBuilder { 107 | fbb_: _fbb, 108 | start_: start, 109 | } 110 | } 111 | #[inline] 112 | pub fn finish(self) -> flatbuffers::WIPOffset> { 113 | let o = self.fbb_.end_table(self.start_); 114 | flatbuffers::WIPOffset::new(o.value()) 115 | } 116 | } 117 | 118 | impl core::fmt::Debug for Referrer<'_> { 119 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 120 | let mut ds = f.debug_struct("Referrer"); 121 | ds.field("guid", &self.guid()); 122 | ds.field("name", &self.name()); 123 | ds.finish() 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/register_location_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum RegisterLocationOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct RegisterLocation<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for RegisterLocation<'a> { 20 | type Inner = RegisterLocation<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> RegisterLocation<'a> { 28 | pub const VT_ID: flatbuffers::VOffsetT = 4; 29 | 30 | #[inline] 31 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 32 | RegisterLocation { _tab: table } 33 | } 34 | #[allow(unused_mut)] 35 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 36 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 37 | args: &'args RegisterLocationArgs 38 | ) -> flatbuffers::WIPOffset> { 39 | let mut builder = RegisterLocationBuilder::new(_fbb); 40 | builder.add_id(args.id); 41 | builder.finish() 42 | } 43 | 44 | 45 | #[inline] 46 | pub fn id(&self) -> u64 { 47 | // Safety: 48 | // Created from valid Table for this object 49 | // which contains a valid value in this slot 50 | unsafe { self._tab.get::(RegisterLocation::VT_ID, Some(0)).unwrap()} 51 | } 52 | } 53 | 54 | impl flatbuffers::Verifiable for RegisterLocation<'_> { 55 | #[inline] 56 | fn run_verifier( 57 | v: &mut flatbuffers::Verifier, pos: usize 58 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 59 | use self::flatbuffers::Verifiable; 60 | v.visit_table(pos)? 61 | .visit_field::("id", Self::VT_ID, false)? 62 | .finish(); 63 | Ok(()) 64 | } 65 | } 66 | pub struct RegisterLocationArgs { 67 | pub id: u64, 68 | } 69 | impl<'a> Default for RegisterLocationArgs { 70 | #[inline] 71 | fn default() -> Self { 72 | RegisterLocationArgs { 73 | id: 0, 74 | } 75 | } 76 | } 77 | 78 | pub struct RegisterLocationBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 79 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 80 | start_: flatbuffers::WIPOffset, 81 | } 82 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> RegisterLocationBuilder<'a, 'b, A> { 83 | #[inline] 84 | pub fn add_id(&mut self, id: u64) { 85 | self.fbb_.push_slot::(RegisterLocation::VT_ID, id, 0); 86 | } 87 | #[inline] 88 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> RegisterLocationBuilder<'a, 'b, A> { 89 | let start = _fbb.start_table(); 90 | RegisterLocationBuilder { 91 | fbb_: _fbb, 92 | start_: start, 93 | } 94 | } 95 | #[inline] 96 | pub fn finish(self) -> flatbuffers::WIPOffset> { 97 | let o = self.fbb_.end_table(self.start_); 98 | flatbuffers::WIPOffset::new(o.value()) 99 | } 100 | } 101 | 102 | impl core::fmt::Debug for RegisterLocation<'_> { 103 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 104 | let mut ds = f.debug_struct("RegisterLocation"); 105 | ds.field("id", &self.id()); 106 | ds.finish() 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/stack_location_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum StackLocationOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct StackLocation<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for StackLocation<'a> { 20 | type Inner = StackLocation<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> StackLocation<'a> { 28 | pub const VT_OFFSET: flatbuffers::VOffsetT = 4; 29 | 30 | #[inline] 31 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 32 | StackLocation { _tab: table } 33 | } 34 | #[allow(unused_mut)] 35 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 36 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 37 | args: &'args StackLocationArgs<'args> 38 | ) -> flatbuffers::WIPOffset> { 39 | let mut builder = StackLocationBuilder::new(_fbb); 40 | if let Some(x) = args.offset { builder.add_offset(x); } 41 | builder.finish() 42 | } 43 | 44 | 45 | #[inline] 46 | pub fn offset(&self) -> &'a BitOffset { 47 | // Safety: 48 | // Created from valid Table for this object 49 | // which contains a valid value in this slot 50 | unsafe { self._tab.get::(StackLocation::VT_OFFSET, None).unwrap()} 51 | } 52 | } 53 | 54 | impl flatbuffers::Verifiable for StackLocation<'_> { 55 | #[inline] 56 | fn run_verifier( 57 | v: &mut flatbuffers::Verifier, pos: usize 58 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 59 | use self::flatbuffers::Verifiable; 60 | v.visit_table(pos)? 61 | .visit_field::("offset", Self::VT_OFFSET, true)? 62 | .finish(); 63 | Ok(()) 64 | } 65 | } 66 | pub struct StackLocationArgs<'a> { 67 | pub offset: Option<&'a BitOffset>, 68 | } 69 | impl<'a> Default for StackLocationArgs<'a> { 70 | #[inline] 71 | fn default() -> Self { 72 | StackLocationArgs { 73 | offset: None, // required field 74 | } 75 | } 76 | } 77 | 78 | pub struct StackLocationBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 79 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 80 | start_: flatbuffers::WIPOffset, 81 | } 82 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> StackLocationBuilder<'a, 'b, A> { 83 | #[inline] 84 | pub fn add_offset(&mut self, offset: &BitOffset) { 85 | self.fbb_.push_slot_always::<&BitOffset>(StackLocation::VT_OFFSET, offset); 86 | } 87 | #[inline] 88 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> StackLocationBuilder<'a, 'b, A> { 89 | let start = _fbb.start_table(); 90 | StackLocationBuilder { 91 | fbb_: _fbb, 92 | start_: start, 93 | } 94 | } 95 | #[inline] 96 | pub fn finish(self) -> flatbuffers::WIPOffset> { 97 | let o = self.fbb_.end_table(self.start_); 98 | self.fbb_.required(o, StackLocation::VT_OFFSET,"offset"); 99 | flatbuffers::WIPOffset::new(o.value()) 100 | } 101 | } 102 | 103 | impl core::fmt::Debug for StackLocation<'_> { 104 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 105 | let mut ds = f.debug_struct("StackLocation"); 106 | ds.field("offset", &self.offset()); 107 | ds.finish() 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/structure_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum StructureOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct Structure<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for Structure<'a> { 20 | type Inner = Structure<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> Structure<'a> { 28 | pub const VT_MEMBERS: flatbuffers::VOffsetT = 4; 29 | 30 | #[inline] 31 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 32 | Structure { _tab: table } 33 | } 34 | #[allow(unused_mut)] 35 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 36 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 37 | args: &'args StructureArgs<'args> 38 | ) -> flatbuffers::WIPOffset> { 39 | let mut builder = StructureBuilder::new(_fbb); 40 | if let Some(x) = args.members { builder.add_members(x); } 41 | builder.finish() 42 | } 43 | 44 | 45 | #[inline] 46 | pub fn members(&self) -> Option>>> { 47 | // Safety: 48 | // Created from valid Table for this object 49 | // which contains a valid value in this slot 50 | unsafe { self._tab.get::>>>(Structure::VT_MEMBERS, None)} 51 | } 52 | } 53 | 54 | impl flatbuffers::Verifiable for Structure<'_> { 55 | #[inline] 56 | fn run_verifier( 57 | v: &mut flatbuffers::Verifier, pos: usize 58 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 59 | use self::flatbuffers::Verifiable; 60 | v.visit_table(pos)? 61 | .visit_field::>>>("members", Self::VT_MEMBERS, false)? 62 | .finish(); 63 | Ok(()) 64 | } 65 | } 66 | pub struct StructureArgs<'a> { 67 | pub members: Option>>>>, 68 | } 69 | impl<'a> Default for StructureArgs<'a> { 70 | #[inline] 71 | fn default() -> Self { 72 | StructureArgs { 73 | members: None, 74 | } 75 | } 76 | } 77 | 78 | pub struct StructureBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 79 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 80 | start_: flatbuffers::WIPOffset, 81 | } 82 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> StructureBuilder<'a, 'b, A> { 83 | #[inline] 84 | pub fn add_members(&mut self, members: flatbuffers::WIPOffset>>>) { 85 | self.fbb_.push_slot_always::>(Structure::VT_MEMBERS, members); 86 | } 87 | #[inline] 88 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> StructureBuilder<'a, 'b, A> { 89 | let start = _fbb.start_table(); 90 | StructureBuilder { 91 | fbb_: _fbb, 92 | start_: start, 93 | } 94 | } 95 | #[inline] 96 | pub fn finish(self) -> flatbuffers::WIPOffset> { 97 | let o = self.fbb_.end_table(self.start_); 98 | flatbuffers::WIPOffset::new(o.value()) 99 | } 100 | } 101 | 102 | impl core::fmt::Debug for Structure<'_> { 103 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 104 | let mut ds = f.debug_struct("Structure"); 105 | ds.field("members", &self.members()); 106 | ds.finish() 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/structure_member_modifiers_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | #[allow(non_upper_case_globals)] 13 | mod bitflags_structure_member_modifiers { 14 | flatbuffers::bitflags::bitflags! { 15 | #[derive(Default)] 16 | pub struct StructureMemberModifiers: u8 { 17 | const Internal = 1; 18 | const Flattened = 2; 19 | } 20 | } 21 | } 22 | pub use self::bitflags_structure_member_modifiers::StructureMemberModifiers; 23 | 24 | impl<'a> flatbuffers::Follow<'a> for StructureMemberModifiers { 25 | type Inner = Self; 26 | #[inline] 27 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 28 | let b = flatbuffers::read_scalar_at::(buf, loc); 29 | // Safety: 30 | // This is safe because we know bitflags is implemented with a repr transparent uint of the correct size. 31 | // from_bits_unchecked will be replaced by an equivalent but safe from_bits_retain in bitflags 2.0 32 | // https://github.com/bitflags/bitflags/issues/262 33 | Self::from_bits_unchecked(b) 34 | } 35 | } 36 | 37 | impl flatbuffers::Push for StructureMemberModifiers { 38 | type Output = StructureMemberModifiers; 39 | #[inline] 40 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 41 | flatbuffers::emplace_scalar::(dst, self.bits()); 42 | } 43 | } 44 | 45 | impl flatbuffers::EndianScalar for StructureMemberModifiers { 46 | type Scalar = u8; 47 | #[inline] 48 | fn to_little_endian(self) -> u8 { 49 | self.bits().to_le() 50 | } 51 | #[inline] 52 | #[allow(clippy::wrong_self_convention)] 53 | fn from_little_endian(v: u8) -> Self { 54 | let b = u8::from_le(v); 55 | // Safety: 56 | // This is safe because we know bitflags is implemented with a repr transparent uint of the correct size. 57 | // from_bits_unchecked will be replaced by an equivalent but safe from_bits_retain in bitflags 2.0 58 | // https://github.com/bitflags/bitflags/issues/262 59 | unsafe { Self::from_bits_unchecked(b) } 60 | } 61 | } 62 | 63 | impl<'a> flatbuffers::Verifiable for StructureMemberModifiers { 64 | #[inline] 65 | fn run_verifier( 66 | v: &mut flatbuffers::Verifier, pos: usize 67 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 68 | use self::flatbuffers::Verifiable; 69 | u8::run_verifier(v, pos) 70 | } 71 | } 72 | 73 | impl flatbuffers::SimpleToVerifyInSlice for StructureMemberModifiers {} 74 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/type_alignment_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 13 | pub const ENUM_MIN_TYPE_ALIGNMENT: u8 = 0; 14 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 15 | pub const ENUM_MAX_TYPE_ALIGNMENT: u8 = 2; 16 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 17 | #[allow(non_camel_case_types)] 18 | pub const ENUM_VALUES_TYPE_ALIGNMENT: [TypeAlignment; 3] = [ 19 | TypeAlignment::NONE, 20 | TypeAlignment::AccessAlignment, 21 | TypeAlignment::FixedAlignment, 22 | ]; 23 | 24 | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] 25 | #[repr(transparent)] 26 | pub struct TypeAlignment(pub u8); 27 | #[allow(non_upper_case_globals)] 28 | impl TypeAlignment { 29 | pub const NONE: Self = Self(0); 30 | pub const AccessAlignment: Self = Self(1); 31 | pub const FixedAlignment: Self = Self(2); 32 | 33 | pub const ENUM_MIN: u8 = 0; 34 | pub const ENUM_MAX: u8 = 2; 35 | pub const ENUM_VALUES: &'static [Self] = &[ 36 | Self::NONE, 37 | Self::AccessAlignment, 38 | Self::FixedAlignment, 39 | ]; 40 | /// Returns the variant's name or "" if unknown. 41 | pub fn variant_name(self) -> Option<&'static str> { 42 | match self { 43 | Self::NONE => Some("NONE"), 44 | Self::AccessAlignment => Some("AccessAlignment"), 45 | Self::FixedAlignment => Some("FixedAlignment"), 46 | _ => None, 47 | } 48 | } 49 | } 50 | impl core::fmt::Debug for TypeAlignment { 51 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 52 | if let Some(name) = self.variant_name() { 53 | f.write_str(name) 54 | } else { 55 | f.write_fmt(format_args!("", self.0)) 56 | } 57 | } 58 | } 59 | impl<'a> flatbuffers::Follow<'a> for TypeAlignment { 60 | type Inner = Self; 61 | #[inline] 62 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 63 | let b = flatbuffers::read_scalar_at::(buf, loc); 64 | Self(b) 65 | } 66 | } 67 | 68 | impl flatbuffers::Push for TypeAlignment { 69 | type Output = TypeAlignment; 70 | #[inline] 71 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 72 | flatbuffers::emplace_scalar::(dst, self.0); 73 | } 74 | } 75 | 76 | impl flatbuffers::EndianScalar for TypeAlignment { 77 | type Scalar = u8; 78 | #[inline] 79 | fn to_little_endian(self) -> u8 { 80 | self.0.to_le() 81 | } 82 | #[inline] 83 | #[allow(clippy::wrong_self_convention)] 84 | fn from_little_endian(v: u8) -> Self { 85 | let b = u8::from_le(v); 86 | Self(b) 87 | } 88 | } 89 | 90 | impl<'a> flatbuffers::Verifiable for TypeAlignment { 91 | #[inline] 92 | fn run_verifier( 93 | v: &mut flatbuffers::Verifier, pos: usize 94 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 95 | use self::flatbuffers::Verifiable; 96 | u8::run_verifier(v, pos) 97 | } 98 | } 99 | 100 | impl flatbuffers::SimpleToVerifyInSlice for TypeAlignment {} 101 | pub struct TypeAlignmentUnionTableOffset {} 102 | 103 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/type_class_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 13 | pub const ENUM_MIN_TYPE_CLASS: u8 = 0; 14 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 15 | pub const ENUM_MAX_TYPE_CLASS: u8 = 12; 16 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 17 | #[allow(non_camel_case_types)] 18 | pub const ENUM_VALUES_TYPE_CLASS: [TypeClass; 13] = [ 19 | TypeClass::NONE, 20 | TypeClass::Void, 21 | TypeClass::Boolean, 22 | TypeClass::Integer, 23 | TypeClass::Character, 24 | TypeClass::Float, 25 | TypeClass::Pointer, 26 | TypeClass::Array, 27 | TypeClass::Structure, 28 | TypeClass::Enumeration, 29 | TypeClass::Union, 30 | TypeClass::Function, 31 | TypeClass::Referrer, 32 | ]; 33 | 34 | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] 35 | #[repr(transparent)] 36 | pub struct TypeClass(pub u8); 37 | #[allow(non_upper_case_globals)] 38 | impl TypeClass { 39 | pub const NONE: Self = Self(0); 40 | pub const Void: Self = Self(1); 41 | pub const Boolean: Self = Self(2); 42 | pub const Integer: Self = Self(3); 43 | pub const Character: Self = Self(4); 44 | pub const Float: Self = Self(5); 45 | pub const Pointer: Self = Self(6); 46 | pub const Array: Self = Self(7); 47 | pub const Structure: Self = Self(8); 48 | pub const Enumeration: Self = Self(9); 49 | pub const Union: Self = Self(10); 50 | pub const Function: Self = Self(11); 51 | pub const Referrer: Self = Self(12); 52 | 53 | pub const ENUM_MIN: u8 = 0; 54 | pub const ENUM_MAX: u8 = 12; 55 | pub const ENUM_VALUES: &'static [Self] = &[ 56 | Self::NONE, 57 | Self::Void, 58 | Self::Boolean, 59 | Self::Integer, 60 | Self::Character, 61 | Self::Float, 62 | Self::Pointer, 63 | Self::Array, 64 | Self::Structure, 65 | Self::Enumeration, 66 | Self::Union, 67 | Self::Function, 68 | Self::Referrer, 69 | ]; 70 | /// Returns the variant's name or "" if unknown. 71 | pub fn variant_name(self) -> Option<&'static str> { 72 | match self { 73 | Self::NONE => Some("NONE"), 74 | Self::Void => Some("Void"), 75 | Self::Boolean => Some("Boolean"), 76 | Self::Integer => Some("Integer"), 77 | Self::Character => Some("Character"), 78 | Self::Float => Some("Float"), 79 | Self::Pointer => Some("Pointer"), 80 | Self::Array => Some("Array"), 81 | Self::Structure => Some("Structure"), 82 | Self::Enumeration => Some("Enumeration"), 83 | Self::Union => Some("Union"), 84 | Self::Function => Some("Function"), 85 | Self::Referrer => Some("Referrer"), 86 | _ => None, 87 | } 88 | } 89 | } 90 | impl core::fmt::Debug for TypeClass { 91 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 92 | if let Some(name) = self.variant_name() { 93 | f.write_str(name) 94 | } else { 95 | f.write_fmt(format_args!("", self.0)) 96 | } 97 | } 98 | } 99 | impl<'a> flatbuffers::Follow<'a> for TypeClass { 100 | type Inner = Self; 101 | #[inline] 102 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 103 | let b = flatbuffers::read_scalar_at::(buf, loc); 104 | Self(b) 105 | } 106 | } 107 | 108 | impl flatbuffers::Push for TypeClass { 109 | type Output = TypeClass; 110 | #[inline] 111 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 112 | flatbuffers::emplace_scalar::(dst, self.0); 113 | } 114 | } 115 | 116 | impl flatbuffers::EndianScalar for TypeClass { 117 | type Scalar = u8; 118 | #[inline] 119 | fn to_little_endian(self) -> u8 { 120 | self.0.to_le() 121 | } 122 | #[inline] 123 | #[allow(clippy::wrong_self_convention)] 124 | fn from_little_endian(v: u8) -> Self { 125 | let b = u8::from_le(v); 126 | Self(b) 127 | } 128 | } 129 | 130 | impl<'a> flatbuffers::Verifiable for TypeClass { 131 | #[inline] 132 | fn run_verifier( 133 | v: &mut flatbuffers::Verifier, pos: usize 134 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 135 | use self::flatbuffers::Verifiable; 136 | u8::run_verifier(v, pos) 137 | } 138 | } 139 | 140 | impl flatbuffers::SimpleToVerifyInSlice for TypeClass {} 141 | pub struct TypeClassUnionTableOffset {} 142 | 143 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/type_modifier_class_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 13 | pub const ENUM_MIN_TYPE_MODIFIER_CLASS: u8 = 0; 14 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 15 | pub const ENUM_MAX_TYPE_MODIFIER_CLASS: u8 = 4; 16 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 17 | #[allow(non_camel_case_types)] 18 | pub const ENUM_VALUES_TYPE_MODIFIER_CLASS: [TypeModifierClass; 5] = [ 19 | TypeModifierClass::NONE, 20 | TypeModifierClass::ConstantModifierClass, 21 | TypeModifierClass::VolatileModifierClass, 22 | TypeModifierClass::DescriptorModifierClass, 23 | TypeModifierClass::MetadataModifierClass, 24 | ]; 25 | 26 | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] 27 | #[repr(transparent)] 28 | pub struct TypeModifierClass(pub u8); 29 | #[allow(non_upper_case_globals)] 30 | impl TypeModifierClass { 31 | pub const NONE: Self = Self(0); 32 | pub const ConstantModifierClass: Self = Self(1); 33 | pub const VolatileModifierClass: Self = Self(2); 34 | pub const DescriptorModifierClass: Self = Self(3); 35 | pub const MetadataModifierClass: Self = Self(4); 36 | 37 | pub const ENUM_MIN: u8 = 0; 38 | pub const ENUM_MAX: u8 = 4; 39 | pub const ENUM_VALUES: &'static [Self] = &[ 40 | Self::NONE, 41 | Self::ConstantModifierClass, 42 | Self::VolatileModifierClass, 43 | Self::DescriptorModifierClass, 44 | Self::MetadataModifierClass, 45 | ]; 46 | /// Returns the variant's name or "" if unknown. 47 | pub fn variant_name(self) -> Option<&'static str> { 48 | match self { 49 | Self::NONE => Some("NONE"), 50 | Self::ConstantModifierClass => Some("ConstantModifierClass"), 51 | Self::VolatileModifierClass => Some("VolatileModifierClass"), 52 | Self::DescriptorModifierClass => Some("DescriptorModifierClass"), 53 | Self::MetadataModifierClass => Some("MetadataModifierClass"), 54 | _ => None, 55 | } 56 | } 57 | } 58 | impl core::fmt::Debug for TypeModifierClass { 59 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 60 | if let Some(name) = self.variant_name() { 61 | f.write_str(name) 62 | } else { 63 | f.write_fmt(format_args!("", self.0)) 64 | } 65 | } 66 | } 67 | impl<'a> flatbuffers::Follow<'a> for TypeModifierClass { 68 | type Inner = Self; 69 | #[inline] 70 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 71 | let b = flatbuffers::read_scalar_at::(buf, loc); 72 | Self(b) 73 | } 74 | } 75 | 76 | impl flatbuffers::Push for TypeModifierClass { 77 | type Output = TypeModifierClass; 78 | #[inline] 79 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 80 | flatbuffers::emplace_scalar::(dst, self.0); 81 | } 82 | } 83 | 84 | impl flatbuffers::EndianScalar for TypeModifierClass { 85 | type Scalar = u8; 86 | #[inline] 87 | fn to_little_endian(self) -> u8 { 88 | self.0.to_le() 89 | } 90 | #[inline] 91 | #[allow(clippy::wrong_self_convention)] 92 | fn from_little_endian(v: u8) -> Self { 93 | let b = u8::from_le(v); 94 | Self(b) 95 | } 96 | } 97 | 98 | impl<'a> flatbuffers::Verifiable for TypeModifierClass { 99 | #[inline] 100 | fn run_verifier( 101 | v: &mut flatbuffers::Verifier, pos: usize 102 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 103 | use self::flatbuffers::Verifiable; 104 | u8::run_verifier(v, pos) 105 | } 106 | } 107 | 108 | impl flatbuffers::SimpleToVerifyInSlice for TypeModifierClass {} 109 | pub struct TypeModifierClassUnionTableOffset {} 110 | 111 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/union_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum UnionOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct Union<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for Union<'a> { 20 | type Inner = Union<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> Union<'a> { 28 | pub const VT_MEMBERS: flatbuffers::VOffsetT = 4; 29 | 30 | #[inline] 31 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 32 | Union { _tab: table } 33 | } 34 | #[allow(unused_mut)] 35 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 36 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 37 | args: &'args UnionArgs<'args> 38 | ) -> flatbuffers::WIPOffset> { 39 | let mut builder = UnionBuilder::new(_fbb); 40 | if let Some(x) = args.members { builder.add_members(x); } 41 | builder.finish() 42 | } 43 | 44 | 45 | #[inline] 46 | pub fn members(&self) -> Option>>> { 47 | // Safety: 48 | // Created from valid Table for this object 49 | // which contains a valid value in this slot 50 | unsafe { self._tab.get::>>>(Union::VT_MEMBERS, None)} 51 | } 52 | } 53 | 54 | impl flatbuffers::Verifiable for Union<'_> { 55 | #[inline] 56 | fn run_verifier( 57 | v: &mut flatbuffers::Verifier, pos: usize 58 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 59 | use self::flatbuffers::Verifiable; 60 | v.visit_table(pos)? 61 | .visit_field::>>>("members", Self::VT_MEMBERS, false)? 62 | .finish(); 63 | Ok(()) 64 | } 65 | } 66 | pub struct UnionArgs<'a> { 67 | pub members: Option>>>>, 68 | } 69 | impl<'a> Default for UnionArgs<'a> { 70 | #[inline] 71 | fn default() -> Self { 72 | UnionArgs { 73 | members: None, 74 | } 75 | } 76 | } 77 | 78 | pub struct UnionBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 79 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 80 | start_: flatbuffers::WIPOffset, 81 | } 82 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> UnionBuilder<'a, 'b, A> { 83 | #[inline] 84 | pub fn add_members(&mut self, members: flatbuffers::WIPOffset>>>) { 85 | self.fbb_.push_slot_always::>(Union::VT_MEMBERS, members); 86 | } 87 | #[inline] 88 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> UnionBuilder<'a, 'b, A> { 89 | let start = _fbb.start_table(); 90 | UnionBuilder { 91 | fbb_: _fbb, 92 | start_: start, 93 | } 94 | } 95 | #[inline] 96 | pub fn finish(self) -> flatbuffers::WIPOffset> { 97 | let o = self.fbb_.end_table(self.start_); 98 | flatbuffers::WIPOffset::new(o.value()) 99 | } 100 | } 101 | 102 | impl core::fmt::Debug for Union<'_> { 103 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 104 | let mut ds = f.debug_struct("Union"); 105 | ds.field("members", &self.members()); 106 | ds.finish() 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/union_member_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum UnionMemberOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct UnionMember<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for UnionMember<'a> { 20 | type Inner = UnionMember<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> UnionMember<'a> { 28 | pub const VT_NAME: flatbuffers::VOffsetT = 4; 29 | pub const VT_TYPE_: flatbuffers::VOffsetT = 6; 30 | 31 | #[inline] 32 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 33 | UnionMember { _tab: table } 34 | } 35 | #[allow(unused_mut)] 36 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 37 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 38 | args: &'args UnionMemberArgs<'args> 39 | ) -> flatbuffers::WIPOffset> { 40 | let mut builder = UnionMemberBuilder::new(_fbb); 41 | if let Some(x) = args.type_ { builder.add_type_(x); } 42 | if let Some(x) = args.name { builder.add_name(x); } 43 | builder.finish() 44 | } 45 | 46 | 47 | #[inline] 48 | pub fn name(&self) -> Option<&'a str> { 49 | // Safety: 50 | // Created from valid Table for this object 51 | // which contains a valid value in this slot 52 | unsafe { self._tab.get::>(UnionMember::VT_NAME, None)} 53 | } 54 | #[inline] 55 | pub fn type_(&self) -> Type<'a> { 56 | // Safety: 57 | // Created from valid Table for this object 58 | // which contains a valid value in this slot 59 | unsafe { self._tab.get::>(UnionMember::VT_TYPE_, None).unwrap()} 60 | } 61 | } 62 | 63 | impl flatbuffers::Verifiable for UnionMember<'_> { 64 | #[inline] 65 | fn run_verifier( 66 | v: &mut flatbuffers::Verifier, pos: usize 67 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 68 | use self::flatbuffers::Verifiable; 69 | v.visit_table(pos)? 70 | .visit_field::>("name", Self::VT_NAME, false)? 71 | .visit_field::>("type_", Self::VT_TYPE_, true)? 72 | .finish(); 73 | Ok(()) 74 | } 75 | } 76 | pub struct UnionMemberArgs<'a> { 77 | pub name: Option>, 78 | pub type_: Option>>, 79 | } 80 | impl<'a> Default for UnionMemberArgs<'a> { 81 | #[inline] 82 | fn default() -> Self { 83 | UnionMemberArgs { 84 | name: None, 85 | type_: None, // required field 86 | } 87 | } 88 | } 89 | 90 | pub struct UnionMemberBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 91 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 92 | start_: flatbuffers::WIPOffset, 93 | } 94 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> UnionMemberBuilder<'a, 'b, A> { 95 | #[inline] 96 | pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { 97 | self.fbb_.push_slot_always::>(UnionMember::VT_NAME, name); 98 | } 99 | #[inline] 100 | pub fn add_type_(&mut self, type_: flatbuffers::WIPOffset>) { 101 | self.fbb_.push_slot_always::>(UnionMember::VT_TYPE_, type_); 102 | } 103 | #[inline] 104 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> UnionMemberBuilder<'a, 'b, A> { 105 | let start = _fbb.start_table(); 106 | UnionMemberBuilder { 107 | fbb_: _fbb, 108 | start_: start, 109 | } 110 | } 111 | #[inline] 112 | pub fn finish(self) -> flatbuffers::WIPOffset> { 113 | let o = self.fbb_.end_table(self.start_); 114 | self.fbb_.required(o, UnionMember::VT_TYPE_,"type_"); 115 | flatbuffers::WIPOffset::new(o.value()) 116 | } 117 | } 118 | 119 | impl core::fmt::Debug for UnionMember<'_> { 120 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 121 | let mut ds = f.debug_struct("UnionMember"); 122 | ds.field("name", &self.name()); 123 | ds.field("type_", &self.type_()); 124 | ds.finish() 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/unsigned_bit_offset_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | // struct UnsignedBitOffset, aligned to 8 13 | #[repr(transparent)] 14 | #[derive(Clone, Copy, PartialEq)] 15 | pub struct UnsignedBitOffset(pub [u8; 8]); 16 | impl Default for UnsignedBitOffset { 17 | fn default() -> Self { 18 | Self([0; 8]) 19 | } 20 | } 21 | impl core::fmt::Debug for UnsignedBitOffset { 22 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 23 | f.debug_struct("UnsignedBitOffset") 24 | .field("value", &self.value()) 25 | .finish() 26 | } 27 | } 28 | 29 | impl flatbuffers::SimpleToVerifyInSlice for UnsignedBitOffset {} 30 | impl<'a> flatbuffers::Follow<'a> for UnsignedBitOffset { 31 | type Inner = &'a UnsignedBitOffset; 32 | #[inline] 33 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 34 | <&'a UnsignedBitOffset>::follow(buf, loc) 35 | } 36 | } 37 | impl<'a> flatbuffers::Follow<'a> for &'a UnsignedBitOffset { 38 | type Inner = &'a UnsignedBitOffset; 39 | #[inline] 40 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 41 | flatbuffers::follow_cast_ref::(buf, loc) 42 | } 43 | } 44 | impl<'b> flatbuffers::Push for UnsignedBitOffset { 45 | type Output = UnsignedBitOffset; 46 | #[inline] 47 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 48 | let src = ::core::slice::from_raw_parts(self as *const UnsignedBitOffset as *const u8, Self::size()); 49 | dst.copy_from_slice(src); 50 | } 51 | } 52 | 53 | impl<'a> flatbuffers::Verifiable for UnsignedBitOffset { 54 | #[inline] 55 | fn run_verifier( 56 | v: &mut flatbuffers::Verifier, pos: usize 57 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 58 | use self::flatbuffers::Verifiable; 59 | v.in_buffer::(pos) 60 | } 61 | } 62 | 63 | impl<'a> UnsignedBitOffset { 64 | #[allow(clippy::too_many_arguments)] 65 | pub fn new( 66 | value: u64, 67 | ) -> Self { 68 | let mut s = Self([0; 8]); 69 | s.set_value(value); 70 | s 71 | } 72 | 73 | pub fn value(&self) -> u64 { 74 | let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); 75 | // Safety: 76 | // Created from a valid Table for this object 77 | // Which contains a valid value in this slot 78 | EndianScalar::from_little_endian(unsafe { 79 | core::ptr::copy_nonoverlapping( 80 | self.0[0..].as_ptr(), 81 | mem.as_mut_ptr() as *mut u8, 82 | core::mem::size_of::<::Scalar>(), 83 | ); 84 | mem.assume_init() 85 | }) 86 | } 87 | 88 | pub fn set_value(&mut self, x: u64) { 89 | let x_le = x.to_little_endian(); 90 | // Safety: 91 | // Created from a valid Table for this object 92 | // Which contains a valid value in this slot 93 | unsafe { 94 | core::ptr::copy_nonoverlapping( 95 | &x_le as *const _ as *const u8, 96 | self.0[0..].as_mut_ptr(), 97 | core::mem::size_of::<::Scalar>(), 98 | ); 99 | } 100 | } 101 | 102 | } 103 | 104 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/void_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum VoidOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct Void<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for Void<'a> { 20 | type Inner = Void<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> Void<'a> { 28 | 29 | #[inline] 30 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 31 | Void { _tab: table } 32 | } 33 | #[allow(unused_mut)] 34 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 35 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 36 | _args: &'args VoidArgs 37 | ) -> flatbuffers::WIPOffset> { 38 | let mut builder = VoidBuilder::new(_fbb); 39 | builder.finish() 40 | } 41 | 42 | } 43 | 44 | impl flatbuffers::Verifiable for Void<'_> { 45 | #[inline] 46 | fn run_verifier( 47 | v: &mut flatbuffers::Verifier, pos: usize 48 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 49 | use self::flatbuffers::Verifiable; 50 | v.visit_table(pos)? 51 | .finish(); 52 | Ok(()) 53 | } 54 | } 55 | pub struct VoidArgs { 56 | } 57 | impl<'a> Default for VoidArgs { 58 | #[inline] 59 | fn default() -> Self { 60 | VoidArgs { 61 | } 62 | } 63 | } 64 | 65 | pub struct VoidBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 66 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 67 | start_: flatbuffers::WIPOffset, 68 | } 69 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> VoidBuilder<'a, 'b, A> { 70 | #[inline] 71 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> VoidBuilder<'a, 'b, A> { 72 | let start = _fbb.start_table(); 73 | VoidBuilder { 74 | fbb_: _fbb, 75 | start_: start, 76 | } 77 | } 78 | #[inline] 79 | pub fn finish(self) -> flatbuffers::WIPOffset> { 80 | let o = self.fbb_.end_table(self.start_); 81 | flatbuffers::WIPOffset::new(o.value()) 82 | } 83 | } 84 | 85 | impl core::fmt::Debug for Void<'_> { 86 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 87 | let mut ds = f.debug_struct("Void"); 88 | ds.finish() 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /rust/gen_flatbuffers/type_bin/volatile_modifier_class_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum VolatileModifierClassOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct VolatileModifierClass<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for VolatileModifierClass<'a> { 20 | type Inner = VolatileModifierClass<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> VolatileModifierClass<'a> { 28 | 29 | #[inline] 30 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 31 | VolatileModifierClass { _tab: table } 32 | } 33 | #[allow(unused_mut)] 34 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 35 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 36 | _args: &'args VolatileModifierClassArgs 37 | ) -> flatbuffers::WIPOffset> { 38 | let mut builder = VolatileModifierClassBuilder::new(_fbb); 39 | builder.finish() 40 | } 41 | 42 | } 43 | 44 | impl flatbuffers::Verifiable for VolatileModifierClass<'_> { 45 | #[inline] 46 | fn run_verifier( 47 | v: &mut flatbuffers::Verifier, pos: usize 48 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 49 | use self::flatbuffers::Verifiable; 50 | v.visit_table(pos)? 51 | .finish(); 52 | Ok(()) 53 | } 54 | } 55 | pub struct VolatileModifierClassArgs { 56 | } 57 | impl<'a> Default for VolatileModifierClassArgs { 58 | #[inline] 59 | fn default() -> Self { 60 | VolatileModifierClassArgs { 61 | } 62 | } 63 | } 64 | 65 | pub struct VolatileModifierClassBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 66 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 67 | start_: flatbuffers::WIPOffset, 68 | } 69 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> VolatileModifierClassBuilder<'a, 'b, A> { 70 | #[inline] 71 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> VolatileModifierClassBuilder<'a, 'b, A> { 72 | let start = _fbb.start_table(); 73 | VolatileModifierClassBuilder { 74 | fbb_: _fbb, 75 | start_: start, 76 | } 77 | } 78 | #[inline] 79 | pub fn finish(self) -> flatbuffers::WIPOffset> { 80 | let o = self.fbb_.end_table(self.start_); 81 | flatbuffers::WIPOffset::new(o.value()) 82 | } 83 | } 84 | 85 | impl core::fmt::Debug for VolatileModifierClass<'_> { 86 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 87 | let mut ds = f.debug_struct("VolatileModifierClass"); 88 | ds.finish() 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /rust/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod signature; 2 | pub mod symbol; 3 | pub mod r#type; 4 | 5 | #[allow(warnings)] 6 | #[rustfmt::skip] 7 | mod gen_flatbuffers; 8 | 9 | use gen_flatbuffers::sig_bin as fb_sig; 10 | use gen_flatbuffers::symbol_bin as fb_symbol; 11 | use gen_flatbuffers::type_bin as fb_type; 12 | 13 | impl From for gen_flatbuffers::type_bin::BitWidth { 14 | fn from(value: u16) -> Self { 15 | Self::new(value) 16 | } 17 | } 18 | 19 | impl From<&gen_flatbuffers::type_bin::BitWidth> for u16 { 20 | fn from(value: &gen_flatbuffers::type_bin::BitWidth) -> Self { 21 | value.value() 22 | } 23 | } 24 | 25 | impl From for gen_flatbuffers::type_bin::BitSize { 26 | fn from(value: u64) -> Self { 27 | Self::new(value) 28 | } 29 | } 30 | 31 | impl From<&gen_flatbuffers::type_bin::BitSize> for u64 { 32 | fn from(value: &gen_flatbuffers::type_bin::BitSize) -> Self { 33 | value.value() 34 | } 35 | } 36 | 37 | impl From for gen_flatbuffers::type_bin::UnsignedBitOffset { 38 | fn from(value: u64) -> Self { 39 | Self::new(value) 40 | } 41 | } 42 | 43 | impl From<&gen_flatbuffers::type_bin::UnsignedBitOffset> for u64 { 44 | fn from(value: &gen_flatbuffers::type_bin::UnsignedBitOffset) -> Self { 45 | value.value() 46 | } 47 | } 48 | 49 | impl From for gen_flatbuffers::type_bin::BitOffset { 50 | fn from(value: i64) -> Self { 51 | Self::new(value) 52 | } 53 | } 54 | 55 | impl From<&gen_flatbuffers::type_bin::BitOffset> for i64 { 56 | fn from(value: &gen_flatbuffers::type_bin::BitOffset) -> Self { 57 | value.value() 58 | } 59 | } 60 | 61 | impl From for gen_flatbuffers::type_bin::BitShift { 62 | fn from(value: i64) -> Self { 63 | Self::new(value) 64 | } 65 | } 66 | 67 | impl From<&gen_flatbuffers::type_bin::BitShift> for i64 { 68 | fn from(value: &gen_flatbuffers::type_bin::BitShift) -> Self { 69 | value.value() 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /rust/signature/basic_block.rs: -------------------------------------------------------------------------------- 1 | use crate::fb_sig as fb; 2 | use flatbuffers::{FlatBufferBuilder, WIPOffset}; 3 | use std::fmt::{Display, Formatter}; 4 | use std::str::FromStr; 5 | use uuid::uuid; 6 | use uuid::Uuid; 7 | 8 | pub const NAMESPACE_BASICBLOCK: Uuid = uuid!("0192a178-7a5f-7936-8653-3cbaa7d6afe7"); 9 | 10 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] 11 | pub struct BasicBlockGUID { 12 | guid: Uuid, 13 | } 14 | 15 | impl BasicBlockGUID { 16 | pub fn as_bytes(&self) -> &[u8] { 17 | self.guid.as_bytes() 18 | } 19 | } 20 | 21 | impl FromStr for BasicBlockGUID { 22 | type Err = uuid::Error; 23 | 24 | fn from_str(s: &str) -> Result { 25 | Uuid::parse_str(s).map(Into::into) 26 | } 27 | } 28 | 29 | impl From<&[u8]> for BasicBlockGUID { 30 | fn from(value: &[u8]) -> Self { 31 | Self { 32 | guid: Uuid::new_v5(&NAMESPACE_BASICBLOCK, value), 33 | } 34 | } 35 | } 36 | 37 | impl From for BasicBlockGUID { 38 | fn from(value: Uuid) -> Self { 39 | Self { guid: value } 40 | } 41 | } 42 | 43 | impl Display for BasicBlockGUID { 44 | fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { 45 | Display::fmt(&self.guid, f) 46 | } 47 | } 48 | 49 | #[derive(Clone, Debug, Eq, PartialEq, Hash)] 50 | pub struct BasicBlock { 51 | pub guid: BasicBlockGUID, 52 | } 53 | 54 | impl BasicBlock { 55 | pub fn new(guid: BasicBlockGUID) -> Self { 56 | Self { guid } 57 | } 58 | 59 | // TODO: Error checking... 60 | pub fn from_bytes(buf: &[u8]) -> Option { 61 | flatbuffers::root::(buf) 62 | .ok() 63 | .map(Into::into) 64 | } 65 | 66 | pub fn to_bytes(&self) -> Vec { 67 | let mut builder = FlatBufferBuilder::new(); 68 | let fb_bb = self.create(&mut builder); 69 | builder.finish_minimal(fb_bb); 70 | builder.finished_data().to_vec() 71 | } 72 | 73 | pub(crate) fn create<'a>( 74 | &self, 75 | builder: &mut FlatBufferBuilder<'a>, 76 | ) -> WIPOffset> { 77 | let guid = builder.create_string(&self.guid.to_string()); 78 | fb::BasicBlock::create(builder, &fb::BasicBlockArgs { guid: Some(guid) }) 79 | } 80 | } 81 | 82 | impl From> for BasicBlock { 83 | fn from(value: fb::BasicBlock<'_>) -> Self { 84 | let guid = value.guid().parse::().unwrap(); 85 | Self { guid } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /rust/signature/function/constraints.rs: -------------------------------------------------------------------------------- 1 | use crate::fb_sig as fb; 2 | use crate::signature::function::FunctionGUID; 3 | use crate::symbol::Symbol; 4 | use flatbuffers::{FlatBufferBuilder, WIPOffset}; 5 | use std::collections::HashSet; 6 | 7 | #[derive(Clone, Debug, Eq, PartialEq, Hash)] 8 | pub struct FunctionConstraint { 9 | pub guid: Option, 10 | pub symbol: Option, 11 | pub offset: i64, 12 | } 13 | 14 | impl FunctionConstraint { 15 | pub fn create<'a>( 16 | &self, 17 | builder: &mut FlatBufferBuilder<'a>, 18 | ) -> WIPOffset> { 19 | let guid = self 20 | .guid 21 | .map(|guid| builder.create_string(&guid.to_string())); 22 | let symbol = self.symbol.as_ref().map(|symbol| symbol.create(builder)); 23 | fb::FunctionConstraint::create( 24 | builder, 25 | &fb::FunctionConstraintArgs { 26 | guid, 27 | symbol, 28 | offset: self.offset, 29 | }, 30 | ) 31 | } 32 | } 33 | 34 | impl From> for FunctionConstraint { 35 | fn from(value: fb::FunctionConstraint<'_>) -> Self { 36 | let guid = value 37 | .guid() 38 | .map(|guid| guid.parse::().unwrap()); 39 | Self { 40 | guid, 41 | symbol: value.symbol().map(Symbol::from), 42 | offset: value.offset(), 43 | } 44 | } 45 | } 46 | 47 | #[derive(Clone, Debug, Eq, PartialEq, Default)] 48 | pub struct FunctionConstraints { 49 | pub adjacent: HashSet, 50 | pub call_sites: HashSet, 51 | pub caller_sites: HashSet, 52 | } 53 | 54 | impl FunctionConstraints { 55 | pub fn create<'a>( 56 | &self, 57 | builder: &mut FlatBufferBuilder<'a>, 58 | ) -> WIPOffset> { 59 | let _adjacent: Vec<_> = self 60 | .adjacent 61 | .iter() 62 | .map(|constraint| constraint.create(builder)) 63 | .collect(); 64 | let adjacent = if _adjacent.is_empty() { 65 | None 66 | } else { 67 | Some(builder.create_vector(&_adjacent)) 68 | }; 69 | 70 | let _call_sites: Vec<_> = self 71 | .call_sites 72 | .iter() 73 | .map(|constraint| constraint.create(builder)) 74 | .collect(); 75 | let call_sites = if _call_sites.is_empty() { 76 | None 77 | } else { 78 | Some(builder.create_vector(&_call_sites)) 79 | }; 80 | 81 | let _caller_sites: Vec<_> = self 82 | .caller_sites 83 | .iter() 84 | .map(|constraint| constraint.create(builder)) 85 | .collect(); 86 | let caller_sites = if _caller_sites.is_empty() { 87 | None 88 | } else { 89 | Some(builder.create_vector(&_caller_sites)) 90 | }; 91 | 92 | fb::FunctionConstraints::create( 93 | builder, 94 | &fb::FunctionConstraintsArgs { 95 | adjacent, 96 | call_sites, 97 | caller_sites, 98 | }, 99 | ) 100 | } 101 | } 102 | 103 | impl From> for FunctionConstraints { 104 | fn from(value: fb::FunctionConstraints<'_>) -> Self { 105 | let adjacent: HashSet = value 106 | .adjacent() 107 | .unwrap_or_default() 108 | .iter() 109 | .map(|constraint| constraint.into()) 110 | .collect(); 111 | let call_sites: HashSet = value 112 | .call_sites() 113 | .unwrap_or_default() 114 | .iter() 115 | .map(|constraint| constraint.into()) 116 | .collect(); 117 | let caller_sites: HashSet = value 118 | .caller_sites() 119 | .unwrap_or_default() 120 | .iter() 121 | .map(|constraint| constraint.into()) 122 | .collect(); 123 | 124 | Self { 125 | adjacent, 126 | call_sites, 127 | caller_sites, 128 | } 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /rust/symbol.rs: -------------------------------------------------------------------------------- 1 | pub mod class; 2 | 3 | use crate::fb_symbol as fb; 4 | use crate::symbol::class::SymbolClass; 5 | use flatbuffers::{FlatBufferBuilder, WIPOffset}; 6 | 7 | pub use fb::SymbolModifiers; 8 | 9 | #[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] 10 | pub struct Symbol { 11 | pub name: String, 12 | pub modifiers: SymbolModifiers, 13 | pub class: SymbolClass, 14 | } 15 | 16 | impl Symbol { 17 | pub fn new(name: impl Into, class: SymbolClass, modifiers: SymbolModifiers) -> Self { 18 | Self { 19 | name: name.into(), 20 | modifiers, 21 | class, 22 | } 23 | } 24 | 25 | pub(crate) fn create<'a>( 26 | &self, 27 | builder: &mut FlatBufferBuilder<'a>, 28 | ) -> WIPOffset> { 29 | let name = builder.create_string(&self.name); 30 | let class_type = self.class.ty(); 31 | let class = self.class.create(builder); 32 | 33 | fb::Symbol::create( 34 | builder, 35 | &fb::SymbolArgs { 36 | name: Some(name), 37 | modifiers: self.modifiers, 38 | class_type, 39 | class: Some(class), 40 | }, 41 | ) 42 | } 43 | } 44 | 45 | impl From> for Symbol { 46 | fn from(value: fb::Symbol<'_>) -> Self { 47 | let name = value.name().unwrap().to_string(); 48 | // TODO: I would like this conversion to be on `SymbolClass` instead. 49 | let class = match value.class_type() { 50 | fb::SymbolClass::FunctionSymbolClass => { 51 | SymbolClass::from(value.class_as_function_symbol_class().unwrap()) 52 | } 53 | fb::SymbolClass::DataSymbolClass => { 54 | SymbolClass::from(value.class_as_data_symbol_class().unwrap()) 55 | } 56 | _ => unreachable!(), 57 | }; 58 | 59 | Self { 60 | name, 61 | modifiers: value.modifiers(), 62 | class, 63 | } 64 | } 65 | } 66 | 67 | #[cfg(test)] 68 | mod tests { 69 | use super::*; 70 | use flatbuffers::FlatBufferBuilder; 71 | 72 | #[test] 73 | fn it_works() { 74 | let mut builder = FlatBufferBuilder::with_capacity(100); 75 | let symbol = Symbol { 76 | name: "".to_string(), 77 | modifiers: SymbolModifiers::empty(), 78 | class: SymbolClass::Data, 79 | }; 80 | let _created_symbol = symbol.create(&mut builder); 81 | // TODO: Add actual tests. 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /rust/symbol/class.rs: -------------------------------------------------------------------------------- 1 | use flatbuffers::{FlatBufferBuilder, UnionWIPOffset, WIPOffset}; 2 | 3 | #[derive(Clone, Debug, Default)] 4 | pub struct FunctionSymbolClass; 5 | 6 | impl FunctionSymbolClass { 7 | pub(crate) fn create<'a>( 8 | &self, 9 | builder: &mut FlatBufferBuilder<'a>, 10 | ) -> WIPOffset> { 11 | crate::gen_flatbuffers::symbol_bin::FunctionSymbolClass::create( 12 | builder, 13 | &crate::gen_flatbuffers::symbol_bin::FunctionSymbolClassArgs {}, 14 | ) 15 | } 16 | } 17 | 18 | #[derive(Clone, Debug, Default)] 19 | pub struct DataSymbolClass; 20 | 21 | impl DataSymbolClass { 22 | fn create<'a>( 23 | &self, 24 | builder: &mut FlatBufferBuilder<'a>, 25 | ) -> WIPOffset> { 26 | crate::gen_flatbuffers::symbol_bin::DataSymbolClass::create( 27 | builder, 28 | &crate::gen_flatbuffers::symbol_bin::DataSymbolClassArgs {}, 29 | ) 30 | } 31 | } 32 | 33 | #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] 34 | pub enum SymbolClass { 35 | Function, 36 | Data, 37 | } 38 | 39 | impl SymbolClass { 40 | pub fn ty(&self) -> crate::gen_flatbuffers::symbol_bin::SymbolClass { 41 | match self { 42 | SymbolClass::Function => { 43 | crate::gen_flatbuffers::symbol_bin::SymbolClass::FunctionSymbolClass 44 | } 45 | SymbolClass::Data => crate::gen_flatbuffers::symbol_bin::SymbolClass::DataSymbolClass, 46 | } 47 | } 48 | 49 | pub fn create(&self, builder: &mut FlatBufferBuilder) -> WIPOffset { 50 | match self { 51 | SymbolClass::Function => FunctionSymbolClass.create(builder).as_union_value(), 52 | SymbolClass::Data => DataSymbolClass.create(builder).as_union_value(), 53 | } 54 | } 55 | } 56 | 57 | impl From> for SymbolClass { 58 | fn from(_value: crate::gen_flatbuffers::symbol_bin::FunctionSymbolClass<'_>) -> Self { 59 | Self::Function 60 | } 61 | } 62 | 63 | impl From> for SymbolClass { 64 | fn from(_value: crate::gen_flatbuffers::symbol_bin::DataSymbolClass<'_>) -> Self { 65 | Self::Data 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /rust/type/class/array.rs: -------------------------------------------------------------------------------- 1 | use bon::bon; 2 | 3 | use crate::fb_type as fb; 4 | use crate::r#type::Type; 5 | use flatbuffers::{FlatBufferBuilder, WIPOffset}; 6 | use rand::distributions::Standard; 7 | use rand::prelude::*; 8 | 9 | // We re-export bit flags as there is no need to wrap them. 10 | pub use fb::ArrayModifiers; 11 | 12 | #[derive(Clone, Debug, PartialEq, Eq, Hash)] 13 | pub struct ArrayClass { 14 | pub length: Option, 15 | pub member_type: Type, 16 | pub modifiers: ArrayModifiers, 17 | } 18 | 19 | #[bon] 20 | impl ArrayClass { 21 | #[builder] 22 | pub fn new(length: Option, member_type: Type, modifiers: Option) -> Self { 23 | Self { 24 | length, 25 | member_type, 26 | modifiers: modifiers.unwrap_or_default(), 27 | } 28 | } 29 | } 30 | 31 | impl ArrayClass { 32 | pub(crate) fn create<'a>( 33 | &self, 34 | builder: &mut FlatBufferBuilder<'a>, 35 | ) -> WIPOffset> { 36 | let member_type = self.member_type.create(builder); 37 | fb::Array::create( 38 | builder, 39 | &fb::ArrayArgs { 40 | type_: Some(member_type), 41 | // NOTE: 0 means the array is dynamically sized. 42 | // TODO: Is this correct? 43 | length: self.length.unwrap_or(0), 44 | modifiers: self.modifiers, 45 | }, 46 | ) 47 | } 48 | 49 | pub fn size(&self) -> Option { 50 | Some(self.length? * self.member_type.size()?) 51 | } 52 | } 53 | 54 | impl From> for ArrayClass { 55 | fn from(value: fb::Array<'_>) -> Self { 56 | Self { 57 | length: match value.length() { 58 | 0 => None, 59 | len => Some(len), 60 | }, 61 | member_type: value.type_().into(), 62 | modifiers: value.modifiers(), 63 | } 64 | } 65 | } 66 | 67 | impl Distribution for Standard { 68 | fn sample(&self, rng: &mut R) -> ArrayClass { 69 | let mut modifiers = ArrayModifiers::empty(); 70 | // 50% chance array is null terminated. 71 | modifiers.set(ArrayModifiers::NullTerminated, rng.gen_bool(0.5)); 72 | ArrayClass { 73 | length: rng.gen(), 74 | member_type: rng.gen(), 75 | modifiers, 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /rust/type/class/boolean.rs: -------------------------------------------------------------------------------- 1 | use crate::fb_type as fb; 2 | use bon::Builder; 3 | use flatbuffers::{FlatBufferBuilder, WIPOffset}; 4 | use rand::distributions::{Distribution, Standard}; 5 | use rand::Rng; 6 | 7 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Builder)] 8 | pub struct BooleanClass { 9 | pub width: Option, 10 | } 11 | 12 | impl BooleanClass { 13 | pub(crate) fn create<'a>( 14 | &self, 15 | builder: &mut FlatBufferBuilder<'a>, 16 | ) -> WIPOffset> { 17 | fb::Boolean::create( 18 | builder, 19 | &fb::BooleanArgs { 20 | width: self.width.map(Into::into).as_ref(), 21 | }, 22 | ) 23 | } 24 | 25 | pub fn size(&self) -> Option { 26 | self.width.map(|w| w as u64) 27 | } 28 | } 29 | 30 | impl From> for BooleanClass { 31 | fn from(value: fb::Boolean<'_>) -> Self { 32 | Self { 33 | width: value.width().map(Into::into), 34 | } 35 | } 36 | } 37 | 38 | impl Distribution for Standard { 39 | fn sample(&self, rng: &mut R) -> BooleanClass { 40 | // TODO: Maybe we should restrict this to "normal" widths? 41 | BooleanClass { width: rng.gen() } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /rust/type/class/character.rs: -------------------------------------------------------------------------------- 1 | use crate::fb_type as fb; 2 | use bon::Builder; 3 | use flatbuffers::{FlatBufferBuilder, WIPOffset}; 4 | use rand::distributions::{Distribution, Standard}; 5 | use rand::Rng; 6 | 7 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Builder)] 8 | pub struct CharacterClass { 9 | /// Width in bits 10 | pub width: Option, 11 | } 12 | 13 | impl CharacterClass { 14 | pub(crate) fn create<'a>( 15 | &self, 16 | builder: &mut FlatBufferBuilder<'a>, 17 | ) -> WIPOffset> { 18 | fb::Character::create( 19 | builder, 20 | &fb::CharacterArgs { 21 | width: self.width.map(Into::into).as_ref(), 22 | }, 23 | ) 24 | } 25 | 26 | pub fn size(&self) -> Option { 27 | self.width.map(|w| w as u64) 28 | } 29 | } 30 | 31 | impl From> for CharacterClass { 32 | fn from(value: fb::Character<'_>) -> Self { 33 | Self { 34 | width: value.width().map(Into::into), 35 | } 36 | } 37 | } 38 | 39 | impl Distribution for Standard { 40 | fn sample(&self, rng: &mut R) -> CharacterClass { 41 | // 90% chance this type will have a width. 42 | let width = match rng.gen_bool(0.9) { 43 | true => Some(rng.gen_range(1..=256)), 44 | false => None, 45 | }; 46 | CharacterClass { width } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /rust/type/class/enumeration.rs: -------------------------------------------------------------------------------- 1 | use bon::Builder; 2 | 3 | use crate::fb_type as fb; 4 | use crate::r#type::Type; 5 | use flatbuffers::{FlatBufferBuilder, WIPOffset}; 6 | use rand::distributions::{Alphanumeric, DistString, Distribution, Standard}; 7 | use rand::Rng; 8 | 9 | #[derive(Clone, Debug, PartialEq, Eq, Hash, Builder)] 10 | #[builder(on(String, into))] 11 | pub struct EnumerationMember { 12 | pub name: Option, 13 | pub constant: u64, 14 | } 15 | 16 | impl EnumerationMember { 17 | fn create<'a>( 18 | &self, 19 | builder: &mut FlatBufferBuilder<'a>, 20 | ) -> WIPOffset> { 21 | let name = self.name.as_ref().map(|n| builder.create_string(n)); 22 | fb::EnumerationMember::create( 23 | builder, 24 | &fb::EnumerationMemberArgs { 25 | name, 26 | constant: self.constant, 27 | }, 28 | ) 29 | } 30 | } 31 | 32 | impl From> for EnumerationMember { 33 | fn from(value: fb::EnumerationMember<'_>) -> Self { 34 | Self { 35 | name: value.name().map(str::to_string), 36 | constant: value.constant(), 37 | } 38 | } 39 | } 40 | 41 | impl Distribution for Standard { 42 | fn sample(&self, rng: &mut R) -> EnumerationMember { 43 | EnumerationMember { 44 | name: Some(Alphanumeric.sample_string(rng, 16)), 45 | constant: rng.gen(), 46 | } 47 | } 48 | } 49 | 50 | #[derive(Clone, Debug, PartialEq, Eq, Hash, Builder)] 51 | pub struct EnumerationClass { 52 | pub member_type: Type, 53 | pub members: Vec, 54 | } 55 | 56 | impl EnumerationClass { 57 | pub fn new(member_type: Type, members: Vec) -> Self { 58 | Self { 59 | member_type, 60 | members, 61 | } 62 | } 63 | } 64 | 65 | impl EnumerationClass { 66 | pub(crate) fn create<'a>( 67 | &self, 68 | builder: &mut FlatBufferBuilder<'a>, 69 | ) -> WIPOffset> { 70 | let enum_type = self.member_type.create(builder); 71 | // Resolve then create all member constants. Take the prior constant when `None`. 72 | let created_members: Vec<_> = self 73 | .members 74 | .iter() 75 | .map(|member| member.create(builder)) 76 | .collect(); 77 | let enum_members = builder.create_vector(&created_members); 78 | fb::Enumeration::create( 79 | builder, 80 | &fb::EnumerationArgs { 81 | member_type: Some(enum_type), 82 | members: Some(enum_members), 83 | }, 84 | ) 85 | } 86 | 87 | pub fn size(&self) -> Option { 88 | self.member_type.size() 89 | } 90 | } 91 | 92 | impl From> for EnumerationClass { 93 | fn from(value: fb::Enumeration<'_>) -> Self { 94 | Self { 95 | member_type: value.member_type().into(), 96 | members: value.members().unwrap().iter().map(Into::into).collect(), 97 | } 98 | } 99 | } 100 | 101 | impl Distribution for Standard { 102 | fn sample(&self, rng: &mut R) -> EnumerationClass { 103 | let rand_member_len = rng.gen_range(0..20); 104 | EnumerationClass { 105 | member_type: rng.gen(), 106 | members: rng.sample_iter(Standard).take(rand_member_len).collect(), 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /rust/type/class/float.rs: -------------------------------------------------------------------------------- 1 | use crate::fb_type as fb; 2 | use bon::Builder; 3 | use flatbuffers::{FlatBufferBuilder, WIPOffset}; 4 | use rand::distributions::{Distribution, Standard}; 5 | use rand::Rng; 6 | 7 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Builder)] 8 | pub struct FloatClass { 9 | /// Width in bits 10 | pub width: Option, 11 | } 12 | 13 | impl FloatClass { 14 | pub(crate) fn create<'a>( 15 | &self, 16 | builder: &mut FlatBufferBuilder<'a>, 17 | ) -> WIPOffset> { 18 | fb::Float::create( 19 | builder, 20 | &fb::FloatArgs { 21 | width: self.width.map(Into::into).as_ref(), 22 | }, 23 | ) 24 | } 25 | 26 | pub fn size(&self) -> Option { 27 | self.width.map(|w| w as u64) 28 | } 29 | } 30 | 31 | impl From> for FloatClass { 32 | fn from(value: fb::Float<'_>) -> Self { 33 | Self { 34 | width: value.width().map(Into::into), 35 | } 36 | } 37 | } 38 | 39 | impl Distribution for Standard { 40 | fn sample(&self, rng: &mut R) -> FloatClass { 41 | // 90% chance this type will have a width. 42 | let width = match rng.gen_bool(0.9) { 43 | true => Some(rng.gen_range(1..=256)), 44 | false => None, 45 | }; 46 | FloatClass { width } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /rust/type/class/integer.rs: -------------------------------------------------------------------------------- 1 | use crate::fb_type as fb; 2 | use bon::Builder; 3 | use flatbuffers::{FlatBufferBuilder, WIPOffset}; 4 | use rand::distributions::{Distribution, Standard}; 5 | use rand::Rng; 6 | 7 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Builder)] 8 | pub struct IntegerClass { 9 | /// Width in bits 10 | pub width: Option, 11 | pub signed: bool, 12 | } 13 | 14 | impl IntegerClass { 15 | pub(crate) fn create<'a>( 16 | &self, 17 | builder: &mut FlatBufferBuilder<'a>, 18 | ) -> WIPOffset> { 19 | fb::Integer::create( 20 | builder, 21 | &fb::IntegerArgs { 22 | width: self.width.map(Into::into).as_ref(), 23 | signed: self.signed, 24 | }, 25 | ) 26 | } 27 | 28 | pub fn size(&self) -> Option { 29 | self.width.map(|w| w as u64) 30 | } 31 | } 32 | 33 | impl From> for IntegerClass { 34 | fn from(value: fb::Integer<'_>) -> Self { 35 | Self { 36 | width: value.width().map(Into::into), 37 | signed: value.signed(), 38 | } 39 | } 40 | } 41 | 42 | impl Distribution for Standard { 43 | fn sample(&self, rng: &mut R) -> IntegerClass { 44 | // 90% chance this type will have a width. 45 | let width = match rng.gen_bool(0.9) { 46 | true => Some(rng.gen_range(1..=256)), 47 | false => None, 48 | }; 49 | IntegerClass { 50 | width, 51 | signed: rng.gen_bool(0.5), 52 | } 53 | } 54 | } 55 | 56 | #[cfg(test)] 57 | mod tests { 58 | use crate::r#type::class::{IntegerClass, TypeClass}; 59 | use crate::r#type::guid::TypeGUID; 60 | use crate::r#type::{Alignment, Type}; 61 | use uuid::{uuid, Uuid}; 62 | 63 | const INT_TYPE_UUID: Uuid = uuid!("ec8805ad-b101-5d8c-a033-c94610d036c1"); 64 | 65 | fn built_int_type() -> Type { 66 | let int_class = IntegerClass::builder().width(64).signed(true).build(); 67 | Type::builder() 68 | .name("my_int".to_owned()) 69 | .class(int_class) 70 | .build() 71 | } 72 | 73 | #[test] 74 | fn int_guid_v1() { 75 | assert_eq!(TypeGUID::from(INT_TYPE_UUID), built_int_type().into()); 76 | } 77 | 78 | #[test] 79 | fn int_type() { 80 | assert_eq!( 81 | Type { 82 | name: Some("my_int".to_owned()), 83 | class: Box::from(TypeClass::Integer(IntegerClass { 84 | width: Some(64), 85 | signed: true 86 | })), 87 | confidence: u8::MAX, 88 | modifiers: vec![], 89 | alignment: Alignment::Access, 90 | ancestors: vec![], 91 | }, 92 | built_int_type() 93 | ) 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /rust/type/class/pointer.rs: -------------------------------------------------------------------------------- 1 | use crate::fb_type as fb; 2 | use crate::r#type::Type; 3 | use bon::bon; 4 | use flatbuffers::{FlatBufferBuilder, WIPOffset}; 5 | use rand::distributions::{Distribution, Standard}; 6 | use rand::Rng; 7 | 8 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Default)] 9 | pub enum PointerAddressing { 10 | #[default] 11 | Absolute = 0, 12 | RelativeBase, 13 | RelativeSelf, 14 | } 15 | 16 | impl From for PointerAddressing { 17 | fn from(value: fb::PointerAddressing) -> Self { 18 | match value { 19 | fb::PointerAddressing::Absolute => PointerAddressing::Absolute, 20 | fb::PointerAddressing::RelativeBase => PointerAddressing::RelativeBase, 21 | fb::PointerAddressing::RelativeSelf => PointerAddressing::RelativeSelf, 22 | _ => unreachable!(), 23 | } 24 | } 25 | } 26 | 27 | impl From for fb::PointerAddressing { 28 | fn from(value: PointerAddressing) -> Self { 29 | match value { 30 | PointerAddressing::Absolute => Self::Absolute, 31 | PointerAddressing::RelativeBase => Self::RelativeBase, 32 | PointerAddressing::RelativeSelf => Self::RelativeSelf, 33 | } 34 | } 35 | } 36 | 37 | impl Distribution for Standard { 38 | fn sample(&self, rng: &mut R) -> PointerAddressing { 39 | match rng.gen_range(0..3) { 40 | 1 => PointerAddressing::RelativeBase, 41 | 0 => PointerAddressing::RelativeSelf, 42 | _ => PointerAddressing::Absolute, 43 | } 44 | } 45 | } 46 | 47 | #[derive(Clone, Debug, PartialEq, Eq, Hash)] 48 | pub struct PointerClass { 49 | pub width: Option, 50 | pub child_type: Type, 51 | pub addressing: PointerAddressing, 52 | // TODO: Pointer modifiers etc... 53 | } 54 | 55 | #[bon] 56 | impl PointerClass { 57 | #[builder] 58 | pub fn new( 59 | width: Option, 60 | child_type: Type, 61 | addressing: Option, 62 | ) -> Self { 63 | Self { 64 | width, 65 | child_type, 66 | addressing: addressing.unwrap_or_default(), 67 | } 68 | } 69 | } 70 | 71 | impl PointerClass { 72 | pub(crate) fn create<'a>( 73 | &self, 74 | builder: &mut FlatBufferBuilder<'a>, 75 | ) -> WIPOffset> { 76 | let child_type = self.child_type.create(builder); 77 | fb::Pointer::create( 78 | builder, 79 | &fb::PointerArgs { 80 | width: self.width.map(Into::into).as_ref(), 81 | // TODO: Shift 82 | shift: None, 83 | child: Some(child_type), 84 | 85 | addressing: self.addressing.into(), 86 | // TODO: Offset 87 | offset: None, 88 | }, 89 | ) 90 | } 91 | 92 | pub fn size(&self) -> Option { 93 | self.width.map(|w| w as u64) 94 | } 95 | } 96 | 97 | impl From> for PointerClass { 98 | fn from(value: fb::Pointer<'_>) -> Self { 99 | Self { 100 | width: value.width().map(Into::into), 101 | child_type: value.child().map(Into::into).unwrap(), 102 | addressing: value.addressing().into(), 103 | } 104 | } 105 | } 106 | 107 | impl Distribution for Standard { 108 | fn sample(&self, rng: &mut R) -> PointerClass { 109 | // 90% chance this type will have a width. 110 | let width = match rng.gen_bool(0.9) { 111 | true => Some(rng.gen_range(1..=256)), 112 | false => None, 113 | }; 114 | PointerClass { 115 | width, 116 | child_type: rng.gen(), 117 | addressing: rng.gen(), 118 | } 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /rust/type/class/referrer.rs: -------------------------------------------------------------------------------- 1 | use bon::Builder; 2 | 3 | use crate::fb_type as fb; 4 | use crate::r#type::guid::TypeGUID; 5 | use flatbuffers::{FlatBufferBuilder, WIPOffset}; 6 | use rand::distributions::{Alphanumeric, DistString, Distribution, Standard}; 7 | use rand::Rng; 8 | 9 | #[derive(Clone, Debug, PartialEq, Eq, Hash, Builder)] 10 | pub struct ReferrerClass { 11 | pub guid: Option, 12 | pub name: Option, 13 | } 14 | 15 | impl ReferrerClass { 16 | pub fn new(guid: Option, name: Option) -> Self { 17 | Self { guid, name } 18 | } 19 | 20 | pub(crate) fn create<'a>( 21 | &self, 22 | builder: &mut FlatBufferBuilder<'a>, 23 | ) -> WIPOffset> { 24 | let guid = self 25 | .guid 26 | .as_ref() 27 | .map(|x| builder.create_string(&x.to_string())); 28 | let name = self.name.as_ref().map(|x| builder.create_string(x)); 29 | fb::Referrer::create(builder, &fb::ReferrerArgs { guid, name }) 30 | } 31 | } 32 | 33 | // TODO: We really should make this TryFrom 34 | impl From> for ReferrerClass { 35 | fn from(value: fb::Referrer<'_>) -> Self { 36 | Self { 37 | guid: value.guid().map(|s| s.parse().unwrap()), 38 | name: value.name().map(|x| x.to_owned()), 39 | } 40 | } 41 | } 42 | 43 | impl Distribution for Standard { 44 | fn sample(&self, rng: &mut R) -> ReferrerClass { 45 | ReferrerClass { 46 | guid: rng.gen(), 47 | name: Some(Alphanumeric.sample_string(rng, 16)), 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /rust/type/class/structure.rs: -------------------------------------------------------------------------------- 1 | use bon::{bon, Builder}; 2 | 3 | use crate::fb_type as fb; 4 | use crate::r#type::Type; 5 | use flatbuffers::{FlatBufferBuilder, WIPOffset}; 6 | use rand::distributions::{Alphanumeric, DistString, Distribution, Standard}; 7 | use rand::Rng; 8 | 9 | // We re-export bit flags as there is no need to wrap them. 10 | pub use fb::StructureMemberModifiers; 11 | 12 | #[derive(Clone, Debug, PartialEq, Eq, Hash)] 13 | pub struct StructureMember { 14 | pub name: Option, 15 | pub offset: u64, 16 | pub ty: Type, 17 | pub modifiers: StructureMemberModifiers, 18 | } 19 | 20 | #[bon] 21 | impl StructureMember { 22 | #[builder] 23 | pub fn new>( 24 | name: Option, 25 | offset: u64, 26 | ty: Type, 27 | modifiers: Option, 28 | ) -> Self { 29 | Self { 30 | name: name.map(Into::into), 31 | offset, 32 | ty, 33 | modifiers: modifiers.unwrap_or_default(), 34 | } 35 | } 36 | } 37 | 38 | impl StructureMember { 39 | fn create<'a>( 40 | &self, 41 | builder: &mut FlatBufferBuilder<'a>, 42 | ) -> WIPOffset> { 43 | let name = self.name.as_ref().map(|n| builder.create_string(n)); 44 | let member_type = self.ty.create(builder); 45 | fb::StructureMember::create( 46 | builder, 47 | &fb::StructureMemberArgs { 48 | name, 49 | offset: Some(&self.offset.into()), 50 | type_: Some(member_type), 51 | modifiers: self.modifiers, 52 | }, 53 | ) 54 | } 55 | 56 | fn size(&self) -> Option { 57 | self.ty.size() 58 | } 59 | } 60 | 61 | impl From> for StructureMember { 62 | fn from(value: fb::StructureMember<'_>) -> Self { 63 | Self { 64 | name: value.name().map(str::to_string), 65 | offset: value.offset().into(), 66 | ty: value.type_().into(), 67 | modifiers: value.modifiers(), 68 | } 69 | } 70 | } 71 | 72 | impl Distribution for Standard { 73 | fn sample(&self, rng: &mut R) -> StructureMember { 74 | let mut modifiers = StructureMemberModifiers::empty(); 75 | // 50% chance structure member is internal. 76 | modifiers.set(StructureMemberModifiers::Internal, rng.gen_bool(0.5)); 77 | StructureMember { 78 | name: Some(Alphanumeric.sample_string(rng, 16)), 79 | offset: rng.gen(), 80 | // TODO: This is causing a recursion issue... 81 | ty: rng.gen(), 82 | modifiers, 83 | } 84 | } 85 | } 86 | 87 | #[derive(Clone, Debug, PartialEq, Eq, Hash, Builder)] 88 | pub struct StructureClass { 89 | pub members: Vec, 90 | } 91 | 92 | impl From> for StructureClass { 93 | fn from(value: fb::Structure<'_>) -> Self { 94 | Self { 95 | members: value.members().unwrap().iter().map(Into::into).collect(), 96 | } 97 | } 98 | } 99 | 100 | impl StructureClass { 101 | pub fn new(members: Vec) -> Self { 102 | Self { members } 103 | } 104 | } 105 | 106 | impl StructureClass { 107 | pub(crate) fn create<'a>( 108 | &self, 109 | builder: &mut FlatBufferBuilder<'a>, 110 | ) -> WIPOffset> { 111 | let created_members: Vec<_> = self 112 | .members 113 | .iter() 114 | .map(|member| member.create(builder)) 115 | .collect(); 116 | let struct_members = builder.create_vector(&created_members); 117 | fb::Structure::create( 118 | builder, 119 | &fb::StructureArgs { 120 | members: Some(struct_members), 121 | }, 122 | ) 123 | } 124 | 125 | pub fn size(&self) -> Option { 126 | self.members.iter().fold(None, |size, member| { 127 | // If an unknown member size is encountered, the structure size has to be unknown. 128 | Some((member.offset + member.size()?).max(size.unwrap_or(0))) 129 | }) 130 | } 131 | } 132 | 133 | impl Distribution for Standard { 134 | fn sample(&self, rng: &mut R) -> StructureClass { 135 | let rand_in_member_len = rng.gen_range(0..1); 136 | StructureClass { 137 | members: rng 138 | .sample_iter::(Standard) 139 | .take(rand_in_member_len) 140 | .collect(), 141 | } 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /rust/type/class/void.rs: -------------------------------------------------------------------------------- 1 | use crate::fb_type as fb; 2 | use flatbuffers::{FlatBufferBuilder, WIPOffset}; 3 | 4 | #[derive(Copy, Clone, Debug, PartialEq, Eq)] 5 | pub struct VoidClass; 6 | 7 | impl VoidClass { 8 | pub(crate) fn create<'a>( 9 | &self, 10 | builder: &mut FlatBufferBuilder<'a>, 11 | ) -> WIPOffset> { 12 | fb::Void::create(builder, &fb::VoidArgs {}) 13 | } 14 | } 15 | 16 | #[cfg(test)] 17 | mod tests { 18 | use crate::r#type::class::TypeClass; 19 | use crate::r#type::guid::TypeGUID; 20 | use crate::r#type::{Alignment, Type}; 21 | use uuid::{uuid, Uuid}; 22 | 23 | const VOID_TYPE_UUID: Uuid = uuid!("c37a394d-750b-5e89-b09e-539859c7a9bd"); 24 | 25 | fn built_void_type() -> Type { 26 | Type::builder() 27 | .name("my_void".to_owned()) 28 | .class(TypeClass::Void) 29 | .build() 30 | } 31 | 32 | #[test] 33 | fn void_guid_v1() { 34 | assert_eq!(TypeGUID::from(VOID_TYPE_UUID), built_void_type().into()); 35 | } 36 | 37 | #[test] 38 | fn void_type() { 39 | assert_eq!( 40 | Type { 41 | name: Some("my_void".to_owned()), 42 | class: Box::from(TypeClass::Void), 43 | confidence: u8::MAX, 44 | modifiers: vec![], 45 | alignment: Alignment::Access, 46 | ancestors: vec![], 47 | }, 48 | built_void_type() 49 | ) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /rust/type/guid.rs: -------------------------------------------------------------------------------- 1 | use crate::r#type::Type; 2 | use rand::distributions::{Distribution, Standard}; 3 | use rand::Rng; 4 | use std::fmt::{Debug, Display, Formatter}; 5 | use std::str::FromStr; 6 | use uuid::{uuid, Uuid}; 7 | 8 | pub const NAMESPACE_TYPEBIN: Uuid = uuid!("01929b90-72e6-73e6-9da1-2b6462e407a6"); 9 | 10 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Ord, PartialOrd)] 11 | pub struct TypeGUID { 12 | guid: Uuid, 13 | } 14 | 15 | impl FromStr for TypeGUID { 16 | type Err = uuid::Error; 17 | 18 | fn from_str(s: &str) -> Result { 19 | Uuid::parse_str(s).map(Into::into) 20 | } 21 | } 22 | 23 | impl From for TypeGUID { 24 | fn from(value: Type) -> Self { 25 | Self::from(&value) 26 | } 27 | } 28 | 29 | impl From<&Type> for TypeGUID { 30 | fn from(value: &Type) -> Self { 31 | Self { 32 | guid: Uuid::new_v5(&NAMESPACE_TYPEBIN, &value.to_bytes()), 33 | } 34 | } 35 | } 36 | 37 | impl From for TypeGUID { 38 | fn from(value: Uuid) -> Self { 39 | Self { guid: value } 40 | } 41 | } 42 | 43 | impl Display for TypeGUID { 44 | fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { 45 | Display::fmt(&self.guid, f) 46 | } 47 | } 48 | 49 | impl Distribution for Standard { 50 | fn sample(&self, rng: &mut R) -> TypeGUID { 51 | let rand_ty: Type = rng.gen(); 52 | TypeGUID::from(rand_ty) 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /rust/type/modifier.rs: -------------------------------------------------------------------------------- 1 | use bon::Builder; 2 | 3 | use crate::fb_type as fb; 4 | use flatbuffers::{FlatBufferBuilder, UnionWIPOffset, WIPOffset}; 5 | 6 | #[derive(Clone, Debug, PartialEq, Hash, Eq)] 7 | pub struct DescriptorModifierClass { 8 | pub description: String, 9 | } 10 | 11 | impl DescriptorModifierClass { 12 | pub fn new(description: String) -> Self { 13 | Self { description } 14 | } 15 | } 16 | 17 | impl DescriptorModifierClass { 18 | fn create<'a>( 19 | &self, 20 | builder: &mut FlatBufferBuilder<'a>, 21 | ) -> WIPOffset> { 22 | let description = builder.create_string(&self.description); 23 | fb::DescriptorModifierClass::create( 24 | builder, 25 | &fb::DescriptorModifierClassArgs { 26 | description: Some(description), 27 | }, 28 | ) 29 | } 30 | } 31 | 32 | #[derive(Clone, Debug, PartialEq, Hash, Eq)] 33 | pub struct MetadataModifierClass { 34 | pub key: String, 35 | pub value: T, 36 | } 37 | 38 | impl MetadataModifierClass { 39 | pub fn new(key: String, value: T) -> Self { 40 | Self { key, value } 41 | } 42 | } 43 | 44 | impl> MetadataModifierClass { 45 | fn create<'a>( 46 | &self, 47 | builder: &mut FlatBufferBuilder<'a>, 48 | ) -> WIPOffset> { 49 | let key = builder.create_string(&self.key); 50 | let value = builder.create_vector(self.value.as_ref()); 51 | fb::MetadataModifierClass::create( 52 | builder, 53 | &fb::MetadataModifierClassArgs { 54 | key: Some(key), 55 | value: Some(value), 56 | }, 57 | ) 58 | } 59 | } 60 | 61 | #[derive(Clone, Debug, PartialEq, Hash, Eq)] 62 | pub enum TypeModifierClass { 63 | Constant, 64 | Volatile, 65 | Descriptor(DescriptorModifierClass), 66 | StringMetadata(MetadataModifierClass), 67 | RawMetadata(MetadataModifierClass>), 68 | } 69 | 70 | impl TypeModifierClass { 71 | pub fn ty(&self) -> fb::TypeModifierClass { 72 | match self { 73 | TypeModifierClass::Constant => fb::TypeModifierClass::ConstantModifierClass, 74 | TypeModifierClass::Volatile => fb::TypeModifierClass::VolatileModifierClass, 75 | TypeModifierClass::Descriptor(_) => fb::TypeModifierClass::DescriptorModifierClass, 76 | TypeModifierClass::StringMetadata(_) | TypeModifierClass::RawMetadata(_) => { 77 | fb::TypeModifierClass::MetadataModifierClass 78 | } 79 | } 80 | } 81 | 82 | fn create_constant<'a>( 83 | builder: &mut FlatBufferBuilder<'a>, 84 | ) -> WIPOffset> { 85 | fb::ConstantModifierClass::create(builder, &fb::ConstantModifierClassArgs {}) 86 | } 87 | 88 | fn create_volatile<'a>( 89 | builder: &mut FlatBufferBuilder<'a>, 90 | ) -> WIPOffset> { 91 | fb::VolatileModifierClass::create(builder, &fb::VolatileModifierClassArgs {}) 92 | } 93 | 94 | fn create(&self, builder: &mut FlatBufferBuilder) -> WIPOffset { 95 | match self { 96 | TypeModifierClass::Constant => Self::create_constant(builder).as_union_value(), 97 | TypeModifierClass::Volatile => Self::create_volatile(builder).as_union_value(), 98 | TypeModifierClass::Descriptor(class) => class.create(builder).as_union_value(), 99 | TypeModifierClass::StringMetadata(class) => class.create(builder).as_union_value(), 100 | TypeModifierClass::RawMetadata(class) => class.create(builder).as_union_value(), 101 | } 102 | } 103 | } 104 | 105 | #[derive(Clone, Debug, PartialEq, Eq, Hash, Builder)] 106 | pub struct TypeModifier { 107 | pub class: TypeModifierClass, 108 | } 109 | 110 | impl TypeModifier { 111 | pub fn new(class: TypeModifierClass) -> Self { 112 | Self { class } 113 | } 114 | 115 | pub fn create<'a>( 116 | &self, 117 | builder: &mut FlatBufferBuilder<'a>, 118 | ) -> WIPOffset> { 119 | let class_type = self.class.ty(); 120 | let class = self.class.create(builder); 121 | fb::TypeModifier::create( 122 | builder, 123 | &fb::TypeModifierArgs { 124 | class_type, 125 | class: Some(class), 126 | }, 127 | ) 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /signature.fbs: -------------------------------------------------------------------------------- 1 | include "type.fbs"; 2 | include "symbol.fbs"; 3 | 4 | namespace SigBin; 5 | 6 | file_identifier "SBIN"; 7 | file_extension "sbin"; 8 | 9 | table BasicBlock { 10 | guid:string (required); 11 | // TODO: successors:[string]; 12 | // TODO: predecessors:[string]; 13 | } 14 | 15 | table FunctionConstraint { 16 | guid:string; 17 | // In cases where a function guid was not able to be generated, we can match on symbol. 18 | symbol:SymbolBin.Symbol; 19 | // The byte offset from the start of the constrained function. 20 | // A negative number would indicate that the constraint occurs before the start of the function. 21 | offset:long; 22 | } 23 | 24 | table FunctionConstraints { 25 | // Adjacent functions. 26 | adjacent:[FunctionConstraint]; 27 | // Call sites within the function. 28 | call_sites:[FunctionConstraint]; 29 | // Callers to the function. 30 | caller_sites:[FunctionConstraint]; 31 | } 32 | 33 | table Function { 34 | // TODO: Add architecture, this is required to support multi-arch binaries... 35 | guid:string (required); 36 | symbol:SymbolBin.Symbol; 37 | type:TypeBin.Type; 38 | constraints:FunctionConstraints; 39 | } 40 | 41 | table Data { 42 | functions:[Function]; 43 | types:[TypeBin.ComputedType]; 44 | } 45 | 46 | root_type Data; -------------------------------------------------------------------------------- /sigview/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "sigview" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | warp = { path = "../" } 8 | log = "0.4" 9 | env_logger = "0.11.5" 10 | eframe = "0.29.1" 11 | egui_extras = "0.29.1" 12 | rfd = "0.15.0" 13 | egui_graphs = "0.22.0" 14 | egui_virtual_list = "0.5.0" 15 | petgraph = "0.6.5" -------------------------------------------------------------------------------- /sigview/src/graph.rs: -------------------------------------------------------------------------------- 1 | use eframe::egui; 2 | use eframe::egui::Ui; 3 | use egui_graphs::{Graph, GraphView, SettingsInteraction, SettingsNavigation, SettingsStyle}; 4 | use petgraph::prelude::StableGraph; 5 | use warp::signature::function::{Function, FunctionGUID}; 6 | 7 | #[derive(Debug, Clone, Hash, Eq, PartialEq)] 8 | pub struct FunctionNode { 9 | pub name: String, 10 | pub guid: FunctionGUID, 11 | } 12 | 13 | impl From for FunctionNode { 14 | fn from(value: Function) -> Self { 15 | Self::from(&value) 16 | } 17 | } 18 | 19 | impl From<&Function> for FunctionNode { 20 | fn from(value: &Function) -> Self { 21 | Self { 22 | name: value.symbol.name.to_owned(), 23 | guid: value.guid, 24 | } 25 | } 26 | } 27 | 28 | #[derive(Debug, Clone)] 29 | pub struct FunctionGraph { 30 | graph: Graph, 31 | } 32 | 33 | impl FunctionGraph { 34 | pub fn from_function(func: &Function) -> Self { 35 | let mut graph = StableGraph::new(); 36 | let func_node = FunctionNode::from(func); 37 | let func_node_idx = graph.add_node(func_node); 38 | 39 | for caller_func in &func.constraints.call_sites { 40 | let name = caller_func 41 | .symbol 42 | .as_ref() 43 | .map(|sym| sym.name.to_owned()) 44 | .unwrap_or_default(); 45 | if let Some(guid) = caller_func.guid { 46 | let caller_func_node = FunctionNode { name, guid }; 47 | let caller_func_node_idx = graph.add_node(caller_func_node); 48 | graph.add_edge(caller_func_node_idx, func_node_idx, ()); 49 | } 50 | } 51 | 52 | FunctionGraph { 53 | graph: Graph::from(&graph), 54 | } 55 | } 56 | 57 | pub fn add(&mut self, ui: &mut Ui) { 58 | let interaction_settings = &SettingsInteraction::new(); 59 | let style_settings = &SettingsStyle::new().with_labels_always(true); 60 | let nav_settings = &SettingsNavigation::new() 61 | .with_fit_to_screen_enabled(false) 62 | .with_zoom_and_pan_enabled(true); 63 | ui.add( 64 | &mut GraphView::new(&mut self.graph) 65 | .with_styles(style_settings) 66 | .with_interactions(interaction_settings) 67 | .with_navigations(nav_settings), 68 | ); 69 | } 70 | 71 | pub fn add_viewport(&mut self, ctx: &egui::Context) -> bool { 72 | let mut requested_close = false; 73 | ctx.show_viewport_immediate( 74 | egui::ViewportId::from_hash_of("function_graph_viewport"), 75 | egui::ViewportBuilder::default() 76 | .with_title("Function Graph") 77 | .with_inner_size([400.0, 400.0]), 78 | |ctx, class| { 79 | assert!( 80 | class == egui::ViewportClass::Immediate, 81 | "This egui backend doesn't support multiple viewports" 82 | ); 83 | 84 | egui::CentralPanel::default().show(ctx, |ui| { 85 | self.add(ui); 86 | }); 87 | 88 | if ctx.input(|i| i.viewport().close_requested()) { 89 | // Tell parent viewport that we should not show next frame: 90 | requested_close = true; 91 | } 92 | }, 93 | ); 94 | requested_close 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /symbol.fbs: -------------------------------------------------------------------------------- 1 | namespace SymbolBin; 2 | 3 | table FunctionSymbolClass {} 4 | 5 | table DataSymbolClass {} 6 | 7 | union SymbolClass { 8 | FunctionSymbolClass, 9 | DataSymbolClass 10 | } 11 | 12 | enum SymbolModifiers : ubyte (bit_flags) { 13 | // Function is an import, or otherwise external to the analysis. 14 | External = 0, 15 | // Function is exported 16 | // TODO: This naming is unfortunate. If something is referenced externally 17 | Exported 18 | } 19 | 20 | table Symbol { 21 | // TODO: We should be able to store metadata on this... 22 | // TODO: Metadata could include raw names and long names. 23 | name:string; 24 | modifiers:SymbolModifiers; 25 | class:SymbolClass (required); 26 | } --------------------------------------------------------------------------------