#![forbid(unsafe_code)]
#![cfg_attr(not(feature = "std"), no_std)]
#[cfg(not(feature = "std"))]
extern crate alloc;
pub mod wire;
pub mod arena;
pub mod extensions;
pub mod message;
pub mod name;
pub mod oneof;
pub mod reflect_bridge;
pub use prost::Message;
pub use prost::Name;
pub use prost_types;
pub use extensions::Extensions;
pub use message::OxiMessage;
pub use name::OxiName;
pub use oneof::OxiOneof;
pub type OxiProtoResult<T> = Result<T, OxiProtoError>;
#[derive(Debug)]
#[non_exhaustive]
pub enum OxiProtoError {
ParseError(prost::alloc::string::String),
CodegenError(prost::alloc::string::String),
#[cfg(feature = "std")]
IoError(std::io::Error),
WireFormatError(wire::WireError),
}
impl core::fmt::Display for OxiProtoError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
OxiProtoError::ParseError(s) => write!(f, "proto parse error: {s}"),
OxiProtoError::CodegenError(s) => write!(f, "proto codegen error: {s}"),
#[cfg(feature = "std")]
OxiProtoError::IoError(e) => write!(f, "I/O error: {e}"),
OxiProtoError::WireFormatError(e) => write!(f, "wire format error: {e}"),
}
}
}
impl core::error::Error for OxiProtoError {
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
match self {
#[cfg(feature = "std")]
OxiProtoError::IoError(e) => Some(e),
OxiProtoError::WireFormatError(e) => Some(e),
OxiProtoError::ParseError(_) | OxiProtoError::CodegenError(_) => None,
}
}
}
#[cfg(feature = "std")]
impl From<std::io::Error> for OxiProtoError {
fn from(e: std::io::Error) -> Self {
OxiProtoError::IoError(e)
}
}
impl From<wire::WireError> for OxiProtoError {
fn from(e: wire::WireError) -> Self {
OxiProtoError::WireFormatError(e)
}
}