Trait protobuf::reflect::runtime_types::RuntimeType [−][src]
pub trait RuntimeType: Debug + Send + Sync + 'static {
type Value: ProtobufValue + Clone + Sized + Debug + Default;
fn runtime_type_box() -> RuntimeTypeBox
where
Self: Sized;
fn default_value_ref() -> ReflectValueRef<'static>;
fn from_value_box(
value_box: ReflectValueBox
) -> Result<Self::Value, ReflectValueBox>;
fn into_value_box(value: Self::Value) -> ReflectValueBox;
fn as_ref(value: &Self::Value) -> ReflectValueRef<'_>;
fn as_mut(value: &mut Self::Value) -> ReflectValueMut<'_>;
fn is_non_zero(value: &Self::Value) -> bool;
fn into_static_value_ref(value: Self::Value) -> ReflectValueRef<'static> { ... }
fn set_from_value_box(target: &mut Self::Value, value_box: ReflectValueBox) { ... }
}
Expand description
RuntimeType
is not implemented by all protobuf types directly
because it’s not possible to implement RuntimeType
for all Message
implementations at once: each Message
implementation has to reimplement
all the methods again. With current strategy there’s only implementation
for all messages, which is RuntimeTypeMessage
.
The downside is that we have to explicitly specify type parameters in a lot of places.
Associated Types
Required methods
fn runtime_type_box() -> RuntimeTypeBox where
Self: Sized,
fn runtime_type_box() -> RuntimeTypeBox where
Self: Sized,
“Box” version of type type.
fn default_value_ref() -> ReflectValueRef<'static>
fn default_value_ref() -> ReflectValueRef<'static>
Default value for this type.
fn from_value_box(
value_box: ReflectValueBox
) -> Result<Self::Value, ReflectValueBox>
fn from_value_box(
value_box: ReflectValueBox
) -> Result<Self::Value, ReflectValueBox>
fn into_value_box(value: Self::Value) -> ReflectValueBox
fn into_value_box(value: Self::Value) -> ReflectValueBox
Convert a value into a refletive box value.
fn as_ref(value: &Self::Value) -> ReflectValueRef<'_>
fn as_ref(value: &Self::Value) -> ReflectValueRef<'_>
Pointer to a dynamic reference.
Mutable pointer to a dynamic mutable reference.
fn is_non_zero(value: &Self::Value) -> bool
fn is_non_zero(value: &Self::Value) -> bool
Value is non-default?
Provided methods
fn into_static_value_ref(value: Self::Value) -> ReflectValueRef<'static>
fn into_static_value_ref(value: Self::Value) -> ReflectValueRef<'static>
fn set_from_value_box(target: &mut Self::Value, value_box: ReflectValueBox)
fn set_from_value_box(target: &mut Self::Value, value_box: ReflectValueBox)
Write the value.