protobuf/varint/
generic.rsuse crate::rt::compute_raw_varint64_size;
pub(crate) trait ProtobufVarint {
fn len_varint(&self) -> u64;
}
impl ProtobufVarint for u64 {
fn len_varint(&self) -> u64 {
compute_raw_varint64_size(*self)
}
}
impl ProtobufVarint for u32 {
fn len_varint(&self) -> u64 {
(*self as u64).len_varint()
}
}
impl ProtobufVarint for i64 {
fn len_varint(&self) -> u64 {
(*self as u64).len_varint()
}
}
impl ProtobufVarint for i32 {
fn len_varint(&self) -> u64 {
(*self as i64).len_varint()
}
}
impl ProtobufVarint for bool {
fn len_varint(&self) -> u64 {
1
}
}