Crate gstuff

Source

Macros§

ERR
Returns a Err(String), prepending the current location (file name and line number) to the string.
ERRL
Prepends file name and line number to the given message.
gstring
A helper to build a string on the stack.
try_f
Returns on error, prepending the current location to a stringified error, then passing the string to From::from.
try_fu
Lifts an error into a boxed future. Box<Future<Item=_, Error=_>>.
try_fus
Lifts an error into a boxed future. Box<Future<Item=_, Error=String>>.
try_s
Returns on error, converting the Err value to String and prepending the current location.
try_sp
Like try_s, but takes a reference.

Structs§

FileLock
Allows several threads or processes to compete for a shared resource by tracking resource ownership with a file.
If the lock file is older than ttl_sec then it is removed, allowing us to recover from a thread or process dying while holding the lock.
IniMutex
IniMutexGuard
OrdF32
Allows to sort by float, but panics if there’s a NaN or infinity
OrdFloat
Allows to sort by float, but panics if there’s a NaN or infinity
ProcEn
Process entry in /proc.
ProcIt
Iterate over processes in /proc.
TSafe

Enums§

LockInitErr

Statics§

SPIN_OUT

Traits§

AtBool
AtI8
AtI32
AtI64
AtUsize

Functions§

any_to_str
Useful with panic handlers.
b2s
bedstead2bits
Bedstead to row-major bits, 2x3
binprint
Helps logging binary data (particularly with text-readable parts, such as bencode, netstring) by replacing all the non-printable bytes with the blank character.
bits2bedstead
Row-major bits, 2x3, to Bedstead
civil_from_days
now_ms / 1000 / 86400 ↦ year, month, day UTC
cmd
Run a command, printing it first. Stdout and stderr are forwarded through (inherit).
days_from_civil
year, month 1..=12, day 1..=31 UTC ↦ UNIX milliseconds (aka now_ms) / 1000 / 86400
duration_to_float
Converts the duration into a number of seconds with fractions.
duration_to_ms
Converts the duration into a number of milliseconds.
filename
Shortcut to path->filename conversion.
ics2ms
integer with centiseconds “%y%m%d%H%M%S%.2f” into UNIX time in milliseconds
iso8601ics
ISO 8601 shorthand “2022-12-12T12” converted into integer with centiseconds “%y%m%d%H%M%S%.2f”
last_modified_sec
Last-modified of the file in seconds since the UNIX epoch, with fractions.
Returns 0 if the file does not exists.
ms2ics
UNIX time into integer with centiseconds “%y%m%d%H%M%S%.2f”, UTC
ms2sec
Converts time in milliseconds into a number of seconds with fractions.
netstring
Takes a netstring from the front of the slice.
now_float
The current number of seconds since UNIX epoch, with fractions.
now_ms
The current number of milliseconds since UNIX epoch.
rdtsc
On x86_64 it is Time Stamp Counter (number of cycles).
Fall backs to SystemTime as_nanos otherwise.
round8
round_to
slurp
Read contents of the file into a Vec.
Similar to std::fs::read.
slurp_prog
Runs a command in a shell, returning stderr+stdout on success.
with_hostname
Wraps gethostname to fetch the current hostname into a temporary buffer.