Crate posish[][src]

Expand description

posish provides safe wrappers to libc functions. The current focus is on the functionality needed by cap-std and system-interface that isn’t provided by std or getrandom.

The wrappers perform the following tasks:

  • Error values are translated to Results.
  • Out-parameters are translated to return values.
  • Path arguments can by any kind of string type.
  • File descriptors are passed in through arguments implementing [AsFd] instead of as bare integers and returned as [OwnedFd]s.
  • Constants use enums and bitflags types.
  • Multiplexed functions (eg. fcntl, ioctl, etc.) are de-multiplexed.
  • Variadic functions (eg. openat, etc.) are presented as non-variadic.
  • Functions and types which need 64 suffixes to enable large-file support are used automatically.
  • Behaviors that depend on the sizes of C types like long are hidden.
  • File offsets and sizes are presented as i64 and u64 rather than off_t.
  • In some places, more human-friendly and less historical-accident names are used.

Things they don’t do include:

  • Emulating functions that aren’t natively supported on a platform.
  • Detecting whether functions are supported at runtime.
  • Hiding significant differences between platforms.
  • Hiding ambient authorities.
  • Imposing sandboxing features such as filesystem path or network address sandboxing.

See cap-std and system-interface for libraries which do hide ambient authorities and perform sandboxing.

Safety

This library uses the io-lifetimes crate to manage all OS resource handles, automatically ensuring I/O safety.

Modules

fs

Filesystem operations.

io

I/O operations.

net

Network-related operations.

path

Filesystem path operations.

process

Process-associated operations.

time

Time-related operations.