macro_rules! delegate_value_encoding {
(
delegate from ($from_ty:ty) to ($to_ty:ty) for type ($value_ty:ty)
$(with where clause ($($where_clause:tt)+))?
$(with generics ($($value_generics:tt)*))?
) => { ... };
(
delegate from ($from_ty:ty) to ($to_ty:ty) for type ($value_ty:ty) including distinguished
$(with where clause for relaxed ($($relaxed_where:tt)+))?
$(with where clause for distinguished ($($distinguished_where:tt)+))?
$(with generics ($($value_generics:tt)*))?
) => { ... };
(
encoding ($encoding:ty) borrows type ($ty:ty) as owned
$(with where clause ($($where_clause:tt)+))?
$(with generics ($($impl_generics:tt)*))?
) => { ... };
(
encoding ($encoding:ty) borrows type ($ty:ty) as owned including distinguished
$(with where clause ($($where_clause:tt)+))?
$(with generics ($($impl_generics:tt)*))?
) => { ... };
}Expand description
Expressly delegates support for encoding values from one encoding to another, but not message
fields themselves. Most built-in encodings in bilrost have the ability to encode any type they
can encode as a value as a message field as well; a notable exception is the special Proxied
encoding, which cannot.
Also includes support for providing borrowed value decoding implementations that delegate to the
owned implementation, for types which have no borrowed representation. Most types supported by
bilrost cannot be meaningfully borrowed and delegate their borrowed decoding impls back to the
owned impls this way.
Delegation is implemented by macro type-by-type rather than as a blanket impl (such as borrowed
encoding whenever owned decoding exists) right now because we want impl RawMessage to provide
value encoding and decoding in the General encodings. This continues to preclude any other
blanket trait delegation.