[Rust] Dynamic protobuf support#465
Conversation
9bca843 to
10528f1
Compare
10528f1 to
df42e1f
Compare
8889215 to
5f9e3ae
Compare
| /// [`crate::dynamic::DynamicRecord`]. Wire-identical to | ||
| /// [`compiled_proto`](Self::compiled_proto); see the [`dynamic`](crate::dynamic) | ||
| /// module for the full pattern. | ||
| pub fn dynamic_proto(mut self, descriptor: prost_types::DescriptorProto) -> Self { |
There was a problem hiding this comment.
This now has the same signature as compiled_proto and collapses into the same (RecordType::Proto, Some(*desc)) build arm, the DynamicProto variant currently differs only in its Debug label, and message_descriptor()/new_record() work on compiled_proto streams too since they only check for a descriptor. So the second method adds a name but no distinct behavior.
I think we should look into dynamic_proto accepting the resolved descriptor instead:
pub fn dynamic_proto(mut self, descriptor: dynamic::MessageDescriptor) -> SelfThe caller resolves once up front via dynamic::message_descriptor(&proto)? (or we add a descriptor_from_uc_columns to resolved-descriptor path), and the builder pulls the raw DescriptorProto back out for the CreateStream payload with MessageDescriptor::descriptor_proto().encode_to_vec(), wire-identical to today. This makes the method genuinely different from compiled_proto, fails fast on a bad descriptor at build() instead of at the first new_record(), and lets us drop the lazy OnceLock<MessageDescriptor> on ZerobusStream (the descriptor is now supplied, not lazily rebuilt).
There was a problem hiding this comment.
Makes sense. Switched to MessageDescriptor.
b91a009 to
d0f6aa6
Compare
382d382 to
ea6703f
Compare
ea6703f to
d973c74
Compare
What changes are proposed in this pull request?
Closes #372
Adds a native dynamic-protobuf path for ingesting records whose schema is known only at runtime, with no compiled prost::Message type.
New public API in the dynamic module:
StreamBuilder::dynamic_proto(descriptor)- select the format from a runtime DescriptorProto.ZerobusStream::message_descriptor()/new_record()- resolve the schema (cached) and start a record.dynamic::DynamicRecord- build records field-by-field with a validating, chainable.set(field, value)?.dynamic::message_descriptor()standalone resolver, theIntoDynamicValueconversion trait, and re-exports ofprost_reflect::{DynamicMessage, MessageDescriptor, Value}.Follow-ups:
How is this tested?
Manually tested with custom Rust client