Skip to main content

Crate logmv

Crate logmv 

Source
Expand description

Logged atomic file move and trash with an append-only JSON-Lines audit trail.

logmv renames a file, or moves it to a trash directory, and records the operation as one compact JSON line per action so every change is auditable. Moves are atomic renames only (never a copy fallback), never overwrite an existing destination, and trash never unlinks. See run for the orchestration and Op for the operations it performs.

§Platform support

logmv supports only macOS and Linux. The crate bakes in macOS/Linux-specific assumptions: EXDEV == raw OS error 18, '/' path separators (see ends_with_sep), and the ~/.Trash move model (resolved in main.rs). Other platforms differ on all three, so a non-macOS/Linux build is rejected at compile time via compile_error! rather than silently misbehaving. The guard lives here; the binary depends on the library, so it is guarded transitively.

One further Linux-only divergence affects log fidelity, not the move itself. The rename is byte-faithful: it uses the real OsStr bytes (see path_to_cstring), so a non-UTF-8 filename is moved correctly. The log, however, records src and dst via to_string_lossy, so on Linux each invalid UTF-8 byte is written as U+FFFD (the Unicode replacement character); JSON strings must be valid Unicode, so the raw bytes cannot be stored verbatim. A log line whose src or dst contains U+FFFD is therefore not a byte-exact record and is not reliably reversible. macOS (APFS/HFS+) enforces UTF-8, so this case is unreachable there.

Enums§

Error
Typed errors for logmv operations.
Op
A file-system operation for logmv to perform.

Functions§

run
Orchestrate: resolve final dst → never-overwrite + pair-collision check → --mkdir (create + log each) → atomic rename → log move/trash → --rmdir (remove + log each, cascading).