Expand description
The operating-system calls the native host makes that the standard library does not offer at this workspace’s minimum Rust version, behind safe functions: an advisory lock on a file, a rename that never replaces its target, a handler for a request to terminate the process, the process’s resident memory, the work the calling thread has done, and a diagnostic line on standard error that a closed stream does not turn into a panic.
The rest of the workspace forbids unsafe; this crate, like
alpha2-ffmpeg-bridge, is where the few calls that need it are kept and
reviewed.
Macros§
- diagnostic
eprintln!for the native host and its libraries: the same line on standard error, dropped when the stream cannot take it (write_diagnostic).
Structs§
- Process
Memory - The process’s resident memory, as the operating system counts it.
- Termination
- A request to end the process: an interrupt or termination signal on Unix, a console control event on Windows.
Functions§
- on_
termination - Calls
handleron a thread of its own each time the process is asked to terminate, instead of the process ending at once. - process_
memory - The process’s resident memory now and at its peak; a figure the
operating system does not report (or this build does not read on it) is
None. - rename_
no_ replace - Renames
fromtotounlesstoexists, in one step: a file that appears attoat any moment, up to the rename itself, is never replaced, and the rename fails withio::ErrorKind::AlreadyExists. - same_
file - Whether
pathnames the filefileis open on now:falsewhen the path no longer exists, names another file (one removed and created again), or names a removed file that some handle keeps open (file’s own included): Windows and an SMB share keep such a name until the last handle closes. - same_
file_ at - Whether the paths
aandbname one file: the same device and inode on Unix, the same volume serial and file index on Windows. Hard links and paths through symbolic links to one file are the same file; two copies are not.falsewhen either path names nothing. - thread_
cpu_ work - The work the calling thread has done so far, as a count that only this
thread’s other readings are comparable to: CPU nanoseconds on Unix
(
CLOCK_THREAD_CPUTIME_ID), CPU cycles on Windows (QueryThreadCycleTime). Time the thread spent waiting for a CPU, as on a busy machine, is not in it, which is what a test that compares the work of two input sizes needs.Nonewhere the operating system does not report it (or this build does not read it there). - try_
lock_ exclusive - Takes an exclusive advisory lock on
filewithout waiting:Ok(true)when this handle now holds it,Ok(false)when another open handle (in this process or another) does. - write_
diagnostic - Writes one line to standard error, the way
eprintln!does, and drops it when the stream is closed or full instead of panicking.