Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support nested flatbuffers #127

Open
TheButlah opened this issue Aug 4, 2022 · 2 comments
Open

Support nested flatbuffers #127

TheButlah opened this issue Aug 4, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@TheButlah
Copy link

Flatbuffers could be serialized into byte slices of a table, thereby nesting the flatbuffer. In the main rust flatbuffer implementation, this is not supported without having to copy a finished flatbuffer in, but in C++ it is.

It would be cool to support this.

@TethysSvensson
Copy link
Collaborator

This is in principle not hard to support, but in practice it requires a bit of thought.

For instance, do we want to prevent the foot-gun of mixing in stuff not meant to go into the nested table? I think allowing that is too large a footgun for me to be comfortable with it (both in terms of performance and in terms of leaking unintended data).

I am thinking that maybe we can do something like this?

struct NestedBuilder<'a> { builder: &'a mut Builder }

impl Builder {
    fn nested_builder<'a>(&'a mut self) -> NestedBuilder<'a> { ... }
}

impl<'a> NestedBuilder<'a> {
    fn nested_builder<'b>(&'a mut self) -> NestedBuilder<'b> { ... }
    fn finish<T>(self, root: Offset<T>) -> Offset<NestedBuffer<T>> { ... }
}

And then re-structuring the builder trait so what they work with either a Builder or a NestedBuilder.

@TheButlah Do you think that API would work for your use-case?

@TheButlah
Copy link
Author

That would probably work, although I should not be relied on as a person to give opinions on y'alls apis.

@TethysSvensson TethysSvensson added enhancement New feature or request rust-backend and removed rust-backend labels Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants