protobuf/reflect/
type_dynamic.rs
1use std::marker;
4
5use crate::reflect::runtime_types::RuntimeTypeTrait;
6use crate::reflect::types::ProtobufTypeTrait;
7use crate::reflect::ProtobufValue;
8use crate::reflect::RuntimeType;
9use crate::wire_format::WireType;
10
11pub(crate) trait _ProtobufTypeDynamic: Send + Sync + 'static {
15 fn wire_type(&self) -> WireType;
17
18 fn runtime_type(&self) -> RuntimeType;
20}
21
22pub(crate) struct _ProtobufTypeDynamicImpl<T: ProtobufTypeTrait>(pub marker::PhantomData<T>);
23
24impl<T> _ProtobufTypeDynamic for _ProtobufTypeDynamicImpl<T>
25where
26 T: ProtobufTypeTrait,
27 <T as ProtobufTypeTrait>::ProtobufValue: ProtobufValue,
28{
29 fn wire_type(&self) -> WireType {
30 T::WIRE_TYPE
31 }
32
33 fn runtime_type(&self) -> RuntimeType {
34 <T::ProtobufValue as ProtobufValue>::RuntimeType::runtime_type_box()
35 }
36}