Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
6 changes: 3 additions & 3 deletions examples/bus-blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ fn main() {

let bn = bus::BusName::from_bytes(b"com.codyps.systemd-test\0").unwrap();
bus.request_name(bn, 0).unwrap();
println!("got name {:?}", bn);
println!("got name {bn:?}");

let op = bus::ObjectPath::from_bytes(b"/com/codyps/systemd_test\0").unwrap();
bus.add_object(op, |m| {
println!("message: {:?}", m);
println!("message: {m:?}");
Ok(())
})
.unwrap();
println!("added object: {:?}", op);
println!("added object: {op:?}");

loop {
println!("wait?");
Expand Down
19 changes: 9 additions & 10 deletions examples/journal-logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#[cfg(feature = "journal")]
mod x {
//! Follow future journal log messages and print up to 100 of them.
use std::io::ErrorKind;

use systemd::journal::{self, JournalRecord, JournalSeek};
use systemd::Error;
Expand All @@ -30,23 +29,23 @@ mod x {
let mut i = 0;
reader
.watch_all_elements(|record: JournalRecord| {
let unit = record.get(KEY_UNIT).ok_or_else(|| {
Error::new(ErrorKind::Other, "Could not get unit from record")
})?;
let message = record.get(KEY_MESSAGE).ok_or_else(|| {
Error::new(ErrorKind::Other, "Could not get message from record")
})?;
println!("[{}] {}", unit, message);
let unit = record
.get(KEY_UNIT)
.ok_or_else(|| Error::other("Could not get unit from record"))?;
let message = record
.get(KEY_MESSAGE)
.ok_or_else(|| Error::other("Could not get message from record"))?;
println!("[{unit}] {message}");

i += 1;
if i < MAX_MESSAGES {
Ok(())
} else {
Err(Error::new(ErrorKind::Other, "Done watching"))
Err(Error::other("Done watching"))
}
})
.unwrap_or_else(|e| {
println!("Stop watching log. Reason: {}", e);
println!("Stop watching log. Reason: {e}");
});

println!("End of example.");
Expand Down
2 changes: 1 addition & 1 deletion examples/journal-reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ mod x {
.map(|v| v.into_owned())
});

println!("[{:?}] {:?}", unit, message);
println!("[{unit:?}] {message:?}");

i += 1;
if i >= MAX_MESSAGES {
Expand Down
60 changes: 60 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
inputs = {
nixpkgs.url = "nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, flake-utils, nixpkgs }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = ((import nixpkgs) {
inherit system;
});
in
{
formatter = pkgs.nixpkgs-fmt;

devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
rustc
cargo
rustfmt
sccache
clippy
rust-analyzer
systemd
pkg-config
];

RUSTC_WRAPPER = "sccache";
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
};
}
);
}
14 changes: 7 additions & 7 deletions libsystemd-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ fn main() {
let name_upper = name.to_ascii_uppercase();
let mut be = build_env::BuildEnv::from_env().unwrap();

let lib_var = format!("{}_LIBS", name_upper);
let lib_dir_var = format!("{}_LIB_DIR", name_upper);
let lib_var = format!("{name_upper}_LIBS");
let lib_dir_var = format!("{name_upper}_LIB_DIR");

let libs = be.var(lib_var);
let lib_dir = match be.var(lib_dir_var.clone()) {
Some(lib_dir) => lib_dir,
None => {
// No lib_dir specified, use pkg-config
let ln_vn = format!("{}_PKG_NAME", name_upper);
let ln_vn = format!("{name_upper}_PKG_NAME");
let library_name = be
.var(&ln_vn)
.map(|v| {
Expand All @@ -24,7 +24,7 @@ fn main() {
)
})
})
.unwrap_or_else(|| format!("lib{}", name));
.unwrap_or_else(|| format!("lib{name}"));

let library = pkg_config::find_library(&library_name);

Expand All @@ -34,7 +34,7 @@ fn main() {
return;
}
Err(error) => {
eprintln!("pkg_config could not find {:?}: {}", library_name, error);
eprintln!("pkg_config could not find {library_name:?}: {error}");
std::process::exit(1);
}
};
Expand All @@ -57,11 +57,11 @@ fn main() {
Some(libs) => {
//let libs = libs.expect(&format!("non utf-8 value provided in {}", lib_var));
for lib in libs.into_string().unwrap().split(':') {
println!("cargo:rustc-link-lib={}", lib);
println!("cargo:rustc-link-lib={lib}");
}
}
None => {
println!("cargo:rustc-link-lib={}", name);
println!("cargo:rustc-link-lib={name}");
}
}
}
Loading
Loading