anza 0.5.0

Ultra-lightweight, zero-copy, cryptographically verified Server-Templated UI (STUI) engine
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use {
  crate::errors::{Error, Result},
  std::{fs::File, path::Path},
};

pub fn text(path: &Path) -> Result<String> {
  std::fs::read_to_string(path).map_err(|e| Error::not_found(format!("Failed to read {}: {}", path.display(), e)))
}

pub fn mmap(path: &Path) -> Result<memmap2::Mmap> {
  let file = File::open(path).map_err(|e| Error::not_found(format!("Failed to open {}: {}", path.display(), e)))?;
  unsafe {
    memmap2::Mmap::map(&file).map_err(|e| Error::internal(format!("Failed to mmap {}: {}", path.display(), e)))
  }
}