Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 Google Inc. All rights reserved. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | //! # FlatBuffers |
| 18 | //! |
| 19 | //! A library for memory-efficient serialization of data. |
| 20 | //! |
| 21 | //! This crate provides runtime support for the FlatBuffers format in the Rust programming language. |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 22 | //! To use this crate, first generate code with the `flatc` compiler, as described here: <https://google.github.io/flatbuffers/> |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 23 | //! Then, include that code into your project. |
| 24 | //! Finally, add this crate to your `Cargo.toml`. |
| 25 | //! |
| 26 | //! At this time, Rust support is experimental, and APIs may change between minor versions. |
| 27 | //! |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 28 | //! At this time, to generate Rust code, you will need the latest `master` version of `flatc`, available from here: <https://github.com/google/flatbuffers> |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 29 | //! (On OSX, you can install FlatBuffers from `HEAD` with the Homebrew package manager.) |
| 30 | |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 31 | #![cfg_attr(feature = "no_std", no_std)] |
| 32 | |
| 33 | #[cfg(feature = "no_std")] |
| 34 | extern crate alloc; |
| 35 | |
| 36 | mod array; |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 37 | mod builder; |
| 38 | mod endian_scalar; |
| 39 | mod follow; |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 40 | mod get_root; |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 41 | mod primitives; |
| 42 | mod push; |
| 43 | mod table; |
| 44 | mod vector; |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 45 | mod verifier; |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 46 | mod vtable; |
| 47 | mod vtable_writer; |
| 48 | |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 49 | pub use crate::array::{array_init, emplace_scalar_array, Array}; |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 50 | pub use crate::builder::FlatBufferBuilder; |
| 51 | pub use crate::endian_scalar::{ |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 52 | byte_swap_f32, byte_swap_f64, emplace_scalar, read_scalar, read_scalar_at, EndianScalar, |
| 53 | }; |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 54 | pub use crate::follow::{Follow, FollowStart}; |
| 55 | pub use crate::primitives::*; |
| 56 | pub use crate::push::Push; |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 57 | pub use crate::table::{buffer_has_identifier, Table}; |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 58 | pub use crate::vector::{follow_cast_ref, SafeSliceAccess, Vector, VectorIter}; |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 59 | pub use crate::verifier::{ |
| 60 | ErrorTraceDetail, InvalidFlatbuffer, SimpleToVerifyInSlice, Verifiable, Verifier, |
| 61 | VerifierOptions, |
| 62 | }; |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 63 | pub use crate::vtable::field_index_to_field_offset; |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 64 | pub use bitflags; |
| 65 | pub use get_root::*; |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 66 | |
| 67 | // TODO(rw): Unify `create_vector` and `create_vector_direct` by using |
| 68 | // `Into<Vector<...>>`. |
| 69 | // TODO(rw): Split fill ops in builder into fill_small, fill_big like in C++. |