mod wkt;
pub(crate) use wkt::WELL_KNOWN_TYPES_BYTES;
use prost::Message;
use crate::{DynamicMessage, MessageDescriptor};
pub trait ReflectMessage: Message {
fn descriptor(&self) -> MessageDescriptor;
fn transcode_to_dynamic(&self) -> DynamicMessage
where
Self: Sized,
{
let mut message = DynamicMessage::new(self.descriptor());
message
.transcode_from(self)
.expect("error converting to dynamic message");
message
}
}
impl<M> ReflectMessage for Box<M>
where
M: ReflectMessage,
{
fn descriptor(&self) -> MessageDescriptor {
(**self).descriptor()
}
}
#[test]
fn assert_object_safe() {
fn _foo(_: Box<dyn ReflectMessage>) {}
}