1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use std::marker;
use crate::reflect::types::ProtobufType;
use crate::reflect::ProtobufValue;
use crate::reflect::RuntimeTypeBox;
use crate::wire_format::WireType;
pub trait ProtobufTypeDynamic: Send + Sync + 'static {
fn wire_type(&self) -> WireType;
fn runtime_type(&self) -> RuntimeTypeBox;
}
pub(crate) struct ProtobufTypeDynamicImpl<T: ProtobufType>(pub marker::PhantomData<T>);
impl<T> ProtobufTypeDynamic for ProtobufTypeDynamicImpl<T>
where
T: ProtobufType,
<T as ProtobufType>::ProtobufValue: ProtobufValue,
{
fn wire_type(&self) -> WireType {
T::WIRE_TYPE
}
fn runtime_type(&self) -> RuntimeTypeBox {
<T::ProtobufValue as ProtobufValue>::runtime_type_box()
}
}