Skip to content

Can't use generated get_root_as_* in 0.8.0, but works in 0.7.0 [Rust, rustc 1.48.0, Win32, FlatBuffers 0.8.0] #6339

@Alfred-Mountfield

Description

@Alfred-Mountfield

Have been trying to use generated Rust Code to read from a Flatbuffer saved in a file.
When using flatbuffers 0.8.0 Rust complains with the following errors (does not with 0.7.0):

error[E0423]: expected function, found module `flatbuffers::get_root`
   --> src\.\generated\model_generated.rs:522:3
    |
522 |   flatbuffers::get_root::<Model<'a>>(buf)
    |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a function

error[E0425]: cannot find function `get_size_prefixed_root` in crate `flatbuffers`
   --> src\.\generated\model_generated.rs:527:16
    |
527 |     flatbuffers::get_size_prefixed_root::<Model<'a>>(buf)
    |                  ^^^^^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `size_prefixed_root`
    | 
   ::: C:\Users\Alfred\.cargo\registry\src\github.com-1ecc6299db9ec823\flatbuffers-0.8.0\src\get_root.rs:56:1
    |
56  | / pub fn size_prefixed_root<'buf, T>(data: &'buf [u8]) -> Result<T::Inner, InvalidFlatbuffer>
57  | | where
58  | |     T: 'buf + Follow<'buf> + Verifiable,
    | |________________________________________- similarly named function `size_prefixed_root` defined here

error[E0603]: module `get_root` is private
   --> src\.\generated\model_generated.rs:522:16
    |
522 |   flatbuffers::get_root::<Model<'a>>(buf)
    |                ^^^^^^^^ private module
    |
note: the module `get_root` is defined here
   --> C:\Users\Alfred\.cargo\registry\src\github.com-1ecc6299db9ec823\flatbuffers-0.8.0\src\lib.rs:34:1
    |
34  | mod get_root;
    | ^^^^^^^^^^^^^

Some extra info that might help:

The command I'm using to call it is:
get_root_as_model(&*bytes)

The schema is defined with a root_type called Model:

table Model {
  ...
}

root_type Model;

and I generate Rust code with:
flatc --rust -o src/generated schema/model.fbs

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions