mod cert;
mod json;
mod term;
pub use cert::{check_certificate, check_counterexample, check_witness, CertInfo};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CheckError {
pub code: &'static str,
pub message: String,
}
impl std::fmt::Display for CheckError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}: {}", self.code, self.message)
}
}
impl std::error::Error for CheckError {}
pub(crate) fn rejected(msg: impl Into<String>) -> CheckError {
CheckError {
code: "RX-E001",
message: msg.into(),
}
}
pub(crate) fn malformed(msg: impl Into<String>) -> CheckError {
CheckError {
code: "RX-E004",
message: msg.into(),
}
}
#[cfg(target_arch = "wasm32")]
pub(crate) fn on_big_stack<R: Send + 'static>(f: impl FnOnce() -> R + Send + 'static) -> R {
f()
}
#[cfg(not(target_arch = "wasm32"))]
pub(crate) fn on_big_stack<R: Send + 'static>(f: impl FnOnce() -> R + Send + 'static) -> R {
match std::thread::Builder::new()
.stack_size(256 * 1024 * 1024)
.spawn(f)
{
Ok(h) => match h.join() {
Ok(r) => r,
Err(_) => std::process::abort(),
},
Err(_) => std::process::abort(),
}
}