rocket_anyhow 0.2.0

throw any error inside rocket's route
Documentation
  • Coverage
  • 66.67%
    2 out of 3 items documented1 out of 2 items with examples
  • Size
  • Source code size: 47.6 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 5.48 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 1m 52s Average build duration of successful builds.
  • all releases: 1m 17s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • thanadolps

rocket_anyhow

This library provided rocket_anyhow::Error, a wrapper around anyhow::Error with rocket's responder implemented.

use std::io::Write;

#[post("/<path..>", data="<text>")]
fn write_utf8_to(path: std::path::PathBuf, text: Vec<u8>) -> rocket_anyhow::Result {
   let mut file = std::fs::File::open(path)?;
   let text = std::str::from_utf8(&text)?;
   file.write_all(text.as_ref())?;
   Ok(())
}