urma-io 0.3.3

Bounded file reads and atomic writes for URMA
Documentation

urma-io

Small I/O primitives for bounded input and deliberate output.

crates.io · API reference · Source · URMA

Use urma-io for the file operations shared by URMA components: reading with an explicit size limit, writing through a temporary file, and hashing streams.

Get started

cargo add urma-io

Hash bytes from a reader

use std::io::Cursor;

fn main() -> Result<(), std::io::Error> {
    let mut input = Cursor::new(b"For the record.");
    let checksum = urma_io::digest(&mut input)?;
    assert_eq!(input.position(), b"For the record.".len() as u64);
    let _ = checksum;
    Ok(())
}

digest reads from the stream's current position; it does not rewind it.

API guide

Entry point Use it for
read_bounded Read a file with a caller-selected byte limit.
write_new Write atomically without replacing an existing destination.
write_replace Atomically replace a destination.
digest Compute a SHA-256 digest from a reader.

Where it fits

For sensitive inputs on supported native targets, see read_private, read_shared, read_admin, check_admin, read_regular, create_file, open_private_append and create_private_directory in the API. These are used by urma-identity, urma-runtime and higher-level workflows.

Boundaries

Native private-file helpers use Unix modes and O_NOFOLLOW on Unix, and DACLs plus reparse-point refusal on Windows. A WASM build does not imply browser access to native filesystem operations. Choose the helper appropriate to the target and handle its errors.

License

0BSD. Part of the URMA workspace, maintained by Cristian Zmole. Project contact.