#![forbid(unsafe_code)]
#![warn(missing_docs)]
mod decode;
mod floor;
mod open;
mod options;
pub use decode::decode;
pub use options::Options;
#[must_use]
pub fn decoder_version() -> &'static str {
env!("CARGO_PKG_VERSION")
}
#[derive(Debug)]
#[non_exhaustive]
pub enum Error {
Open(String),
Read(String),
FloorRefusal {
feature: String,
reason: String,
},
ResourceLimit {
what: String,
ceiling: String,
},
Ir(brygge_ir::Error),
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Open(m) => write!(f, "cannot open Git repository: {m}"),
Self::Read(m) => write!(f, "cannot read Git repository: {m}"),
Self::FloorRefusal { feature, reason } => {
write!(
f,
"refused Git feature '{feature}' below the floor: {reason}"
)
}
Self::ResourceLimit { what, ceiling } => {
write!(f, "refused: {what} exceeds brygge's ceiling ({ceiling})")
}
Self::Ir(e) => write!(f, "IR assembly failed: {e}"),
}
}
}
impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Self::Ir(e) => Some(e),
_ => None,
}
}
}
impl From<brygge_ir::Error> for Error {
fn from(e: brygge_ir::Error) -> Self {
Self::Ir(e)
}
}