pub trait ToBytes {
// Required methods
fn binary_size(&self) -> usize;
fn write<W: Write>(&self, writer: W) -> Result<()>;
fn default_repr() -> impl ToBytes;
}
Expand description
Convert a field to binary representation
Required Methods§
sourcefn binary_size(&self) -> usize
fn binary_size(&self) -> usize
Return the number of bytes needed to store the field
sourcefn default_repr() -> impl ToBytes
fn default_repr() -> impl ToBytes
Return the default representation for the field type
Note: this does not need to be the same type as the implementing type.
For example, an empty C-style string can be represented e.g. by returning 0u8
.
Object Safety§
This trait is not object safe.