Skip to main content

Crate systemd

Crate systemd 

Source
Expand description

Rust interfaces to libsystemd and compatible libraries.

Native APIs introduced in newer releases require explicit Cargo features: systemd_v240 enables boot-specific application IDs and bus timeout APIs; systemd_v241 adds the raw close-and-unref helper; systemd_v245 adds journal namespaces; systemd_v254 adds session start-time queries. Each version feature includes the earlier version features. The default bus feature requires the callback-lifetime APIs from systemd 239. With bus disabled, the base APIs require systemd 233 or equivalent capabilities.

The build script checks required native symbols by linking a probe for the target without running it. This includes explicit SYSTEMD_LIB_DIR and SYSTEMD_LIBS selections and libraries selected by SYSTEMD_PKG_NAME, including libelogind. Disable unsupported features or install a library providing the selected APIs when the capability check fails.

Fallible systemd APIs use Error and Result. The crate-owned error preserves errno and I/O error kinds while adding operation and argument context. See Error for migration from the previous std::io::Error re-export. D-Bus method errors use bus::Error when the bus feature is enabled; logger installation uses log::SetLoggerError.

Re-exports§

pub use journal::JournalFiles;Deprecatedjournal
pub use journal::FormattedJournalLog;journal
pub use journal::Journal;journal
pub use journal::JournalLog;journal
pub use journal::JournalRecord;journal
pub use journal::JournalSeek;journal
pub use journal::JournalWaitResult;journal

Modules§

busbus
An interface to work with the dbus message bus.
daemon
id128
APIs to process and generate 128-bit ID values for systemd.
journaljournal
High-level interface to the systemd journal.
login
Interface to introspect on seats, sessions and users. Queries for processes, users, and login sessions.
unit
Utilities for working with systemd units.

Macros§

log_with
Similar to log!(), except it accepts a func argument rather than hard coding ::log::log(), and it doesn’t filter on log_enabled!().
sd_journal_logjournal
Log a message with source location metadata, returning Result<()>.

Structs§

Error
An error from a systemd operation, with its underlying cause and optional context.

Traits§

CStrArgument
A string argument for an API that needs a NUL-terminated string.

Functions§

ffi_result
Convert a systemd ffi return value into a Result

Type Aliases§

Result
The result of a systemd operation. See Error for details and I/O conversions.