The `peepmatic-runtime` crate contains everything required to use a `peepmatic`-generated peephole optimizer. In short: build times and code size. If you are just using a peephole optimizer, you shouldn't need the functions to construct it from scratch from the DSL (and the implied code size and compilation time), let alone even build it at all. You should just deserialize an already-built peephole optimizer, and then use it. That's all that is contained here in this crate.
45 lines
915 B
Rust
45 lines
915 B
Rust
//! `Error` and `Result` types for this crate.
|
|
|
|
use std::io;
|
|
use thiserror::Error;
|
|
|
|
/// A result type containing `Ok(T)` or `Err(peepmatic_runtime::Error)`.
|
|
pub type Result<T> = std::result::Result<T, Error>;
|
|
|
|
/// Errors that `peepmatic_runtime` may generate.
|
|
#[derive(Debug, Error)]
|
|
#[error(transparent)]
|
|
pub struct Error {
|
|
#[from]
|
|
inner: Box<ErrorInner>,
|
|
}
|
|
|
|
#[derive(Debug, Error)]
|
|
enum ErrorInner {
|
|
#[error(transparent)]
|
|
Io(#[from] io::Error),
|
|
|
|
#[error(transparent)]
|
|
Bincode(#[from] bincode::Error),
|
|
}
|
|
|
|
impl From<io::Error> for Error {
|
|
fn from(e: io::Error) -> Error {
|
|
let e: ErrorInner = e.into();
|
|
e.into()
|
|
}
|
|
}
|
|
|
|
impl From<bincode::Error> for Error {
|
|
fn from(e: bincode::Error) -> Error {
|
|
let e: ErrorInner = e.into();
|
|
e.into()
|
|
}
|
|
}
|
|
|
|
impl From<ErrorInner> for Error {
|
|
fn from(e: ErrorInner) -> Error {
|
|
Box::new(e).into()
|
|
}
|
|
}
|