pub trait ReflectMessage {
// Required method
fn descriptor(&self) -> MessageDescriptor;
// Provided method
fn transcode_to_dynamic(&self) -> DynamicMessage
where Self: Message + Sized { ... }
}Expand description
Implemented by every type that has a descriptor in some
crate::DescriptorPool — generated typed messages via
#[derive(ReflectMessage)] and runtime-typed
crate::DynamicMessage.
Note: this trait deliberately does not require
buffa::Message as a super-trait so that
crate::DynamicMessage (which has no static
DefaultInstance) can implement it. Where wire-encoding via
Self::encode_to_vec is needed, individual methods name
Self: ::buffa::Message as a where-clause.
Required Methods§
Sourcefn descriptor(&self) -> MessageDescriptor
fn descriptor(&self) -> MessageDescriptor
Resolve the MessageDescriptor for Self.
The pool the descriptor lives in is set up by the
#[derive(ReflectMessage)] macro, either:
- the user-supplied
descriptor_poolexpression, or - a lazily-decoded pool keyed off the embedded
file_descriptor_set_bytes.
Provided Methods§
Sourcefn transcode_to_dynamic(&self) -> DynamicMessage
Available on crate feature dynamic only.
fn transcode_to_dynamic(&self) -> DynamicMessage
dynamic only.Round-trip self through wire bytes into a crate::DynamicMessage.
The default implementation pays one wire round-trip; the impl
for crate::DynamicMessage short-circuits to self.clone().
§Panics
Panics if self.encode_to_vec() produces bytes that fail to
decode against self.descriptor() — this would indicate a bug
in the generated descriptor() wiring or in
self’s Message impl.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl ReflectMessage for DynamicMessage
dynamic only.