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

Reading messages dynamically without capnpc generation #543

Open
anlumo opened this issue Jan 29, 2025 · 3 comments
Open

Reading messages dynamically without capnpc generation #543

anlumo opened this issue Jan 29, 2025 · 3 comments

Comments

@anlumo
Copy link

anlumo commented Jan 29, 2025

I'm trying to read Cap'n Proto messages where the schema is only known at runtime. capnproto-c++ does support runtime schema loading, but capnproto-rust does not.

The examples always start with a type from capnpc-generated code and then downcast to dynamic_value, dynamic_struct, etc., but there is no way to get there from a capnp::message::Reader.

Same goes for creating messages based on dynamic_value etc..

It would be great to have this feature added.

@dwrensha
Copy link
Member

No, capnproto-rust currently does not support that. The dynamic reflection API requires any schemas that are used to be known at compile time.

If you are willing to use C++, capnproto-c++ does support runtime schema loading: https://github.com/capnproto/capnproto/blob/v2/c%2B%2B/src/capnp/schema-loader.h

@anlumo
Copy link
Author

anlumo commented Jan 30, 2025

Unfortunately, using C++ is not an option (I have to support wasm, where mixing Rust and C++ is hard to impossible). Is there any chance that this will be added?

@anlumo anlumo changed the title Reading messages without capnpc generation? Reading messages dynamically without capnpc generation Jan 30, 2025
@anlumo
Copy link
Author

anlumo commented Jan 30, 2025

I've updated the ticket to represent a feature request rather than a question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants