pub use crate::decoding::{Decodable, DecodableMessage, Deserializer, Result};
pub use crate::encoding::{Encodable, EncodableMessage, ProtobufSerializer};
pub use crate::wire_types::*;
pub use crate::VarInt;
pub use bytes::{Buf, BufMut};
pub trait HasField<const NUM: u64> {
type PreCompArray: AsRef<[u8]>;
const PRECOMP: Self::PreCompArray;
}
pub trait HasFieldDecode<const NUM: u64> {
type VarInt: VarInt;
const FNUM: Self::VarInt;
}
pub struct __ConstBoundWorkaround<T>(T);
impl<T: WireType> WireType for __ConstBoundWorkaround<T> {
const BITS: u8 = T::BITS;
}
impl<T: WireType> crate::traits::private::Sealed for __ConstBoundWorkaround<T> {}
pub const unsafe fn precompute_field_varint<F, const N: usize>(mut num: u64) -> [u8; N]
where
__ConstBoundWorkaround<F>: WireType,
{
let mut bytes = [0; N];
let lowest_byte =
(num << 3 & 0b0111_1000) as u8 | <__ConstBoundWorkaround<F> as WireType>::BITS;
num >>= 4;
bytes[N - 1] = lowest_byte;
let mut n = N - 1;
if n == 0 {
return bytes;
}
loop {
if num == 0 {
return bytes;
}
n -= 1;
bytes[n] = (num & 0b0111_1111) as u8 | 0b1000_0000;
num >>= 7;
if n == 0 {
return bytes;
}
}
}