Commit Graph

73 Commits

Author SHA1 Message Date
Derek Bailey af9ceabeef
FlatBuffers Version 23.1.4 (#7758) 2023-01-04 15:22:46 -08:00
Max Burke 3be296ec8a
[Rust] Restore public visibility of previously-public fields (#7700)
* Restore public visibility of previously-public fields

* code review feedback
2022-12-08 18:20:14 -05:00
Derek Bailey acf39ff056
FlatBuffers Version 22.12.06 (#7702) 2022-12-06 22:54:49 -08:00
Casper 7b6c9f4a3c
Rurel (#7663)
* Update release script to update Rust version (it still needs to be published after)

* Also update rust while I'm at it

Co-authored-by: Casper Neo <cneo@google.com>
2022-11-23 12:03:54 -08:00
Casper 214cc94681
Bump Rust version to 22.10.26 before publication (#7622) 2022-11-03 16:24:00 +00:00
Dan Lapid 5792623df4
Rust fix compilation for no_std targets #2 (#7553)
* Fix nightly no_std

* Fix nightly no_std
2022-10-19 09:14:41 -04:00
Casper 0edb275285
Update Rust version (#7574)
Co-authored-by: Casper Neo <cneo@google.com>
2022-10-18 20:37:12 +00:00
Casper e1c5db988a
Turn on clippy for Rust and fix lints for non-generated code (#7575)
Co-authored-by: Casper Neo <cneo@google.com>
2022-10-10 21:26:35 -04:00
Raphael Taylor-Davies 374f8fb5fb
Rust soundness fixes (#7518)
* Rust soundness fixes

* Second pass

* Make init_from_table unsafe

* Remove SafeSliceAccess

* Clippy

* Remove create_vector_of_strings

* More clippy

* Remove deprecated root type accessors

* More soundness fixes

* Fix EndianScalar for bool

* Add TriviallyTransmutable

* Add debug assertions

* Review comments

* Review feedback
2022-09-29 09:58:49 -04:00
Bogdan Opanchuk 76d3cca19c
Rust: fix a name conflict when building with "no_std" feature (#7268)
* Fix a name conflict when building with "no_std" feature

* Bump patch version
2022-04-25 13:09:41 -04:00
Casper 3d903302c3
[Rust] Add length checks to arrays and vectors. (#7130)
* [Rust] Add length checks to arrays and vectors.

The previous behavior allowed for out of bounds access in
the public API (#7011).

* bump semver and test warning

Co-authored-by: Casper Neo <cneo@google.com>
2022-02-24 13:49:59 -05:00
Marcin Witkowski c1daa6ba0c
rust: Bump thiserror version and remove git dependency (#7080) 2022-02-04 16:02:02 -05:00
Max Burke 1d294a31b8
Implement Serialize on generated rust types (#7022)
* fix for rust build

* Rust: Implement Serialize on generated types

For debugging convenience it is really handy to be able to dump out
types as another format (ie: json). For example, if we are logging a
type to a structured logging system, or even printing it out in a
structured way to the console.

Right now we handle this by shelling out to `flatc` which is not ideal;
by implementing Serialize on the generated types we can use any of the
Serializer-implementing packages for our structured debug output.

* clang-format

* Make the flatbuffers Rust crate only have an optional dependency on the `serde` packages.

* fix warning

* fix rust test build

* Oh yeah this needs to be initialized

* fix toml syntax

* code review feedback

* rebuild test data
2022-01-30 19:29:18 -05:00
Marcin Witkowski aff818cebf
rust: Allow for usage in no_std environment (#6989) 2022-01-20 11:49:02 -05:00
Élie ROUDNINSKI a14f4052cf
rust: remove needless borrow (#6922)
This was discovered by running clippy.
2021-11-23 10:46:56 -06:00
Casper 35e2cac6eb
Store vtables sorted in Rust builder (#6765)
* benchmark many vtables

* Rust: Store written_table rev-positions sorted.

The previous implementation was slow if there were too many tables.

Asymototically when inserting the n^th vtable: The old implementation
took O(n) lookup steps and O(1) insertion. The new implementation is
O(log n) lookup and O(n) insertion. This might be improved further by
using a balanced btree.

Benchmarking, create_many_tables is 7.5x faster (on my laptop):

// Simple vector cache
test create_many_tables ... bench: 728,875 ns/iter (+/- 12,279) = 44 MB/s

// Sorted vector cache
test create_many_tables ... bench: 97,843 ns/iter (+/- 4,430) = 334 MB/s

* Fix lints

Co-authored-by: Casper Neo <cneo@google.com>
2021-08-03 12:31:45 -07:00
Casper fe2bc2b0a7
Added README for Rust Flatbuffers (before publishing v=2.0) (#6652)
Co-authored-by: Casper Neo <cneo@google.com>
2021-05-16 10:37:16 -04:00
Casper 8fd10606c1
Implement Serialize for flexbuffer::Reader (#6635)
* Implement Serialize for flexbuffer::Reader

* bump version

* Remove use of experimantal or-patterns

* Remove more use of experimantal or-patterns

Co-authored-by: Casper Neo <cneo@google.com>
2021-05-10 23:15:46 -04:00
Wouter van Oortmerssen a9a295fecf More missing version changes 2021-05-10 11:45:16 -07:00
Wouter van Oortmerssen 6ed780dbd5 C++/Rust version changes 2021-05-10 11:29:32 -07:00
Casper 6b44c605b8
Bump Rust to 0.9.0 (#6610)
Co-authored-by: Casper Neo <cneo@google.com>
2021-05-02 12:28:17 -04:00
Casper 8fa3dfdb5d
Introduce new_from_vec in Rust (also fix formatting) (#6599)
* Introduce new_from_vec in Rust (also fix formatting)

Also, rename `new_with_capacity` to `with_capacity` to match
how `Vec` does it.

* bump rust version

* mut_finished_buffer

Co-authored-by: Casper Neo <cneo@google.com>
2021-04-29 18:23:22 -04:00
Casper c87179e73e
Rust Remove SafeSliceAccess for Arrays, and fix miri. (#6592)
* Fix Miri flag passing and bump Rust version.

* Fix Miri problems from Arrays PR.

SafeSliceAccess was removed for Arrays. It's kind of unsound.
It has two properties:
1. EndianSafe
2. Alignment 1

We only need 1. in create_vector_direct to memcpy data.
We both 1. and 2. for accessing things with slices as buffers are built on &[u8]
which is unaligned. Conditional compilation implements
SafeSliceAccess for >1byte scalars (like f32) on LittleEndian machines
which is wrong since they don't satisfy 2.

This UB is still accessible for Vectors (though not exercised our
tests) as it implements SafeSliceAccess. I'll fix this later by
splitting SafeSliceAccess into its 2 properties.

Co-authored-by: Casper Neo <cneo@google.com>
2021-04-26 19:28:25 -04:00
Casper c24031c36b
Mark endian_scalar as unsafe. (#6588)
* Mark endian_scalar as unsafe.

Also
- removed the deprecated flexbuffer slice from example
- fixed some cargo warnings

* Assertions and read_scalar made unsafe

* Clippy lints

* Add to Safety

Co-authored-by: Casper Neo <cneo@google.com>
2021-04-26 09:18:58 -04:00
Ádám Lippai c43ba17520
[Rust] Specify Minimum Supported Rust Version (#6573)
Related to #6572
2021-04-19 16:43:11 -04:00
Eddie Linder da3bb64ef6
[Rust] Add support for fixed size arrays (#6548)
* Add support for fixed size arrays

* clang-format

* Update rust image to 1.51 to support const generics

* Handle correctly big endian

* Add fuzz tests and clean code

* Add struct fuzz test and optimize struct arrays for api

* Bump flatbuffers crate version
2021-04-16 11:15:59 -04:00
Colin c0be1cb7a5
[rust] Remove debug code (#6475)
* Remove debug code

This was added for testing in the recent genericize PR for flexbuffer Reader.

* Added alloc tests -> MapReader::{is_empty, index_key, len}

* Added , accessible through Deref to deprecation warning
2021-02-24 13:00:18 -05:00
Colin 4174c10e7a
[rust] Genericize flexbuffer reader (#6450)
* feature/rust-tokio-bytes added feature name for tokio-bytes

* Added flexbuffer implementation, TODO: typecast to avoid recurse

* Converted codebase to utilize FlexBuffer implementation, need to resolve deserialization issues

* Added todo for lifetime issue, may use &'de [u8] for deserializer instead of current method

* Added proper &[u8] implementation

* Removed unused struct

* Added experimental fix to get_slice

* Added experimental fix to get_slice

* Avoided lifetime issues via ref structs, need to check if this hurts peformance

* Updated deserializer implementation to allow for borrowed data from Reader struct

* Fixed bug with str

* Removed unnecessary generic parameter

* Added unsafe to avoid lifetime complaints, current tests pass, need to review alternatives to unsafe

* Opinionated: Removed bytes crate as this implementation could be done in a separate crate

* Cleaned up flatbuffer

* Fixed sample / example

* Resolved PR feedback, need to resolve issues with tests

* Cleaned up FlexBuffer trait to be an auto impl

* Removed TODO

* Reverted Deserializer to only support &'de [u8]

* Cleaned up / renamed function for clarification

* Renamed FlexBuffer -> InternalBuffer for clarification on it's purpose

* Fixed issue with key bytes

* resolved issues with broken tests, confirming this is a breaking change

* Removed FIXME that's solved by splitting String and Key variants

* Implemented associated types approach

* Fixed backward slice logic

* Fixed MapReader compile error

* Added from_buffer for deserialization, removed  function since it's only needed for deserialization

* Removed dead code

* Cleaned up buffer, removed AsRef in favor of Deref

* Renamed Buffer::as_str -> Buffer::buffer_str

* Minor cleanup

* Updated documentation, need to fix tests

* Removed unnecessary &

* Removed unused lifetime

* removed unnecessary as_ref

* Minor optimization wrap-up

* resolved issue with Clone

* Added test to verify no deep-copy

* Added  for optimization

* Updated to use empty fn instead of default

* Updated comments / test name - plus the 0.3.0 version bump

* comment
2021-02-16 08:04:48 -05:00
Casper 86401e078d
Default strings and vectors: Parser + Rust support (#6421)
* Fix tests.cpp

* Parser support for vector/string defaults

* tests and default empty vectors

* addressed comments

* Default strings and vectors for Rust

* Tested Rust more_defaults

* git-clang-format

* add more_defaults_test

* fixed vector default

* removed commented out code

* more unreachable

Co-authored-by: Casper Neo <cneo@google.com>
2021-02-12 09:41:10 -05:00
Casper 1da0a2dfac
Rust Object API (#6070)
* inital commit of rust object api

* Required fields support.

* clang fallthrough

* Fix unused variables

* just don't fall through

* remove comment

* s/panic/unreachable

* Tests for object API

* Added defaults

* deleted unintentionally added files and updated .bat file

* fix bat file

* clang format

* Cargo clippy checks

* remove commented out code

* clippy allows

* Remove matches! macro since we're not yet at Rust v1.42

* install clippy in RustTest.sh

* move line

Co-authored-by: Casper Neo <cneo@google.com>
2021-01-22 13:07:32 -05:00
Casper 8008dde117
Upgrade Rust dependencies (#6406)
Co-authored-by: Casper Neo <cneo@google.com>
2021-01-19 13:39:29 -05:00
Casper 408cf58024
Fix Rust UB problems (#6393)
* Fix miri problems by assuming alignment is 1 in rust

* Removed is_aligned fn from rust verifier.

* Add back is_aligned, but make it w.r.t. buffer[0]

* touch unused variable

* touch unused variable

* +nightly

* Move Rust miri testing into its own docker

* fix bash

* missing one endian conversion

* fix endianness2

* format stuff

Co-authored-by: Casper Neo <cneo@google.com>
2021-01-11 15:24:52 -05:00
mustiikhalil 57f68e2896
[Rust] Shared String (#6367)
* Adds shared strings and tests for shared strings

* Adds resets on string_map

* Moved shared strings to use vector instead of hashmap

* Addresses all the issues

* Resolves some comments
2021-01-04 06:18:35 -08:00
Casper 9c9baf6d58
bumprust (#6322)
Co-authored-by: Casper Neo <cneo@google.com>
2020-12-09 11:34:19 -08:00
Casper 442949bc11
Rust Flatbuffers Verifier (#6269)
* Updated comments and fixed a fundemental type error.

* bump rust flatbuffers semver

* Initial commit with verifier, need to clean up

* Verifier tested. Needs clean up and refactoring.

* Display for InvalidFlatbuffer and better errors for strings

* SimpleToVerify, some refactoring

* Combined VerifierType TableAccessorFuncBody into FollowType

* scrub todos

* Update Rust get_root functions.

There are 6 variants, with verifier options, default verifier options
and no verification "fast".

* Rename root fns

* inline

* Update to use thiserror

* fix for bad compiler

* improve error formatting

* Replace multiply with saturating_multiply

* saturating adds too

* Add docs disclaiming experimental verification system

Co-authored-by: Casper Neo <cneo@google.com>
2020-12-07 18:37:51 -05:00
Casper ed391e1777
BREAKING: Rust flexbuffers serde human readable set to false (#6257)
Co-authored-by: Casper Neo <cneo@google.com>
2020-11-13 07:53:01 -08:00
Casper b08b0a4402
Implement `Debug` trait for Rust flatbuffers. (#6207)
* Refactor idl_gen_rust to a ForAllX continuation pattern.

* Removed unneeded SetValue and updated sample rust gencode

* Make Rust flatbuffers print right

* Generated code and removed unnecessary trait constraint

* bumped rust version. Release required

* removed an unwrap in Rust Debug-print unions

* Tested formatting flatbuffers in rust.

* Set float precision in flaky debug-print test

* impl Debug for structs too

Co-authored-by: Casper Neo <cneo@google.com>
2020-10-29 12:57:29 -07:00
Casper 14ecfe4236
Updated comments and fixed a fundamental type error. (#6214)
* Updated comments and fixed a fundemental type error.

* bump rust flatbuffers semver

Co-authored-by: Casper Neo <cneo@google.com>
2020-10-28 19:23:22 -07:00
Casper 9fa1d27059
Rework enums in rust. (#6098)
* Rework enums in rust.

They're now a unit struct, rather than an enum. This is a
backwards incompatible change but the previous version had UB
and was also backwards incompatible so...

* Update and test sample rust flatbuffers

* Use bitflags crate to properly support rust enums.

Previously, the bitflags attribute was just ignored. This is a breaking change
as the bitflgs API is not like a normal rust enum (duh).

* variant_name() -> Option<_>

* repr transparent

* Reexport bitflags from flatbuffers

* Make bitflags constants CamelCase, matching normal enums

* Deprecate c-style associated enum constants

Co-authored-by: Casper Neo <cneo@google.com>
2020-10-19 11:40:03 -07:00
ImmConCon 187a4787f9
[Rust] Upgrade flatbuffers library to 2018 edition (#6159)
* [Rust] Upgrade flatbuffers lib to 2018 edition

* Pushed version
2020-10-06 15:55:22 -07:00
Kamil Rojewski 2eedc769d5
possibility to create a vector from an iterator (#6135) 2020-09-28 09:45:48 -07:00
Casper 18b015d25a
Rust codegen improvements and lint fixes (#6046)
* Improve rust codegen

* one more unneeded lifetime

* Added a derive default

Co-authored-by: Casper Neo <cneo@google.com>
2020-07-25 13:46:20 -07:00
Casper 043b52bd4a
Optional Scalars support for Rust (#6034)
* First draft of rust optionals

* Code cleanup around ftBool and ftVectorOfBool

* Tests for Rust optional scalars

* test bools too

Co-authored-by: Casper Neo <cneo@google.com>
2020-07-23 16:30:27 -07:00
Casper 8a721f69a1
Serde with bytes maps to Blob (#6009)
* Serde with_bytes maps to Blob

* Bump rust flexbuffers minor version number

Co-authored-by: Casper Neo <cneo@google.com>
2020-06-28 19:58:08 -07:00
Johan Andersson 35d45cac7a
[Rust] Flexbuffers dependency cleanup and fixes (#5998)
* Fix doc comment warnings

Can't use doc comment "///" syntax on macros, that generates the following warning:

warning: unused doc comment
   --> src\flexbuffer_type.rs:236:5
    |
236 |     /// returns true if and only if the flexbuffer type is `VectorFloat4`.
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ rustdoc does not generate documentation for macros
    |
    = help: to document an item produced by a macro, the macro must produce the documentation as part of its expansion

So switched to just use ordinary "//" comments on these to be warning free

* Upgrade num_enum 0.4.1 -> 0.5.0

* Remove unused and non-working usage of test crates

* Remove usage of abandoned debug_stub_derive crate

Which brought in old pre-v1 syn and quote crates.

This replaces it with just manual Debug trait implementation instead for the 2 cases
2020-06-25 17:12:10 -07:00
Casper 12ddc8a920
Rust Flexbuffers Documentation update (#5979)
* Update samples and docs

* Fixed a line of documentation

Co-authored-by: Casper Neo <cneo@google.com>
2020-06-18 00:01:48 -07:00
Matt Brubeck 53fb453e04
[rust] Add FlatBufferBuilder::force_defaults API (#5946)
* [rust] Add force_defaults method FlatBufferBuilder

This works just like the same method already available in other
languages.

* Add binary format test for force_defaults
2020-06-08 09:47:36 -07:00
Casper c3faa83463
Fix Cargo.toml dependencies (#5911)
* Fix Cargo.toml dependencies

* less specific serde dependency

Co-authored-by: Casper Neo <cneo@google.com>
2020-05-13 11:24:32 -07:00
Casper 32782e4ad1
Update Rust Flexbuffers metadata before publishing (#5905)
Co-authored-by: Casper Neo <cneo@google.com>
2020-05-11 19:46:37 -07:00
Casper 8be05f6bd4
Rust Flexbuffers (#5669)
* Cargo clippy lints

* more lints

* more lints

* Restored a doc comment

* Comment on float eps-eq and adjusted casting

* Rust Flexbuffers

* more serde tests, removed some unsafe

* Redid serde to be map-like and Reader is Display

* Moved iter from Reader to VectorReader

* Serious quickcheck + bugs

* wvo api

* Made types smaller for a reasonable speedup

* redid reading in a way that's a bit faster.

Profiling shows the rust slowdown as building +10%, reading +20%

* src/bin are developer binaries in rust

* Root and Map width are not packed

* key null check is debug only + doc changes

* BuilderOptions

* Documentation

* Documentation

* Moved tests to rust_usage_test

* Moved rust flexbuffers samples to Flatbuffers/samples

* Fixed RustTest

* Fixed for Rust 1.37.0

* Upgraded to rust 1_40_0

* fixed a little-endian-only feature in a test

* 1.40.0

* fixed some benchmarks for bigendian

* Updated .bat file

* misspelling

* Gold Flexbuffer test.

* Serialize,Deserialize, std::error::Error for Errors.

* Undo rustfmt in integration_test.rs

* from_slice instead of from_vec

* Added comments to unsafe blocks

* expanded on comment

* bump

Co-authored-by: CasperN <cneo@google.com>
2020-05-07 14:11:26 -07:00