百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

rust-systemd

> 编程语言
开源

Rust 接口到 systemd c API

181 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

Rust 接口到 systemd c API

rust-systemd

crate docs (systemd)

crate docs (libsystemd-sys)

systemd

libsystemd-sys

In Cargo.toml:

toml
[dependencies]
systemd = "0.10.1"

Build Environment variables

By default, libsystemd-sys will use pkg-config to find libsystemd. It defaults to using the libsystemd package. To change the package looked up in pkg-config, set the SYSTEMD_PKG_NAME environment variable.

If you want to override the source of the libsystemd directly, set the env var SYSTEMD_LIB_DIR to a path which contains the libsystemd to link against. Optionally, you may also set SYSTEMD_LIBS to indicate which libraries to link against. Libraries in the variable SYSTEMD_LIBS are colon (:) separated and may include a KIND. For example: SYSTEMD_LIBS="static=foo:bar".

elogind support

Either set SYSTEMD_PKG_NAME=libelogind (name of the pkg-config file) or set both SYSTEMD_LIBS=elogind and set SYSTEMD_LIB_DIR to the appropriate directory.

When using elogind, the apis needed for journal and bus features may not be completely available (elogind forked from an older version of systemd that may lack some of these APIs). If your application does not need these features, depend on systemd without the default features to allow maximum compatibility:

toml
[dependencies]
systemd = { version = "0.10.1", default-features = false }

Note that there still may be some missing symbols. If you discover a link error, report it so that we can tweak the systemd crate to support it.

journal

Journal sending is supported, and systemd::journal::Journal is a (low functionality) wrapper around the read API.

An example of the journal writing api:

rust
use log::warn;
use systemd::{journal, sd_journal_log};

fn main() {
   journal::print(1, &format!("Rust can talk to the journal: {:?}", 4));
   journal::send(&["CODE_FILE=HI", "CODE_LINE=1213", "CODE_FUNCTION=LIES"]);
   journal::JournalLog::init().unwrap();
   warn!("HI");
   sd_journal_log!(4, "HI {:?}", 2);
}

daemon

The daemon API mostly offers tools for working with raw filehandles passed to the process by systemd on socket activation. Since raw filehandles are not well supported in Rust, it's likely these functions will mostly be helpful in managing program flow; actual socket code will have to use the libc crate.

License

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

In addition to the permissions in the GNU Lesser General Public License, the authors give you unlimited permission to link the compiled version of this library into combinations with other programs, and to distribute those programs without any restriction coming from the use of this library. (The Lesser General Public License restrictions do apply in other respects; for example, they cover modification of the library, and distribution when not linked into another program.)

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

Contributions

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be licensed as above, without any additional terms or conditions.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rust

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言