mod buf;
mod wire_type;
pub mod alloc_profile;
pub mod fixed;
pub mod length_delimited;
pub mod tag;
pub mod unknown;
pub mod varint;
pub mod zigzag;
pub use buf::{DecodeBuffer, EncodeBuffer};
pub use fixed::{
decode_double, decode_fixed32, decode_fixed64, decode_float, decode_sfixed32, decode_sfixed64,
encode_double, encode_fixed32, encode_fixed64, encode_float, encode_sfixed32, encode_sfixed64,
};
pub use length_delimited::{
decode_length_delimited, decode_string, encode_length_delimited, encode_string,
encoded_len_length_delimited,
};
pub use tag::{decode_tag, encode_tag, make_tag, Tag, MAX_FIELD_NUMBER};
pub use unknown::{UnknownField, UnknownFields, UnknownValue};
pub use varint::{
decode_varint, decode_varint32, decode_varint_bool, decode_varint_i32, decode_varint_i64,
encode_varint, encode_varint32, encode_varint_bool, encode_varint_fixed, encode_varint_i32,
encode_varint_i64,
};
pub use wire_type::WireType;
pub use zigzag::{zigzag_decode32, zigzag_decode64, zigzag_encode32, zigzag_encode64};
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum WireError {
UnexpectedEof,
Overflow,
InvalidWireType(u32),
InvalidFieldNumber(u32),
TruncatedMessage {
declared: usize,
available: usize,
},
OutOfRange(prost::alloc::string::String),
InvalidUtf8(core::str::Utf8Error),
}
impl core::fmt::Display for WireError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
WireError::UnexpectedEof => write!(f, "unexpected end of input"),
WireError::Overflow => write!(f, "varint overflow (>10 bytes)"),
WireError::InvalidWireType(w) => write!(f, "invalid wire type: {w}"),
WireError::InvalidFieldNumber(n) => write!(f, "invalid field number: {n}"),
WireError::TruncatedMessage {
declared,
available,
} => write!(
f,
"truncated message: declared {declared} bytes but only {available} available"
),
WireError::OutOfRange(msg) => write!(f, "value out of range: {msg}"),
WireError::InvalidUtf8(e) => write!(f, "invalid UTF-8: {e}"),
}
}
}
impl core::error::Error for WireError {}