sail-solve 0.3.0

Fast, cached Verus verification for Rust: standalone files, projects, watch and agent workflows
Documentation
//! One isolated native job. The parent owns process lifetime and byte limits.
#![forbid(unsafe_code)]
use std::io::{Read as _, Write as _};

/// mimalloc, as in the D.I.V.E. CLI: state-space exploration allocates
/// heavily, and the system allocator made checks 3–16% slower (#765).
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;

fn main() -> std::process::ExitCode {
    match run() {
        Ok(()) => std::process::ExitCode::SUCCESS,
        Err(error) => {
            eprintln!("SAIL4210: {error}");
            std::process::ExitCode::FAILURE
        }
    }
}

fn run() -> Result<(), Box<dyn std::error::Error>> {
    let mut input = Vec::new();
    std::io::stdin()
        .take(u64::try_from(sail_dive::MAX_DOCUMENT_BYTES)? + 1)
        .read_to_end(&mut input)?;
    if input.len() > sail_dive::MAX_DOCUMENT_BYTES {
        return Err("worker request exceeds its byte bound".into());
    }
    let request = sail_dive::decode_request(&input)?;
    let response = sail_dive::execute(&request);
    let bytes = serde_json::to_vec(&response)?;
    if bytes.len() > sail_dive::MAX_DOCUMENT_BYTES {
        return Err("worker evidence exceeds its byte bound".into());
    }
    std::io::stdout().write_all(&bytes)?;
    Ok(())
}