├── .github └── workflows │ └── rust.yml ├── .gitignore ├── .gitmodules ├── CONTRIBUTING.md ├── Cargo.toml ├── README.md ├── codegen.toml ├── codegen ├── Cargo.lock ├── Cargo.toml └── src │ ├── config │ └── mod.rs │ ├── generator │ ├── mod.rs │ └── ztypes.rs │ ├── main.rs │ └── parser │ ├── data.rs │ ├── interface.rs │ ├── methods.rs │ ├── mod.rs │ ├── node.rs │ ├── properties.rs │ ├── signals.rs │ └── xml.rs ├── examples ├── login1-session_lock-unlock.rs ├── login1-wall_message.rs ├── systemd1-get_default_target.rs └── timedate1-list_timezones.rs ├── justfile └── src ├── helpers.rs ├── home1 ├── generated.rs └── mod.rs ├── hostname1 ├── generated.rs └── mod.rs ├── import1 ├── generated.rs └── mod.rs ├── lib.rs ├── locale1 ├── generated.rs └── mod.rs ├── login1 ├── generated.rs └── mod.rs ├── machine1 ├── generated.rs └── mod.rs ├── network1 ├── generated.rs └── mod.rs ├── oom1 ├── generated.rs └── mod.rs ├── portable1 ├── generated.rs └── mod.rs ├── resolve1 ├── generated.rs └── mod.rs ├── systemd1 ├── generated.rs └── mod.rs ├── sysupdate1 ├── generated.rs └── mod.rs ├── timedate1 ├── generated.rs └── mod.rs └── timesync1 ├── generated.rs └── mod.rs /.github/workflows/rust.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Rust 3 | "on": 4 | push: 5 | branches: [main] 6 | pull_request: 7 | branches: [main] 8 | permissions: 9 | contents: read 10 | 11 | # Avoid wasting job slots on superseded code 12 | concurrency: 13 | group: ${{ github.workflow }}-${{ github.ref }} 14 | cancel-in-progress: true 15 | 16 | env: 17 | CARGO_TERM_COLOR: always 18 | # Pinned toolchain for linting 19 | ACTIONS_LINTS_TOOLCHAIN: 1.84.0 20 | 21 | jobs: 22 | tests-stable: 23 | name: Tests, stable toolchain 24 | runs-on: ubuntu-latest 25 | steps: 26 | - name: Check out repository 27 | uses: actions/checkout@v3 28 | - name: Install toolchain 29 | uses: dtolnay/rust-toolchain@v1 30 | with: 31 | toolchain: stable 32 | - name: cargo build 33 | run: cargo build --all-features 34 | - name: cargo test 35 | run: cargo test --all-features 36 | tests-release-msrv: 37 | name: Tests, minimum supported toolchain 38 | runs-on: ubuntu-latest 39 | steps: 40 | - name: Check out repository 41 | uses: actions/checkout@v3 42 | - name: Detect crate MSRV 43 | run: | 44 | msrv=$(cargo metadata --format-version 1 --no-deps | \ 45 | jq -r '.packages[0].rust_version') 46 | echo "Crate MSRV: $msrv" 47 | echo "MSRV=$msrv" >> $GITHUB_ENV 48 | - name: Install toolchain 49 | uses: dtolnay/rust-toolchain@v1 50 | with: 51 | toolchain: ${{ env.MSRV }} 52 | - name: cargo build 53 | run: cargo build --all-features 54 | - name: cargo test 55 | run: cargo test --all-features 56 | linting: 57 | name: Lints, pinned toolchain 58 | runs-on: ubuntu-latest 59 | steps: 60 | - name: Check out repository 61 | uses: actions/checkout@v3 62 | - name: Install toolchain 63 | uses: dtolnay/rust-toolchain@v1 64 | with: 65 | toolchain: ${{ env.ACTIONS_LINTS_TOOLCHAIN }} 66 | components: rustfmt, clippy 67 | - name: cargo fmt (check) 68 | run: cargo fmt -- --check -l 69 | - name: cargo clippy (warnings) 70 | run: cargo clippy -- -D warnings 71 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /Cargo.lock 3 | /codegen/target 4 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "codegen/systemd"] 2 | path = codegen/systemd 3 | url = https://github.com/systemd/systemd.git 4 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | 3 | This document provides an overview and some general notes about all the code 4 | in this repository. 5 | 6 | ## Motivations and trade-offs 7 | 8 | The `zbus_systemd` library tries to achieve the following goals: 9 | 10 | * provide coverage for all systemd DBus services in a single crate 11 | * build on top of a Rust-native DBus stack, thanks to `zbus` 12 | * statically generate library code directly from systemd definitions 13 | * directly rely on generated interfaces 14 | 15 | ## Code generation 16 | 17 | This project uses [just](https://github.com/casey/just) to perform code-generation. 18 | To refresh all interfaces after making some changes, you can directly run `just` in the top directory. 19 | 20 | All modules are generated from the corresponding systemd doc-page. 21 | The code-generator source lives under `codegen/`, and it can be configured through the `codegen.toml` file. 22 | 23 | The interfaces are re-generated on each major systemd release, in a process that involves: 24 | 25 | * updating the git submodule at `codegen/systemd/` to the latest version 26 | * parsing all the relevant XML files `codegen/systemd/man/` 27 | * writing a `generated.rs` for each service module 28 | * running `cargo fmt` on the whole crate 29 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["Luca Bruno "] 3 | description = "A pure-Rust library to interact with systemd DBus services" 4 | documentation = "https://docs.rs/zbus_systemd" 5 | edition = "2021" 6 | exclude = [".gitignore", "codegen", "justfile"] 7 | keywords = ["dbus", "systemd", "Linux", "zbus", "async"] 8 | license = "MIT/Apache-2.0" 9 | name = "zbus_systemd" 10 | repository = "https://github.com/lucab/zbus_systemd" 11 | version = "0.25701.0" 12 | rust-version = "1.77.0" 13 | 14 | [dependencies] 15 | futures = "0.3" 16 | serde = "1" 17 | zbus = "5.3" 18 | 19 | [dev-dependencies] 20 | tokio = {version = "1", features = ["full"]} 21 | 22 | [features] 23 | home1 = [] 24 | hostname1 = [] 25 | import1 = [] 26 | locale1 = [] 27 | login1 = [] 28 | machine1 = [] 29 | network1 = [] 30 | oom1 = [] 31 | portable1 = [] 32 | resolve1 = [] 33 | systemd1 = [] 34 | sysupdate1 = [] 35 | timedate1 = [] 36 | timesync1 = [] 37 | 38 | [package.metadata.docs.rs] 39 | all-features = true 40 | rustdoc-args = ["--cfg", "docsrs"] 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # zbus_systemd 2 | 3 | [![crates.io](https://img.shields.io/crates/v/zbus_systemd.svg)](https://crates.io/crates/zbus_systemd) 4 | [![Documentation](https://docs.rs/zbus_systemd/badge.svg)](https://docs.rs/zbus_systemd) 5 | 6 | A pure-Rust library to interact with systemd DBus services. 7 | 8 | `zbus_systemd` provides support for interacting with the suite of systemd 9 | services over DBus. This crate tries to cover all systemd interfaces, 10 | across all services. 11 | 12 | Each service has its own dedicated module, which is auto-generated from current 13 | systemd definitions and can be activated through the corresponding Cargo feature: 14 | 15 | * `home1`: systemd-homed interfaces (org.freedesktop.home1) 16 | * `hostname1`: systemd-hostnamed interfaces (org.freedesktop.hostname1) 17 | * `import1`: systemd-importd interfaces (org.freedesktop.import1) 18 | * `locale1`: systemd-localed interfaces (org.freedesktop.locale1) 19 | * `login1`: systemd-logind interfaces (org.freedesktop.login1) 20 | * `machine1`: systemd-machined interfaces (org.freedesktop.machine1) 21 | * `network1`: systemd-networkd interfaces (org.freedesktop.network1) 22 | * `oom1`: systemd-oomd interfaces (org.freedesktop.oom1) 23 | * `portable1`: systemd-portabled interfaces (org.freedesktop.portable1) 24 | * `resolve1`: systemd-resolved interfaces (org.freedesktop.resolve1) 25 | * `systemd1`: systemd interfaces (org.freedesktop.systemd1) 26 | * `sysupdate1`: systemd-sysupdated interfaces (org.freedesktop.sysupdated1) 27 | * `timedate1`: systemd-timedated interfaces (org.freedesktop.timedate1) 28 | * `timesync1`: systemd-timesyncd interfaces (org.freedesktop.timesync1) 29 | 30 | For a quickstart on how to use those interfaces, see the [examples](https://github.com/lucab/zbus_systemd/tree/main/examples). 31 | 32 | ## License 33 | 34 | Licensed under either of 35 | 36 | * MIT license - 37 | * Apache License, Version 2.0 - 38 | 39 | at your option. 40 | -------------------------------------------------------------------------------- /codegen.toml: -------------------------------------------------------------------------------- 1 | [service.home1] 2 | hierarchy = "/org/freedesktop/home1" 3 | id = "org.freedesktop.home1" 4 | module = "home1" 5 | 6 | [service.hostname1] 7 | default_object = "Hostnamed" 8 | hierarchy = "/org/freedesktop/hostname1" 9 | id = "org.freedesktop.hostname1" 10 | module = "hostname1" 11 | 12 | [service.import1] 13 | hierarchy = "/org/freedesktop/import1" 14 | id = "org.freedesktop.import1" 15 | module = "import1" 16 | 17 | [service.locale1] 18 | default_object = "Localed" 19 | hierarchy = "/org/freedesktop/locale1" 20 | id = "org.freedesktop.locale1" 21 | module = "locale1" 22 | 23 | [service.login1] 24 | hierarchy = "/org/freedesktop/login1" 25 | id = "org.freedesktop.login1" 26 | module = "login1" 27 | 28 | [service.machine1] 29 | hierarchy = "/org/freedesktop/machine1" 30 | id = "org.freedesktop.machine1" 31 | module = "machine1" 32 | 33 | [service.network1] 34 | hierarchy = "/org/freedesktop/network1" 35 | id = "org.freedesktop.network1" 36 | module = "network1" 37 | 38 | [service.oom1] 39 | hierarchy = "/org/freedesktop/oom1" 40 | id = "org.freedesktop.oom1" 41 | module = "oom1" 42 | 43 | [service.portable1] 44 | hierarchy = "/org/freedesktop/portable1" 45 | id = "org.freedesktop.portable1" 46 | module = "portable1" 47 | 48 | [service.resolve1] 49 | hierarchy = "/org/freedesktop/resolve1" 50 | id = "org.freedesktop.resolve1" 51 | module = "resolve1" 52 | 53 | [service.systemd1] 54 | hierarchy = "/org/freedesktop/systemd1" 55 | id = "org.freedesktop.systemd1" 56 | module = "systemd1" 57 | 58 | [service.sysupdate1] 59 | hierarchy = "/org/freedesktop/sysupdate1" 60 | id = "org.freedesktop.sysupdate1" 61 | module = "sysupdate1" 62 | 63 | [service.timedate1] 64 | default_object = "Timedated" 65 | hierarchy = "/org/freedesktop/timedate1" 66 | id = "org.freedesktop.timedate1" 67 | module = "timedate1" 68 | 69 | [service.timesync1] 70 | hierarchy = "/org/freedesktop/timesync1" 71 | id = "org.freedesktop.timesync1" 72 | module = "timesync1" 73 | -------------------------------------------------------------------------------- /codegen/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "anyhow" 7 | version = "1.0.97" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" 10 | 11 | [[package]] 12 | name = "codegen" 13 | version = "0.0.1" 14 | dependencies = [ 15 | "anyhow", 16 | "fn-error-context", 17 | "heck", 18 | "nom", 19 | "nom-language", 20 | "serde", 21 | "toml", 22 | "xmltree", 23 | ] 24 | 25 | [[package]] 26 | name = "equivalent" 27 | version = "1.0.2" 28 | source = "registry+https://github.com/rust-lang/crates.io-index" 29 | checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" 30 | 31 | [[package]] 32 | name = "fn-error-context" 33 | version = "0.2.1" 34 | source = "registry+https://github.com/rust-lang/crates.io-index" 35 | checksum = "2cd66269887534af4b0c3e3337404591daa8dc8b9b2b3db71f9523beb4bafb41" 36 | dependencies = [ 37 | "proc-macro2", 38 | "quote", 39 | "syn", 40 | ] 41 | 42 | [[package]] 43 | name = "hashbrown" 44 | version = "0.15.2" 45 | source = "registry+https://github.com/rust-lang/crates.io-index" 46 | checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" 47 | 48 | [[package]] 49 | name = "heck" 50 | version = "0.5.0" 51 | source = "registry+https://github.com/rust-lang/crates.io-index" 52 | checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" 53 | 54 | [[package]] 55 | name = "indexmap" 56 | version = "2.8.0" 57 | source = "registry+https://github.com/rust-lang/crates.io-index" 58 | checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058" 59 | dependencies = [ 60 | "equivalent", 61 | "hashbrown", 62 | ] 63 | 64 | [[package]] 65 | name = "memchr" 66 | version = "2.7.4" 67 | source = "registry+https://github.com/rust-lang/crates.io-index" 68 | checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" 69 | 70 | [[package]] 71 | name = "nom" 72 | version = "8.0.0" 73 | source = "registry+https://github.com/rust-lang/crates.io-index" 74 | checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405" 75 | dependencies = [ 76 | "memchr", 77 | ] 78 | 79 | [[package]] 80 | name = "nom-language" 81 | version = "0.1.0" 82 | source = "registry+https://github.com/rust-lang/crates.io-index" 83 | checksum = "2de2bc5b451bfedaef92c90b8939a8fff5770bdcc1fafd6239d086aab8fa6b29" 84 | dependencies = [ 85 | "nom", 86 | ] 87 | 88 | [[package]] 89 | name = "proc-macro2" 90 | version = "1.0.94" 91 | source = "registry+https://github.com/rust-lang/crates.io-index" 92 | checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" 93 | dependencies = [ 94 | "unicode-ident", 95 | ] 96 | 97 | [[package]] 98 | name = "quote" 99 | version = "1.0.40" 100 | source = "registry+https://github.com/rust-lang/crates.io-index" 101 | checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" 102 | dependencies = [ 103 | "proc-macro2", 104 | ] 105 | 106 | [[package]] 107 | name = "serde" 108 | version = "1.0.219" 109 | source = "registry+https://github.com/rust-lang/crates.io-index" 110 | checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" 111 | dependencies = [ 112 | "serde_derive", 113 | ] 114 | 115 | [[package]] 116 | name = "serde_derive" 117 | version = "1.0.219" 118 | source = "registry+https://github.com/rust-lang/crates.io-index" 119 | checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" 120 | dependencies = [ 121 | "proc-macro2", 122 | "quote", 123 | "syn", 124 | ] 125 | 126 | [[package]] 127 | name = "serde_spanned" 128 | version = "0.6.8" 129 | source = "registry+https://github.com/rust-lang/crates.io-index" 130 | checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" 131 | dependencies = [ 132 | "serde", 133 | ] 134 | 135 | [[package]] 136 | name = "syn" 137 | version = "2.0.100" 138 | source = "registry+https://github.com/rust-lang/crates.io-index" 139 | checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" 140 | dependencies = [ 141 | "proc-macro2", 142 | "quote", 143 | "unicode-ident", 144 | ] 145 | 146 | [[package]] 147 | name = "toml" 148 | version = "0.8.20" 149 | source = "registry+https://github.com/rust-lang/crates.io-index" 150 | checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148" 151 | dependencies = [ 152 | "serde", 153 | "serde_spanned", 154 | "toml_datetime", 155 | "toml_edit", 156 | ] 157 | 158 | [[package]] 159 | name = "toml_datetime" 160 | version = "0.6.8" 161 | source = "registry+https://github.com/rust-lang/crates.io-index" 162 | checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" 163 | dependencies = [ 164 | "serde", 165 | ] 166 | 167 | [[package]] 168 | name = "toml_edit" 169 | version = "0.22.24" 170 | source = "registry+https://github.com/rust-lang/crates.io-index" 171 | checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" 172 | dependencies = [ 173 | "indexmap", 174 | "serde", 175 | "serde_spanned", 176 | "toml_datetime", 177 | "winnow", 178 | ] 179 | 180 | [[package]] 181 | name = "unicode-ident" 182 | version = "1.0.18" 183 | source = "registry+https://github.com/rust-lang/crates.io-index" 184 | checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" 185 | 186 | [[package]] 187 | name = "winnow" 188 | version = "0.7.4" 189 | source = "registry+https://github.com/rust-lang/crates.io-index" 190 | checksum = "0e97b544156e9bebe1a0ffbc03484fc1ffe3100cbce3ffb17eac35f7cdd7ab36" 191 | dependencies = [ 192 | "memchr", 193 | ] 194 | 195 | [[package]] 196 | name = "xml-rs" 197 | version = "0.8.25" 198 | source = "registry+https://github.com/rust-lang/crates.io-index" 199 | checksum = "c5b940ebc25896e71dd073bad2dbaa2abfe97b0a391415e22ad1326d9c54e3c4" 200 | 201 | [[package]] 202 | name = "xmltree" 203 | version = "0.11.0" 204 | source = "registry+https://github.com/rust-lang/crates.io-index" 205 | checksum = "b619f8c85654798007fb10afa5125590b43b088c225a25fc2fec100a9fad0fc6" 206 | dependencies = [ 207 | "xml-rs", 208 | ] 209 | -------------------------------------------------------------------------------- /codegen/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "codegen" 3 | version = "0.0.1" 4 | license = "MIT/Apache-2.0" 5 | edition = "2018" 6 | publish = false 7 | 8 | [dependencies] 9 | anyhow = "1" 10 | fn-error-context = "0.2" 11 | heck = "0.5" 12 | nom = "8" 13 | nom-language = "0.1" 14 | serde = { version = "1", features = ["derive"] } 15 | toml = "0.8" 16 | xmltree = "0.11" 17 | -------------------------------------------------------------------------------- /codegen/src/config/mod.rs: -------------------------------------------------------------------------------- 1 | use anyhow::Result; 2 | use fn_error_context::context; 3 | use serde::Deserialize; 4 | use std::collections::{BTreeMap, HashSet}; 5 | use std::fs::File; 6 | use std::io::{BufRead, BufReader}; 7 | use std::path::Path; 8 | 9 | #[derive(Debug, Deserialize)] 10 | pub(crate) struct CodegenConfig { 11 | #[serde(rename = "service")] 12 | pub(crate) services: BTreeMap, 13 | } 14 | 15 | impl CodegenConfig { 16 | pub(crate) fn parse_toml(input: &mut impl BufRead) -> Result { 17 | let mut content = String::new(); 18 | input.read_to_string(&mut content)?; 19 | let cfg: CodegenConfig = toml::from_str(&content)?; 20 | Ok(cfg) 21 | } 22 | 23 | pub(crate) fn get_service_by_id(&self, id: &str) -> Option<&Service> { 24 | self.services.values().find(|s| s.id == id) 25 | } 26 | } 27 | 28 | #[derive(Debug, Deserialize, PartialEq, Eq, PartialOrd, Ord)] 29 | pub(crate) struct Service { 30 | pub(crate) default_object: Option, 31 | pub(crate) hierarchy: String, 32 | pub(crate) id: String, 33 | pub(crate) module: String, 34 | pub(crate) overrides: Option>, 35 | } 36 | 37 | impl Service { 38 | pub(crate) fn method_overrides(&self) -> HashSet<(String, String)> { 39 | let mut out = HashSet::new(); 40 | if let Some(overrides) = &self.overrides { 41 | for service in overrides { 42 | if let Some(todo) = &service.todo_methods { 43 | for name in todo { 44 | out.insert((service.interface.to_string(), name.to_string())); 45 | } 46 | } 47 | } 48 | } 49 | out 50 | } 51 | 52 | pub(crate) fn property_overrides(&self) -> HashSet<(String, String)> { 53 | let mut out = HashSet::new(); 54 | if let Some(overrides) = &self.overrides { 55 | for service in overrides { 56 | if let Some(todo) = &service.todo_properties { 57 | for name in todo { 58 | out.insert((service.interface.to_string(), name.to_string())); 59 | } 60 | } 61 | } 62 | } 63 | out 64 | } 65 | } 66 | 67 | #[derive(Debug, Deserialize, PartialEq, Eq, PartialOrd, Ord)] 68 | pub(crate) struct ServiceOverride { 69 | pub(crate) interface: String, 70 | pub(crate) todo_methods: Option>, 71 | pub(crate) todo_signals: Option>, 72 | pub(crate) todo_properties: Option>, 73 | } 74 | 75 | #[context("Parsing configuration file {}", path.as_ref().display())] 76 | pub(crate) fn parse_toml_config(path: impl AsRef) -> Result { 77 | let tomlfile = File::open("./codegen.toml")?; 78 | let mut bufrd = BufReader::new(tomlfile); 79 | CodegenConfig::parse_toml(&mut bufrd) 80 | } 81 | -------------------------------------------------------------------------------- /codegen/src/generator/mod.rs: -------------------------------------------------------------------------------- 1 | mod ztypes; 2 | 3 | use crate::config::Service; 4 | use crate::parser::data::{self, Node}; 5 | use anyhow::{format_err, Context, Result}; 6 | use heck::ToSnakeCase; 7 | use std::collections::HashSet; 8 | use std::io::Write; 9 | 10 | pub(crate) fn generate(output: &mut impl Write, nodes: Vec, service: &Service) -> Result<()> { 11 | writeln!( 12 | output, 13 | "// This file is autogenerated, do not manually edit.", 14 | )?; 15 | writeln!(output, "\n")?; 16 | 17 | if !nodes.is_empty() { 18 | writeln!(output, "use crate::zbus::proxy;")?; 19 | writeln!(output, "\n")?; 20 | 21 | for object in nodes { 22 | let iface = object.interface.clone(); 23 | generate_single_object(output, object, service) 24 | .with_context(|| format!("Generating interface '{}'", iface))?; 25 | } 26 | } 27 | 28 | Ok(()) 29 | } 30 | 31 | fn generate_single_object(file: &mut impl Write, node: Node, service: &Service) -> Result<()> { 32 | writeln!(file, "/// Proxy object for `{}`.", node.interface)?; 33 | 34 | writeln!(file, "#[proxy(")?; 35 | { 36 | writeln!(file, r#"interface = "{}","#, node.interface)?; 37 | writeln!(file, r#"gen_blocking = false,"#)?; 38 | writeln!(file, r#"default_service = "{}","#, service.id)?; 39 | if node.path == service.hierarchy { 40 | writeln!(file, r#"default_path = "{}","#, service.hierarchy)?; 41 | } else { 42 | writeln!(file, "assume_defaults = false,")?; 43 | } 44 | } 45 | writeln!(file, ")]")?; 46 | 47 | let struct_name = node.struct_name(service); 48 | writeln!(file, "pub trait {} {{", struct_name,)?; 49 | 50 | if !node.methods.is_empty() { 51 | let overrides = service.method_overrides(); 52 | emit_methods(file, &node.interface, node.methods, overrides)?; 53 | } 54 | 55 | if !node.signals.is_empty() { 56 | emit_signals(file, &node.signals)?; 57 | } 58 | 59 | if !node.properties.is_empty() { 60 | let overrides = service.property_overrides(); 61 | emit_properties(file, &node.interface, node.properties, overrides)?; 62 | } 63 | 64 | writeln!(file, "}}")?; 65 | writeln!(file)?; 66 | 67 | Ok(()) 68 | } 69 | 70 | fn emit_methods( 71 | output: &mut impl Write, 72 | iface: &str, 73 | methods: Vec, 74 | overrides: HashSet<(String, String)>, 75 | ) -> Result<()> { 76 | for method in methods { 77 | if overrides.contains(&(iface.to_string(), method.name.clone())) { 78 | continue; 79 | } 80 | 81 | let directive_link = format!( 82 | "https://www.freedesktop.org/software/systemd/man/systemd.directives.html#{}()", 83 | method.name 84 | ); 85 | 86 | let mut inputs = Vec::with_capacity(method.inputs.len()); 87 | for arg in &method.inputs { 88 | let rtype = ztypes::translate_sig(&arg.1).with_context(|| { 89 | format_err!( 90 | "Failed to generate method '{}' due to unhandled input argument", 91 | &method.name, 92 | ) 93 | })?; 94 | 95 | inputs.push((arg.0.clone(), rtype)); 96 | } 97 | 98 | let translated_sig = translate_sig_output(&method.outputs).with_context(|| { 99 | format_err!( 100 | "Failed to generate method '{}' due to unhandled output argument", 101 | method.name 102 | ) 103 | })?; 104 | 105 | writeln!( 106 | output, 107 | "/// [📖]({}) Call interface method `{}`.", 108 | directive_link, method.name, 109 | )?; 110 | let fn_name = match method.name.as_str() { 111 | "Ref" => "reference".to_string(), 112 | x => x.to_snake_case(), 113 | }; 114 | writeln!(output, r#"#[zbus(name = "{}")]"#, method.name)?; 115 | writeln!(output, "fn {}(&self,", fn_name)?; 116 | for arg in inputs { 117 | let mangled_name = match arg.0.as_str() { 118 | "type" => "typelabel", 119 | x => x, 120 | }; 121 | writeln!(output, " {}: {},", mangled_name, arg.1)?; 122 | } 123 | writeln!(output, ") ")?; 124 | writeln!(output, "-> crate::zbus::Result<{}>;", translated_sig)?; 125 | writeln!(output)?; 126 | } 127 | 128 | Ok(()) 129 | } 130 | 131 | fn emit_signals(output: &mut impl Write, signals: &[data::Signal]) -> Result<()> { 132 | for entry in signals { 133 | let mut args = Vec::with_capacity(entry.args.len()); 134 | for (sig, name) in &entry.args { 135 | let rtype = ztypes::translate_sig(sig).with_context(|| { 136 | format_err!( 137 | "Failed to generate signal '{}' due to unhandled argument", 138 | entry.name, 139 | ) 140 | })?; 141 | args.push((name, rtype)); 142 | } 143 | 144 | let fn_name = entry.name.to_snake_case(); 145 | writeln!(output, "/// Receive `{}` signal.", entry.name)?; 146 | writeln!(output, r#"#[zbus(signal, name = "{}")]"#, entry.name)?; 147 | writeln!(output, "fn {}(&self,", fn_name,)?; 148 | for (name, rtype) in args { 149 | let mangled_name = match name.as_str() { 150 | "type" => "typelabel", 151 | x => x, 152 | }; 153 | writeln!(output, " {}: {},", mangled_name, rtype)?; 154 | } 155 | writeln!(output, ") -> crate::zbus::Result<()>;")?; 156 | writeln!(output)?; 157 | } 158 | Ok(()) 159 | } 160 | 161 | fn emit_properties( 162 | output: &mut impl Write, 163 | iface: &str, 164 | props: Vec, 165 | overrides: HashSet<(String, String)>, 166 | ) -> Result<()> { 167 | for entry in props { 168 | if overrides.contains(&(iface.to_string(), entry.name.clone())) { 169 | continue; 170 | } 171 | 172 | let fn_name = match entry.name.as_str() { 173 | "Where" | "Type" => { 174 | format!("{}_property", entry.name.to_snake_case()) 175 | } 176 | x => x.to_snake_case(), 177 | }; 178 | let decoded_type = ztypes::translate_sig(&entry.type_label).with_context(|| { 179 | format_err!( 180 | "Failed to generate property '{}' due to unhandled arguments", 181 | entry.name, 182 | ) 183 | })?; 184 | 185 | writeln!(output, "/// Get property `{}`.", entry.name)?; 186 | writeln!( 187 | output, 188 | r#"#[zbus(property(emits_changed_signal = "{}"), name = "{}")]"#, 189 | entry.emits_changed_signal, entry.name, 190 | )?; 191 | writeln!( 192 | output, 193 | "fn {}(&self) -> crate::zbus::Result<{}>;", 194 | fn_name, decoded_type, 195 | )?; 196 | writeln!(output)?; 197 | 198 | if entry.writable { 199 | // NOTE(lucab): `set_property_` prefix is ugly, but a shorter `set_` 200 | // prefix unfortunately will result in a conflict on `SetWallMessage` 201 | // method. 202 | writeln!(output, "/// Set property `{}`.", entry.name)?; 203 | writeln!(output, r#"#[zbus(property, name = "{}")]"#, entry.name)?; 204 | writeln!( 205 | output, 206 | "fn set_property_{}(&self, new_value: {}) -> crate::zbus::Result<()>;", 207 | entry.name.to_snake_case(), 208 | decoded_type, 209 | )?; 210 | writeln!(output)?; 211 | } 212 | } 213 | Ok(()) 214 | } 215 | 216 | fn translate_sig_output(outputs: &Vec<(String, String)>) -> Result { 217 | if outputs.is_empty() { 218 | return Ok("()".to_string()); 219 | } 220 | 221 | if outputs.len() == 1 { 222 | return ztypes::translate_sig(&outputs[0].1); 223 | } 224 | 225 | let mut res = String::new(); 226 | for arg in outputs { 227 | if !res.is_empty() { 228 | res.push_str(", "); 229 | } 230 | let rtype = ztypes::translate_sig(&arg.1)?; 231 | res.push_str(&rtype); 232 | } 233 | Ok(format!("({})", res)) 234 | } 235 | -------------------------------------------------------------------------------- /codegen/src/generator/ztypes.rs: -------------------------------------------------------------------------------- 1 | /// This module implements translating DBus data types to Rust. More details can be found at: 2 | /// https://dbus.freedesktop.org/doc/dbus-specification.html 3 | use anyhow::Result; 4 | use fn_error_context::context; 5 | use nom::{ 6 | branch::alt, 7 | bytes::complete::tag, 8 | combinator::{map, value}, 9 | multi::many1, 10 | sequence::{delimited, pair, preceded}, 11 | Finish, IResult, Parser, 12 | }; 13 | 14 | #[context("Translating DBus type '{}'", sig)] 15 | pub fn translate_sig(sig: &str) -> Result { 16 | if sig.is_empty() { 17 | return Ok("".to_string()); 18 | } 19 | 20 | let (_, result) = parse_type(sig) 21 | .map_err(|e| e.map_input(|input| input.to_string())) 22 | .finish()?; 23 | Ok(result) 24 | } 25 | 26 | fn parse_type(input: &str) -> IResult<&str, String> { 27 | alt((parse_simple, parse_tuple, parse_dictionary, parse_array)).parse(input) 28 | } 29 | 30 | fn parse_simple(input: &str) -> IResult<&str, String> { 31 | map( 32 | alt(( 33 | value("bool", tag("b")), 34 | value("f64", tag("d")), 35 | value("crate::zvariant::OwnedFd", tag("h")), 36 | value("i32", tag("i")), 37 | value("crate::zvariant::OwnedObjectPath", tag("o")), 38 | value("u16", tag("q")), 39 | value("String", tag("s")), 40 | value("u64", tag("t")), 41 | value("u32", tag("u")), 42 | value("crate::zvariant::OwnedValue", tag("v")), 43 | value("i64", tag("x")), 44 | value("u8", tag("y")), 45 | )), 46 | |out| out.to_string(), 47 | ) 48 | .parse(input) 49 | } 50 | 51 | fn parse_tuple(input: &str) -> IResult<&str, String> { 52 | map(delimited(tag("("), many1(parse_type), tag(")")), |t| { 53 | format!("({},)", t.join(", ")) 54 | }) 55 | .parse(input) 56 | } 57 | 58 | fn parse_dictionary(input: &str) -> IResult<&str, String> { 59 | map( 60 | delimited(tag("a{"), pair(parse_type, parse_type), tag("}")), 61 | |(key, value)| format!("::std::collections::HashMap<{}, {}>", key, value), 62 | ) 63 | .parse(input) 64 | } 65 | 66 | fn parse_array(input: &str) -> IResult<&str, String> { 67 | map(preceded(tag("a"), parse_type), |t| format!("Vec<{}>", t)).parse(input) 68 | } 69 | 70 | #[cfg(test)] 71 | mod tests { 72 | use super::*; 73 | 74 | #[test] 75 | fn test_translate_sig() { 76 | let ok_cases = &[ 77 | ("", ""), 78 | ("a{ss}", "::std::collections::HashMap"), 79 | ("b", "bool"), 80 | ("a(iiayqs)", "Vec<(i32, i32, Vec, u16, String,)>"), 81 | ( 82 | "a(sa(sv))", 83 | "Vec<(String, Vec<(String, crate::zvariant::OwnedValue,)>,)>", 84 | ), 85 | ]; 86 | for (input, expected) in ok_cases { 87 | let output = translate_sig(input).expect(&format!("test case {}", input)); 88 | assert_eq!(&output, expected, "test case {}", input); 89 | } 90 | } 91 | 92 | #[test] 93 | fn test_translate_array_plain() { 94 | let ok_cases = &[("ab", "Vec")]; 95 | for (input, expected) in ok_cases { 96 | let output = translate_sig(input).unwrap(); 97 | assert_eq!(&output, expected); 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /codegen/src/main.rs: -------------------------------------------------------------------------------- 1 | mod config; 2 | mod generator; 3 | mod parser; 4 | 5 | use anyhow::{Context, Result}; 6 | use std::fs::File; 7 | use std::io::BufReader; 8 | 9 | fn run() -> Result<()> { 10 | let cfg = config::parse_toml_config("./codegen.toml")?; 11 | 12 | let systemd_man_dir = 13 | std::fs::read_dir("./codegen/systemd/man").context("Listing systemd manpages")?; 14 | 15 | println!("Processing modules:"); 16 | for entry in systemd_man_dir { 17 | let entry = entry?; 18 | if !entry.file_type()?.is_file() { 19 | continue; 20 | } 21 | 22 | let service_cfg = { 23 | let fname = entry.file_name().to_string_lossy().into_owned(); 24 | let service_id = fname.trim_end_matches(".xml"); 25 | match cfg.get_service_by_id(service_id) { 26 | Some(v) => v, 27 | None => continue, 28 | } 29 | }; 30 | println!(" * {}", service_cfg.module); 31 | 32 | let mut xml_input = { 33 | let fd = File::open(entry.path()) 34 | .with_context(|| format!("Opening {}", entry.path().display()))?; 35 | BufReader::new(fd) 36 | }; 37 | let nodes = parser::parse_docxml(&mut xml_input, service_cfg) 38 | .with_context(|| format!("Parsing XML for '{}'", service_cfg.module))?; 39 | 40 | let mut rust_output = File::create(format!("./src/{}/generated.rs", service_cfg.module))?; 41 | generator::generate(&mut rust_output, nodes, &service_cfg) 42 | .with_context(|| format!("Analyzing '{}'", entry.path().display()))?; 43 | } 44 | 45 | Ok(()) 46 | } 47 | 48 | fn main() { 49 | if let Err(e) = run() { 50 | eprintln!("Error:"); 51 | for entry in e.chain() { 52 | eprintln!(" - {}", entry); 53 | } 54 | std::process::exit(1); 55 | }; 56 | } 57 | -------------------------------------------------------------------------------- /codegen/src/parser/data.rs: -------------------------------------------------------------------------------- 1 | use crate::config::Service; 2 | 3 | #[derive(Debug)] 4 | pub(crate) struct Node { 5 | pub(crate) object_name: String, 6 | pub(crate) path: String, 7 | pub(crate) interface: String, 8 | pub(crate) methods: Vec, 9 | pub(crate) signals: Vec, 10 | pub(crate) properties: Vec, 11 | } 12 | 13 | impl Node { 14 | pub(crate) fn struct_name(&self, service: &Service) -> String { 15 | if !self.object_name.is_empty() { 16 | self.object_name.clone() 17 | } else { 18 | service 19 | .default_object 20 | .clone() 21 | .unwrap_or_else(|| "Service".to_string()) 22 | } 23 | } 24 | } 25 | 26 | #[derive(Debug)] 27 | pub(crate) struct Method { 28 | pub(crate) name: String, 29 | pub(crate) inputs: Vec<(String, String)>, 30 | pub(crate) outputs: Vec<(String, String)>, 31 | } 32 | 33 | #[derive(Debug)] 34 | pub(crate) struct Property { 35 | pub(crate) name: String, 36 | pub(crate) type_label: String, 37 | pub(crate) writable: bool, 38 | pub(crate) emits_changed_signal: String, 39 | } 40 | 41 | #[derive(Debug)] 42 | pub(crate) struct Signal { 43 | pub(crate) name: String, 44 | pub(crate) args: Vec<(String, String)>, 45 | } 46 | -------------------------------------------------------------------------------- /codegen/src/parser/interface.rs: -------------------------------------------------------------------------------- 1 | use super::{data, methods, properties, signals}; 2 | use nom::branch::alt; 3 | use nom::bytes::complete::{tag, take, take_till, take_until}; 4 | use nom::character::complete::{char, multispace0, multispace1}; 5 | use nom::combinator::eof; 6 | use nom::sequence::delimited; 7 | use nom::FindSubstring; 8 | use nom::Parser; 9 | use nom_language::error::VerboseError; 10 | 11 | /// Parse a single interface and return its name and methods/properties/signals. 12 | pub(crate) fn parse_single_interface( 13 | rest: &str, 14 | ) -> nom::IResult< 15 | &str, 16 | ( 17 | &str, 18 | Vec, 19 | Vec, 20 | Vec, 21 | ), 22 | VerboseError<&str>, 23 | > { 24 | let (rest, iface_name) = interface_start(rest)?; 25 | 26 | let (rest, methods, signals, properties) = { 27 | let (rest, content) = take_until("};")(rest)?; 28 | let (_, out) = alt((parse_dummy_content, parse_interface_content)).parse(content)?; 29 | (rest, out.0, out.1, out.2) 30 | }; 31 | 32 | let (rest, _) = interface_end(rest)?; 33 | 34 | Ok((rest, (iface_name, methods, signals, properties))) 35 | } 36 | 37 | /// Match interface block start, and return its name. 38 | fn interface_start(rest: &str) -> nom::IResult<&str, &str, VerboseError<&str>> { 39 | let mut parser = ( 40 | multispace0, 41 | tag("interface"), 42 | multispace1, 43 | take_till(|b: char| b.is_ascii_whitespace()), 44 | multispace0, 45 | char('{'), 46 | multispace0, 47 | ); 48 | let (rest, out) = parser.parse(rest)?; 49 | Ok((rest, out.3)) 50 | } 51 | 52 | /// Match interface block end. 53 | fn interface_end(text: &str) -> nom::IResult<&str, (), VerboseError<&str>> { 54 | let (rest, _) = (char('}'), char(';'), multispace0).parse(text)?; 55 | Ok((rest, ())) 56 | } 57 | 58 | /// Parse a dummy interface block (`[ ... ]`). 59 | fn parse_dummy_content( 60 | rest: &str, 61 | ) -> nom::IResult< 62 | &str, 63 | (Vec, Vec, Vec), 64 | VerboseError<&str>, 65 | > { 66 | let (rest, _) = delimited(multispace0, tag("..."), multispace0).parse(rest)?; 67 | let out = (vec![], vec![], vec![]); 68 | Ok((rest, out)) 69 | } 70 | /// Parse interface content. 71 | /// 72 | /// Content blocks are ordered as: 73 | /// 1. methods (optional) 74 | /// 2. signals (optional) 75 | /// 3. properties (optional) 76 | fn parse_interface_content( 77 | text: &str, 78 | ) -> nom::IResult< 79 | &str, 80 | (Vec, Vec, Vec), 81 | VerboseError<&str>, 82 | > { 83 | let block_end = text.len(); 84 | let mut rest = text; 85 | 86 | // Properties slice. 87 | let props_start = text.find_substring("properties:"); 88 | let props_end = block_end; 89 | // Signals slice. 90 | let sigs_start = text.find_substring("signals:"); 91 | let sigs_end = props_start.unwrap_or(block_end); 92 | // Methods slice. 93 | let methods_start = text.find_substring("methods:"); 94 | let methods_end = sigs_start 95 | .unwrap_or(block_end) 96 | .min(props_start.unwrap_or(block_end)); 97 | 98 | // Parse 'methods:' section, if present. 99 | let mut methods = vec![]; 100 | if let Some(start) = methods_start { 101 | let count = methods_end.saturating_sub(start); 102 | let out = take(count)(rest)?; 103 | rest = out.0; 104 | let (_, parsed) = methods::parse_interface_methods(out.1)?; 105 | methods = parsed; 106 | } 107 | 108 | // Parse 'signals:' section, if present. 109 | let mut signals = vec![]; 110 | if let Some(start) = sigs_start { 111 | let count = sigs_end.saturating_sub(start); 112 | let out = take(count)(rest)?; 113 | rest = out.0; 114 | let (_, parsed) = signals::parse_interface_signals(out.1)?; 115 | signals = parsed; 116 | } 117 | 118 | // Parse 'properties:' section, if present. 119 | let mut properties = vec![]; 120 | if let Some(start) = props_start { 121 | let count = props_end.saturating_sub(start); 122 | let out = take(count)(rest)?; 123 | rest = out.0; 124 | let (_, parsed) = properties::parse_interface_properties(out.1)?; 125 | properties = parsed; 126 | } 127 | 128 | // Ensure all the content has been parsed. 129 | eof(rest)?; 130 | 131 | Ok((rest, (methods, signals, properties))) 132 | } 133 | 134 | #[cfg(test)] 135 | mod tests { 136 | use super::*; 137 | 138 | #[test] 139 | fn test_interface_content_dummy() { 140 | let input = " ... "; 141 | let (rest, out) = parse_dummy_content(input).unwrap(); 142 | assert_eq!(rest, ""); 143 | assert!(out.0.is_empty()); 144 | assert!(out.1.is_empty()); 145 | assert!(out.2.is_empty()); 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /codegen/src/parser/methods.rs: -------------------------------------------------------------------------------- 1 | use super::data; 2 | use nom::branch::alt; 3 | use nom::bytes::complete::{tag, take, take_till, take_while}; 4 | use nom::character::complete::{multispace0, multispace1}; 5 | use nom::combinator::eof; 6 | use nom::multi::{separated_list0, separated_list1}; 7 | use nom::sequence::delimited; 8 | use nom::Parser; 9 | use nom_language::error::VerboseError; 10 | 11 | // Parse the 'methods:' section of an interface. 12 | pub(crate) fn parse_interface_methods( 13 | input: &str, 14 | ) -> nom::IResult<&str, Vec, VerboseError<&str>> { 15 | // Ensure this is a 'methods' section. 16 | let (rest, _) = delimited(multispace0, tag("methods:"), multispace0).parse(input)?; 17 | 18 | // Split method blocks apart. 19 | let (rest, blocks) = separated_list1(tag(";"), take_till(|b| b == ';')).parse(rest)?; 20 | eof(rest)?; 21 | 22 | let mut methods = Vec::with_capacity(blocks.len()); 23 | for entry in blocks { 24 | let trimmed = entry.trim(); 25 | if trimmed.is_empty() { 26 | continue; 27 | } 28 | 29 | let (empty, m) = parse_single_method(trimmed)?; 30 | eof(empty)?; 31 | 32 | methods.push(m); 33 | } 34 | methods.shrink_to_fit(); 35 | 36 | Ok((rest, methods)) 37 | } 38 | 39 | // Parse a single method. 40 | fn parse_single_method(input: &str) -> nom::IResult<&str, data::Method, VerboseError<&str>> { 41 | let mut rest = input; 42 | 43 | // Handle annotations. 44 | let mut annotations = vec![]; 45 | while rest.starts_with('@') { 46 | let (next, annotation) = take_while(|b| b != '\n')(rest)?; 47 | annotations.push(annotation); 48 | rest = next.trim(); 49 | } 50 | 51 | // Extract method name. 52 | let (rest, method_name) = take_while(|b| b != '(')(rest)?; 53 | 54 | // Extract arguments list. 55 | let (rest, _) = tag("(")(rest)?; 56 | let (rest, args_body) = take(rest.len().saturating_sub(1))(rest)?; 57 | let (rest, _) = tag(")")(rest)?; 58 | 59 | // Parse arguments. 60 | let (_, args) = interface_method_args(args_body)?; 61 | 62 | let mut method = data::Method { 63 | name: method_name.to_string(), 64 | inputs: Vec::with_capacity(args.len()), 65 | outputs: Vec::with_capacity(args.len()), 66 | }; 67 | for entry in args { 68 | let arg_name = entry.2.to_string(); 69 | let signature = entry.1.to_string(); 70 | match entry.0 { 71 | "in" => method.inputs.push((arg_name, signature)), 72 | "out" => method.outputs.push((arg_name, signature)), 73 | x => unreachable!("{}", x), 74 | }; 75 | } 76 | method.inputs.shrink_to_fit(); 77 | method.outputs.shrink_to_fit(); 78 | 79 | Ok((rest, method)) 80 | } 81 | 82 | fn interface_method_args( 83 | text: &str, 84 | ) -> nom::IResult<&str, Vec<(&str, &str, &str)>, VerboseError<&str>> { 85 | let (rest, out) = separated_list0(tag(","), take_till(|b| b == ',')).parse(text)?; 86 | eof(rest)?; 87 | 88 | let mut result = Vec::with_capacity(out.len()); 89 | for line in out { 90 | let trimmed = line.trim(); 91 | if trimmed.is_empty() { 92 | continue; 93 | } 94 | 95 | let (_, arg) = ( 96 | multispace0, 97 | alt((tag("in"), tag("out"))), 98 | multispace1, 99 | take_till(|b: char| b.is_ascii_whitespace()), 100 | multispace1, 101 | take_while(|_| true), 102 | ) 103 | .parse(line)?; 104 | let entry = (arg.1, arg.3, arg.5); 105 | result.push(entry); 106 | } 107 | result.shrink_to_fit(); 108 | 109 | Ok((rest, result)) 110 | } 111 | -------------------------------------------------------------------------------- /codegen/src/parser/mod.rs: -------------------------------------------------------------------------------- 1 | pub(crate) mod data; 2 | mod interface; 3 | mod methods; 4 | mod node; 5 | mod properties; 6 | mod signals; 7 | mod xml; 8 | 9 | pub(crate) use xml::parse_docxml; 10 | -------------------------------------------------------------------------------- /codegen/src/parser/node.rs: -------------------------------------------------------------------------------- 1 | use super::data; 2 | use super::interface::parse_single_interface; 3 | use crate::config::Service; 4 | use nom::bytes::complete::{tag, take_till}; 5 | use nom::character::complete::{char, multispace0, multispace1}; 6 | use nom::combinator::eof; 7 | use nom::multi::many1; 8 | use nom::Parser; 9 | use nom_language::error::VerboseError; 10 | 11 | pub(crate) fn parse_single_node<'a>( 12 | text: &'a str, 13 | service: &Service, 14 | ) -> nom::IResult<&'a str, data::Node, VerboseError<&'a str>> { 15 | let (path, interfaces) = { 16 | let mut parser = (node_start, many1(parse_single_interface), node_end, eof); 17 | let (_, out) = parser.parse(text)?; 18 | (out.0, out.1) 19 | }; 20 | 21 | for entry in interfaces { 22 | let (iface_name, methods, signals, properties) = entry; 23 | let object_name = iface_name 24 | .trim_start_matches(&service.id) 25 | .trim_start_matches('.') 26 | .to_string(); 27 | let node = data::Node { 28 | object_name, 29 | path: path.to_string(), 30 | interface: iface_name.to_string(), 31 | methods, 32 | signals, 33 | properties, 34 | }; 35 | return Ok(("", node)); 36 | } 37 | 38 | unreachable!("failed to parse node"); 39 | } 40 | 41 | /// Match node start and return its name. 42 | fn node_start(text: &str) -> nom::IResult<&str, &str, VerboseError<&str>> { 43 | let (rest, out) = ( 44 | multispace0, 45 | tag("node"), 46 | multispace1, 47 | take_till(|b: char| b.is_ascii_whitespace()), 48 | multispace0, 49 | char('{'), 50 | multispace0, 51 | ) 52 | .parse(text)?; 53 | Ok((rest, out.3)) 54 | } 55 | 56 | fn node_end(text: &str) -> nom::IResult<&str, (), VerboseError<&str>> { 57 | let (rest, _) = (multispace0, char('}'), multispace0, char(';'), multispace0).parse(text)?; 58 | Ok((rest, ())) 59 | } 60 | 61 | #[cfg(test)] 62 | mod tests { 63 | use super::*; 64 | 65 | #[test] 66 | fn test_node_start() { 67 | let input = " node foo { \n"; 68 | let (rest, out) = node_start(input).unwrap(); 69 | assert_eq!(rest, ""); 70 | assert_eq!(out, "foo"); 71 | } 72 | 73 | #[test] 74 | fn test_node() { 75 | let input = " node foo { \n"; 76 | let (rest, out) = node_start(input).unwrap(); 77 | assert_eq!(rest, ""); 78 | assert_eq!(out, "foo"); 79 | } 80 | 81 | #[test] 82 | fn test_node_end() { 83 | let input = " \n } ; \n"; 84 | let (rest, out) = node_end(input).unwrap(); 85 | assert_eq!(rest, ""); 86 | assert_eq!(out, ()); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /codegen/src/parser/properties.rs: -------------------------------------------------------------------------------- 1 | use super::data; 2 | use nom::branch::alt; 3 | use nom::bytes::complete::{tag, take_till, take_while}; 4 | use nom::character::complete::{multispace0, multispace1}; 5 | use nom::combinator::eof; 6 | use nom::multi::separated_list1; 7 | use nom::sequence::delimited; 8 | use nom::Parser; 9 | use nom_language::error::VerboseError; 10 | 11 | /// Parse the 'properties:' section of an interface. 12 | pub(crate) fn parse_interface_properties( 13 | input: &str, 14 | ) -> nom::IResult<&str, Vec, VerboseError<&str>> { 15 | let rest = input; 16 | // Ensure this is a 'properties:' section. 17 | let (rest, _) = delimited(multispace0, tag("properties:"), multispace0).parse(rest)?; 18 | 19 | // Split each property apart. 20 | let (rest, props) = separated_list1(tag(";"), take_till(|b| b == ';')).parse(rest)?; 21 | eof(rest)?; 22 | 23 | let mut properties = Vec::with_capacity(props.len()); 24 | for entry in props { 25 | let trimmed = entry.trim(); 26 | if trimmed.is_empty() { 27 | continue; 28 | } 29 | let (empty, prop) = parse_single_property(trimmed)?; 30 | eof(empty)?; 31 | 32 | properties.push(prop); 33 | } 34 | properties.shrink_to_fit(); 35 | Ok((rest, properties)) 36 | } 37 | 38 | /// Parse a single property. 39 | fn parse_single_property(input: &str) -> nom::IResult<&str, data::Property, VerboseError<&str>> { 40 | // Parse line-by-line in reverse order, as all the annotations are leading. 41 | let mut rev_lines = input.lines().rev(); 42 | let property_def = rev_lines.next().unwrap(); 43 | 44 | let (empty, mut prop) = parse_property_definition(property_def)?; 45 | eof(empty)?; 46 | 47 | // This logic only understands a very limited set of annotations that 48 | // appear in systemd docs. 49 | for annotation in rev_lines { 50 | let rest = annotation; 51 | let (rest, _) = multispace0(rest)?; 52 | if rest.starts_with("@org.freedesktop.systemd1.Privileged") { 53 | continue; 54 | } 55 | let (rest, _) = tag("@org.freedesktop.DBus.Property.EmitsChangedSignal")(rest)?; 56 | let (rest, _) = tag("(\"")(rest)?; 57 | let (rest, value) = 58 | alt((tag("const"), tag("false"), tag("invalidates"), tag("true"))).parse(rest)?; 59 | let (rest, _) = tag("\")")(rest)?; 60 | eof(rest)?; 61 | 62 | prop.emits_changed_signal = value.to_string(); 63 | } 64 | 65 | Ok(("", prop)) 66 | } 67 | 68 | /// Parse a property definition. 69 | fn parse_property_definition( 70 | input: &str, 71 | ) -> nom::IResult<&str, data::Property, VerboseError<&str>> { 72 | let rest = input; 73 | let (rest, _) = multispace0(rest)?; 74 | let (rest, rw_label) = alt((tag("readonly"), tag("readwrite"))).parse(rest)?; 75 | let (rest, _) = multispace1(rest)?; 76 | let (rest, type_label) = take_till(|b: char| b.is_ascii_whitespace())(rest)?; 77 | let (rest, _) = multispace1(rest)?; 78 | let (rest, name) = take_till(|b: char| b.is_ascii_whitespace())(rest)?; 79 | let (rest, _) = multispace1(rest)?; 80 | let (rest, _) = (take_while(|_| true))(rest)?; 81 | eof(rest)?; 82 | 83 | let writable = match rw_label { 84 | "readonly" => false, 85 | "readwrite" => true, 86 | _ => unreachable!(), 87 | }; 88 | 89 | const DEFAULT_CHANGED_SIGNAL: &str = "true"; 90 | let out_prop = data::Property { 91 | type_label: type_label.to_string(), 92 | name: name.to_string(), 93 | writable, 94 | emits_changed_signal: DEFAULT_CHANGED_SIGNAL.to_string(), 95 | }; 96 | Ok((rest, out_prop)) 97 | } 98 | 99 | #[cfg(test)] 100 | mod tests { 101 | use super::*; 102 | use nom::Finish; 103 | use nom_language::error::convert_error; 104 | 105 | #[test] 106 | fn test_parse_property_definition() { 107 | let input = "readonly a(iiay) DNS = [...];"; 108 | let (rest, out) = parse_property_definition(input) 109 | .finish() 110 | .map_err(|e| panic!("{}", convert_error(input, e))) 111 | .unwrap(); 112 | assert_eq!(rest, ""); 113 | assert_eq!(out.type_label, "a(iiay)"); 114 | assert_eq!(out.name, "DNS"); 115 | assert_eq!(out.writable, false); 116 | assert_eq!(out.emits_changed_signal, "true"); 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /codegen/src/parser/signals.rs: -------------------------------------------------------------------------------- 1 | use super::data; 2 | use nom::bytes::complete::{tag, take, take_till, take_while}; 3 | use nom::character::complete::{multispace0, multispace1}; 4 | use nom::combinator::eof; 5 | use nom::multi::{separated_list0, separated_list1}; 6 | use nom::sequence::delimited; 7 | use nom::Parser; 8 | use nom_language::error::VerboseError; 9 | 10 | // Parse the 'signal:' section of an interface. 11 | pub(crate) fn parse_interface_signals( 12 | input: &str, 13 | ) -> nom::IResult<&str, Vec, VerboseError<&str>> { 14 | // Ensure this is a 'signals' section. 15 | let (rest, _) = delimited(multispace0, tag("signals:"), multispace0).parse(input)?; 16 | 17 | // Split each signal apart. 18 | let (rest, out) = separated_list1(tag(";"), take_till(|b| b == ';')).parse(rest)?; 19 | eof(rest)?; 20 | 21 | let mut signals = Vec::with_capacity(out.len()); 22 | for line in out { 23 | let trimmed = line.trim(); 24 | if trimmed.is_empty() { 25 | continue; 26 | } 27 | let (empty, s) = parse_single_signal(trimmed)?; 28 | eof(empty)?; 29 | 30 | signals.push(s); 31 | } 32 | signals.shrink_to_fit(); 33 | 34 | Ok((rest, signals)) 35 | } 36 | 37 | // Parse a single signal. 38 | fn parse_single_signal(rest: &str) -> nom::IResult<&str, data::Signal, VerboseError<&str>> { 39 | // Extract signal name. 40 | let (rest, signal_name) = take_while(|b| b != '(')(rest)?; 41 | 42 | // Extract arguments list. 43 | let (rest, _) = tag("(")(rest)?; 44 | let (rest, args_body) = take(rest.len().saturating_sub(1))(rest)?; 45 | let (rest, _) = tag(")")(rest)?; 46 | 47 | // Parse arguments. 48 | let (empty, args) = parse_signal_args(args_body)?; 49 | eof(empty)?; 50 | 51 | let signal = data::Signal { 52 | name: signal_name.to_string(), 53 | args, 54 | }; 55 | 56 | Ok((rest, signal)) 57 | } 58 | 59 | // Parse signal arguments. 60 | fn parse_signal_args(input: &str) -> nom::IResult<&str, Vec<(String, String)>, VerboseError<&str>> { 61 | let (rest, out) = separated_list0(tag(","), take_till(|b| b == ',')).parse(input)?; 62 | eof(rest)?; 63 | 64 | let mut result = Vec::with_capacity(out.len()); 65 | for line in out { 66 | let trimmed = line.trim(); 67 | if trimmed.is_empty() { 68 | continue; 69 | } 70 | 71 | let (empty, arg) = ( 72 | multispace0, 73 | take_till(|b: char| b.is_ascii_whitespace()), 74 | multispace1, 75 | take_while(|_| true), 76 | ) 77 | .parse(line)?; 78 | eof(empty)?; 79 | 80 | let entry = (arg.1.to_string(), arg.3.to_string()); 81 | result.push(entry); 82 | } 83 | result.shrink_to_fit(); 84 | 85 | Ok((rest, result)) 86 | } 87 | -------------------------------------------------------------------------------- /codegen/src/parser/xml.rs: -------------------------------------------------------------------------------- 1 | use super::{data, node}; 2 | use crate::config; 3 | use anyhow::{bail, format_err, Context, Result}; 4 | use nom::Finish; 5 | use nom_language::error::convert_error; 6 | use std::io::BufRead; 7 | 8 | /// Parse the XML docs for systemd DBus services. 9 | pub(crate) fn parse_docxml( 10 | input: &mut impl BufRead, 11 | service: &config::Service, 12 | ) -> Result> { 13 | let root = xmltree::Element::parse(input).context("failed to parse XML")?; 14 | 15 | let mut nodes = vec![]; 16 | for node in &root.children { 17 | let section = match node.as_element().filter(|elem| elem.name == "refsect1") { 18 | Some(sect) => sect, 19 | None => continue, 20 | }; 21 | 22 | for entry in §ion.children { 23 | let elem = entry 24 | .as_element() 25 | .filter(|elem| elem.name == "programlisting") 26 | //.filter(|elem| elem.attributes.get("node") == Some(&service.hierarchy)) 27 | ; 28 | let (text, _name) = match elem { 29 | Some(v) => ( 30 | v.get_text().unwrap_or_default(), 31 | v.attributes.get("interface").cloned().unwrap_or_default(), 32 | ), 33 | None => continue, 34 | }; 35 | 36 | let parsed = parse_dbus_block(&text, service)?; 37 | nodes.push(parsed); 38 | } 39 | } 40 | 41 | if nodes.is_empty() { 42 | bail!("no DBus definitions found") 43 | } 44 | 45 | Ok(nodes) 46 | } 47 | 48 | /// Parse a DBus text block into a node. 49 | fn parse_dbus_block(text: &str, service: &config::Service) -> Result { 50 | let (rest, node) = node::parse_single_node(text, service) 51 | .finish() 52 | .map_err(|e| { 53 | format_err!( 54 | "failed to parse DBus description, parsing error:\n{}", 55 | convert_error(text, e) 56 | ) 57 | })?; 58 | 59 | if !rest.is_empty() { 60 | bail!("unparsed trailing data: {}", rest); 61 | } 62 | 63 | Ok(node) 64 | } 65 | -------------------------------------------------------------------------------- /examples/login1-session_lock-unlock.rs: -------------------------------------------------------------------------------- 1 | use zbus_systemd::login1::{ManagerProxy, SessionProxy}; 2 | 3 | type ExResult = Result>; 4 | 5 | fn main() { 6 | let rt = tokio::runtime::Runtime::new().unwrap(); 7 | let ret = rt.block_on(run()); 8 | if let Err(e) = ret { 9 | eprintln!("Error: {}", e); 10 | std::process::exit(1); 11 | } 12 | } 13 | 14 | async fn run() -> ExResult<()> { 15 | let session_id = "4"; 16 | let conn = zbus::Connection::system().await?; 17 | 18 | let session_obj_path = { 19 | let manager = ManagerProxy::new(&conn).await?; 20 | manager.get_session(session_id.to_string()).await? 21 | }; 22 | println!("Session object path: {}", session_obj_path.as_str()); 23 | 24 | let session = SessionProxy::builder(&conn) 25 | .path(session_obj_path)? 26 | .build() 27 | .await?; 28 | 29 | session.lock().await?; 30 | println!("Locked"); 31 | 32 | session.unlock().await?; 33 | println!("Unlocked"); 34 | 35 | Ok(()) 36 | } 37 | -------------------------------------------------------------------------------- /examples/login1-wall_message.rs: -------------------------------------------------------------------------------- 1 | type ExResult = Result>; 2 | 3 | fn main() { 4 | let rt = tokio::runtime::Runtime::new().unwrap(); 5 | let ret = rt.block_on(run()); 6 | if let Err(e) = ret { 7 | eprintln!("Error: {}", e); 8 | std::process::exit(1); 9 | } 10 | } 11 | 12 | async fn run() -> ExResult<()> { 13 | println!("!!! NOTE: This example requires root privileges to run."); 14 | 15 | let conn = zbus::Connection::system().await?; 16 | let manager = zbus_systemd::login1::ManagerProxy::new(&conn).await?; 17 | 18 | let is_enabled = manager.enable_wall_messages().await?; 19 | let status = if is_enabled { "enabled" } else { "disabled" }; 20 | println!("Shutdown wall messages are currently {status}."); 21 | if is_enabled { 22 | let msg = manager.wall_message().await?; 23 | println!(" -> Current shutdown message: '{msg}'"); 24 | } 25 | 26 | if !is_enabled { 27 | manager.set_property_enable_wall_messages(true).await?; 28 | println!("Enabled shutdown wall messages"); 29 | } 30 | 31 | let msg = "Hello from Rust!".to_string(); 32 | manager.set_property_wall_message(msg.clone()).await?; 33 | println!("Updated shutdown message."); 34 | println!(" -> New shutdown message: '{msg}'"); 35 | 36 | Ok(()) 37 | } 38 | -------------------------------------------------------------------------------- /examples/systemd1-get_default_target.rs: -------------------------------------------------------------------------------- 1 | type ExResult = Result>; 2 | 3 | fn main() { 4 | let rt = tokio::runtime::Runtime::new().unwrap(); 5 | let ret = rt.block_on(run()); 6 | if let Err(e) = ret { 7 | eprintln!("Error: {}", e); 8 | std::process::exit(1); 9 | } 10 | } 11 | 12 | async fn run() -> ExResult<()> { 13 | let conn = zbus::Connection::system().await?; 14 | let manager = zbus_systemd::systemd1::ManagerProxy::new(&conn).await?; 15 | let target = manager.get_default_target().await?; 16 | println!("Default target: '{}'", target); 17 | Ok(()) 18 | } 19 | -------------------------------------------------------------------------------- /examples/timedate1-list_timezones.rs: -------------------------------------------------------------------------------- 1 | type ExResult = Result>; 2 | 3 | fn main() { 4 | let rt = tokio::runtime::Runtime::new().unwrap(); 5 | let ret = rt.block_on(run()); 6 | if let Err(e) = ret { 7 | eprintln!("{}", e); 8 | std::process::exit(1); 9 | } 10 | } 11 | 12 | async fn run() -> ExResult<()> { 13 | let conn = zbus::Connection::system().await?; 14 | let timedated = zbus_systemd::timedate1::TimedatedProxy::new(&conn).await?; 15 | let timezones = timedated.list_timezones().await?; 16 | if timezones.len() > 0 { 17 | println!("Timezones:"); 18 | for tz in &timezones { 19 | println!(" - {}", tz); 20 | } 21 | } 22 | println!("Total timezones: {}", timezones.len()); 23 | Ok(()) 24 | } 25 | -------------------------------------------------------------------------------- /justfile: -------------------------------------------------------------------------------- 1 | @default: bump-systemd generate fmt check 2 | 3 | check: 4 | cargo check --all-features 5 | 6 | doc: 7 | cargo doc --all-features 8 | 9 | fmt: 10 | cargo fmt 11 | 12 | generate: 13 | cargo run --manifest-path ./codegen/Cargo.toml --locked 14 | 15 | current_sd_tag := 'v257' 16 | bump-systemd sd_tag=current_sd_tag: 17 | #!/usr/bin/env bash 18 | set -euo pipefail 19 | echo "Updating git-module 'codegen/systemd' to '{{sd_tag}}'." 20 | git submodule update --init -- codegen/systemd 21 | cd codegen/systemd 22 | git fetch -q origin tag "{{sd_tag}}" 23 | git checkout "{{sd_tag}}" 24 | -------------------------------------------------------------------------------- /src/helpers.rs: -------------------------------------------------------------------------------- 1 | //! This module contains helpers translated from `systemd` for working with D-Bus object paths. 2 | //! They are re-exported from the crate root. 3 | 4 | use std::borrow::Cow; 5 | use std::fmt::Write; 6 | use zbus::zvariant::{ObjectPath, OwnedObjectPath}; 7 | 8 | /// Escape a label for use in a D-Bus object path. 9 | /// 10 | /// Based on `bus_label_escape` from `systemd`. 11 | pub fn bus_label_escape(s: &str) -> Cow<'_, str> { 12 | if s.is_empty() { 13 | return Cow::Borrowed("_"); 14 | } 15 | 16 | fn needs_encoding(i: usize, c: u8) -> bool { 17 | !(c.is_ascii_alphabetic() || i > 0 && c.is_ascii_digit()) 18 | } 19 | 20 | let need_encoding_count = s 21 | .bytes() 22 | .enumerate() 23 | .filter(|(i, c)| needs_encoding(*i, *c)) 24 | .count(); 25 | if need_encoding_count == 0 { 26 | return Cow::Borrowed(s); 27 | } 28 | 29 | let mut r = String::with_capacity(s.len() + need_encoding_count * 2); 30 | for (i, c) in s.bytes().enumerate() { 31 | if needs_encoding(i, c) { 32 | _ = write!(&mut r, "_{:02x}", c); 33 | } else { 34 | r.push(c as char); 35 | } 36 | } 37 | 38 | Cow::Owned(r) 39 | } 40 | 41 | /// Unescape a label from a D-Bus object path. 42 | /// 43 | /// Based on `bus_label_unescape` from `systemd`. 44 | pub fn bus_label_unescape(f: &str) -> Cow<'_, str> { 45 | if !f.contains('_') { 46 | return Cow::Borrowed(f); 47 | } 48 | 49 | if f == "_" { 50 | return Cow::Borrowed(""); 51 | } 52 | 53 | let mut r = String::with_capacity(f.len()); 54 | let mut chars = f.chars(); 55 | while let Some(c) = chars.next() { 56 | if c == '_' { 57 | let a = chars.next().and_then(|c| c.to_digit(16)); 58 | let b = chars.next().and_then(|c| c.to_digit(16)); 59 | match (a, b) { 60 | (Some(a), Some(b)) => r.push(((a * 16 + b) as u8) as char), 61 | // Invalid escape sequence 62 | _ => r.push('_'), 63 | } 64 | } else { 65 | r.push(c); 66 | } 67 | } 68 | 69 | Cow::Owned(r) 70 | } 71 | 72 | /// Convert an external identifier into an object path. 73 | /// 74 | /// Based on `sd_bus_path_encode` from `systemd`. 75 | pub fn bus_path_encode(prefix: &ObjectPath<'_>, external_id: &str) -> OwnedObjectPath { 76 | let label = bus_label_escape(external_id); 77 | ObjectPath::from_string_unchecked(format!("{}/{}", prefix, label)).into() 78 | } 79 | 80 | /// Convert an object path into an external identifier. 81 | /// 82 | /// Returns `None` if the path is not a child of the prefix. 83 | /// 84 | /// Based on `sd_bus_path_decode` from `systemd`. 85 | pub fn bus_path_decode<'a>( 86 | prefix: &ObjectPath<'_>, 87 | path: &'a ObjectPath<'a>, 88 | ) -> Option> { 89 | let path = path.as_str(); 90 | let label = path.strip_prefix(prefix.as_str())?; 91 | let label = label.strip_prefix('/')?; 92 | Some(bus_label_unescape(label)) 93 | } 94 | 95 | /// Escape a unit name 96 | /// 97 | /// Based on `unit_name_escape` from `systemd`. 98 | pub fn unit_name_escape(input: &str) -> Cow<'_, str> { 99 | const VALID_CHARS: &str = r"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:_."; 100 | 101 | if !input.starts_with('.') && input.chars().all(|c| VALID_CHARS.contains(c)) { 102 | return Cow::Borrowed(input); 103 | } 104 | 105 | let mut result = String::with_capacity(input.len()); 106 | 107 | let escape_char = |c: char, result: &mut String| { 108 | result.push('\\'); 109 | result.push('x'); 110 | _ = write!(result, "{:02x}", c as u8); 111 | }; 112 | 113 | let mut chars = input.chars().peekable(); 114 | 115 | // Handle leading '.' separately 116 | if let Some(c) = chars.next_if_eq(&'.') { 117 | escape_char(c, &mut result); 118 | } 119 | 120 | for c in chars { 121 | match c { 122 | '/' => result.push('-'), 123 | c if VALID_CHARS.contains(c) => result.push(c), 124 | c => escape_char(c, &mut result), 125 | } 126 | } 127 | 128 | Cow::Owned(result) 129 | } 130 | 131 | /// Unescape a unit name 132 | /// 133 | /// Based on `unit_name_unescape` from `systemd`. 134 | pub fn unit_name_unescape(f: &str) -> Option> { 135 | if f.chars().all(|c| c != '\\' && c != '-') { 136 | return Some(Cow::Borrowed(f)); 137 | } 138 | 139 | let mut result = String::with_capacity(f.len()); 140 | let mut chars = f.chars(); 141 | while let Some(c) = chars.next() { 142 | match c { 143 | '-' => result.push('/'), 144 | '\\' => { 145 | if chars.next() != Some('x') { 146 | return None; 147 | } 148 | let a = chars.next().and_then(|c| c.to_digit(16))?; 149 | let b = chars.next().and_then(|c| c.to_digit(16))?; 150 | result.push(((a << 4) | b) as u8 as char); 151 | } 152 | _ => result.push(c), 153 | } 154 | } 155 | 156 | Some(Cow::Owned(result)) 157 | } 158 | 159 | #[cfg(test)] 160 | mod test { 161 | use super::*; 162 | 163 | #[test] 164 | fn test_bus_label_escape() { 165 | assert_eq!(bus_label_escape("1"), "_31"); 166 | assert_eq!(bus_label_escape("hello"), "hello"); 167 | assert_eq!(bus_label_escape(""), "_"); 168 | } 169 | 170 | #[test] 171 | fn test_bus_label_unescape() { 172 | assert_eq!(bus_label_unescape("_31"), "1"); 173 | assert_eq!(bus_label_unescape("_3"), "_"); 174 | assert_eq!(bus_label_unescape("hello"), "hello"); 175 | assert_eq!(bus_label_unescape("_"), ""); 176 | } 177 | 178 | const EXAMPLE_NAMESPACE: ObjectPath<'static> = 179 | ObjectPath::from_static_str_unchecked("/org/freedesktop/network1/link"); 180 | 181 | #[test] 182 | fn test_bus_path_encode() { 183 | assert_eq!( 184 | bus_path_encode(&EXAMPLE_NAMESPACE, "1"), 185 | OwnedObjectPath::from(ObjectPath::from_static_str_unchecked( 186 | "/org/freedesktop/network1/link/_31" 187 | )) 188 | ); 189 | assert_eq!( 190 | bus_path_encode(&EXAMPLE_NAMESPACE, "huh"), 191 | OwnedObjectPath::from(ObjectPath::from_static_str_unchecked( 192 | "/org/freedesktop/network1/link/huh" 193 | )) 194 | ); 195 | assert_eq!( 196 | bus_path_encode(&EXAMPLE_NAMESPACE, ""), 197 | OwnedObjectPath::from(ObjectPath::from_static_str_unchecked( 198 | "/org/freedesktop/network1/link/_" 199 | )) 200 | ); 201 | } 202 | 203 | #[test] 204 | fn test_bus_path_decode() { 205 | assert_eq!( 206 | bus_path_decode( 207 | &EXAMPLE_NAMESPACE, 208 | &"/org/freedesktop/network1/link/_31".try_into().unwrap(), 209 | ), 210 | Some("1".into()) 211 | ); 212 | assert_eq!( 213 | bus_path_decode( 214 | &EXAMPLE_NAMESPACE, 215 | &"/org/freedesktop/network1/link/huh".try_into().unwrap(), 216 | ), 217 | Some("huh".into()) 218 | ); 219 | assert_eq!( 220 | bus_path_decode( 221 | &EXAMPLE_NAMESPACE, 222 | &"/org/freedesktop/network1/link/_".try_into().unwrap(), 223 | ), 224 | Some("".into()) 225 | ); 226 | } 227 | 228 | #[test] 229 | fn test_unit_name_escape() { 230 | assert_eq!(unit_name_escape(""), Cow::Borrowed("")); 231 | assert_eq!( 232 | unit_name_escape("ab+-c.a/bc@foo.service"), 233 | Cow::<'static, str>::Owned(r"ab\x2b\x2dc.a-bc\x40foo.service".to_string()) 234 | ); 235 | assert_eq!( 236 | unit_name_escape("foo.service"), 237 | Cow::Borrowed("foo.service") 238 | ); 239 | assert_eq!( 240 | unit_name_escape(".foo.service"), 241 | Cow::<'static, str>::Owned(r"\x2efoo.service".to_string()) 242 | ); 243 | } 244 | 245 | #[test] 246 | fn test_unit_name_unescape() { 247 | assert_eq!(unit_name_unescape(""), Some(Cow::Borrowed(""))); 248 | assert_eq!( 249 | unit_name_unescape(r"ab\x2b\x2dc.a-bc\x40foo.service"), 250 | Some(Cow::Owned("ab+-c.a/bc@foo.service".to_string())) 251 | ); 252 | assert_eq!( 253 | unit_name_unescape("foo.service"), 254 | Some(Cow::Borrowed("foo.service")) 255 | ); 256 | assert_eq!( 257 | unit_name_unescape(r"\x2efoo.service"), 258 | Some(Cow::Owned(".foo.service".to_string())) 259 | ); 260 | assert_eq!(unit_name_unescape(r"\x2"), None); 261 | } 262 | } 263 | -------------------------------------------------------------------------------- /src/home1/generated.rs: -------------------------------------------------------------------------------- 1 | // This file is autogenerated, do not manually edit. 2 | 3 | use crate::zbus::proxy; 4 | 5 | /// Proxy object for `org.freedesktop.home1.Manager`. 6 | #[proxy( 7 | interface = "org.freedesktop.home1.Manager", 8 | gen_blocking = false, 9 | default_service = "org.freedesktop.home1", 10 | default_path = "/org/freedesktop/home1" 11 | )] 12 | pub trait Manager { 13 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetHomeByName()) Call interface method `GetHomeByName`. 14 | #[zbus(name = "GetHomeByName")] 15 | fn get_home_by_name( 16 | &self, 17 | user_name: String, 18 | ) -> crate::zbus::Result<( 19 | u32, 20 | String, 21 | u32, 22 | String, 23 | String, 24 | String, 25 | crate::zvariant::OwnedObjectPath, 26 | )>; 27 | 28 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetHomeByUID()) Call interface method `GetHomeByUID`. 29 | #[zbus(name = "GetHomeByUID")] 30 | fn get_home_by_uid( 31 | &self, 32 | uid: u32, 33 | ) -> crate::zbus::Result<( 34 | String, 35 | String, 36 | u32, 37 | String, 38 | String, 39 | String, 40 | crate::zvariant::OwnedObjectPath, 41 | )>; 42 | 43 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetUserRecordByName()) Call interface method `GetUserRecordByName`. 44 | #[zbus(name = "GetUserRecordByName")] 45 | fn get_user_record_by_name( 46 | &self, 47 | user_name: String, 48 | ) -> crate::zbus::Result<(String, bool, crate::zvariant::OwnedObjectPath)>; 49 | 50 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetUserRecordByUID()) Call interface method `GetUserRecordByUID`. 51 | #[zbus(name = "GetUserRecordByUID")] 52 | fn get_user_record_by_uid( 53 | &self, 54 | uid: u32, 55 | ) -> crate::zbus::Result<(String, bool, crate::zvariant::OwnedObjectPath)>; 56 | 57 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ListHomes()) Call interface method `ListHomes`. 58 | #[zbus(name = "ListHomes")] 59 | fn list_homes( 60 | &self, 61 | ) -> crate::zbus::Result< 62 | Vec<( 63 | String, 64 | u32, 65 | String, 66 | u32, 67 | String, 68 | String, 69 | String, 70 | crate::zvariant::OwnedObjectPath, 71 | )>, 72 | >; 73 | 74 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ActivateHome()) Call interface method `ActivateHome`. 75 | #[zbus(name = "ActivateHome")] 76 | fn activate_home(&self, user_name: String, secret: String) -> crate::zbus::Result<()>; 77 | 78 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ActivateHomeIfReferenced()) Call interface method `ActivateHomeIfReferenced`. 79 | #[zbus(name = "ActivateHomeIfReferenced")] 80 | fn activate_home_if_referenced( 81 | &self, 82 | user_name: String, 83 | secret: String, 84 | ) -> crate::zbus::Result<()>; 85 | 86 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#DeactivateHome()) Call interface method `DeactivateHome`. 87 | #[zbus(name = "DeactivateHome")] 88 | fn deactivate_home(&self, user_name: String) -> crate::zbus::Result<()>; 89 | 90 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#RegisterHome()) Call interface method `RegisterHome`. 91 | #[zbus(name = "RegisterHome")] 92 | fn register_home(&self, user_record: String) -> crate::zbus::Result<()>; 93 | 94 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#UnregisterHome()) Call interface method `UnregisterHome`. 95 | #[zbus(name = "UnregisterHome")] 96 | fn unregister_home(&self, user_name: String) -> crate::zbus::Result<()>; 97 | 98 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#CreateHome()) Call interface method `CreateHome`. 99 | #[zbus(name = "CreateHome")] 100 | fn create_home(&self, user_record: String) -> crate::zbus::Result<()>; 101 | 102 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#CreateHomeEx()) Call interface method `CreateHomeEx`. 103 | #[zbus(name = "CreateHomeEx")] 104 | fn create_home_ex( 105 | &self, 106 | user_record: String, 107 | blobs: ::std::collections::HashMap, 108 | flags: u64, 109 | ) -> crate::zbus::Result<()>; 110 | 111 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#RealizeHome()) Call interface method `RealizeHome`. 112 | #[zbus(name = "RealizeHome")] 113 | fn realize_home(&self, user_name: String, secret: String) -> crate::zbus::Result<()>; 114 | 115 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#RemoveHome()) Call interface method `RemoveHome`. 116 | #[zbus(name = "RemoveHome")] 117 | fn remove_home(&self, user_name: String) -> crate::zbus::Result<()>; 118 | 119 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#FixateHome()) Call interface method `FixateHome`. 120 | #[zbus(name = "FixateHome")] 121 | fn fixate_home(&self, user_name: String, secret: String) -> crate::zbus::Result<()>; 122 | 123 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#AuthenticateHome()) Call interface method `AuthenticateHome`. 124 | #[zbus(name = "AuthenticateHome")] 125 | fn authenticate_home(&self, user_name: String, secret: String) -> crate::zbus::Result<()>; 126 | 127 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#UpdateHome()) Call interface method `UpdateHome`. 128 | #[zbus(name = "UpdateHome")] 129 | fn update_home(&self, user_record: String) -> crate::zbus::Result<()>; 130 | 131 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#UpdateHomeEx()) Call interface method `UpdateHomeEx`. 132 | #[zbus(name = "UpdateHomeEx")] 133 | fn update_home_ex( 134 | &self, 135 | user_record: String, 136 | blobs: ::std::collections::HashMap, 137 | flags: u64, 138 | ) -> crate::zbus::Result<()>; 139 | 140 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ResizeHome()) Call interface method `ResizeHome`. 141 | #[zbus(name = "ResizeHome")] 142 | fn resize_home(&self, user_name: String, size: u64, secret: String) -> crate::zbus::Result<()>; 143 | 144 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ChangePasswordHome()) Call interface method `ChangePasswordHome`. 145 | #[zbus(name = "ChangePasswordHome")] 146 | fn change_password_home( 147 | &self, 148 | user_name: String, 149 | new_secret: String, 150 | old_secret: String, 151 | ) -> crate::zbus::Result<()>; 152 | 153 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#LockHome()) Call interface method `LockHome`. 154 | #[zbus(name = "LockHome")] 155 | fn lock_home(&self, user_name: String) -> crate::zbus::Result<()>; 156 | 157 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#UnlockHome()) Call interface method `UnlockHome`. 158 | #[zbus(name = "UnlockHome")] 159 | fn unlock_home(&self, user_name: String, secret: String) -> crate::zbus::Result<()>; 160 | 161 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#AcquireHome()) Call interface method `AcquireHome`. 162 | #[zbus(name = "AcquireHome")] 163 | fn acquire_home( 164 | &self, 165 | user_name: String, 166 | secret: String, 167 | please_suspend: bool, 168 | ) -> crate::zbus::Result; 169 | 170 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#RefHome()) Call interface method `RefHome`. 171 | #[zbus(name = "RefHome")] 172 | fn ref_home( 173 | &self, 174 | user_name: String, 175 | please_suspend: bool, 176 | ) -> crate::zbus::Result; 177 | 178 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#RefHomeUnrestricted()) Call interface method `RefHomeUnrestricted`. 179 | #[zbus(name = "RefHomeUnrestricted")] 180 | fn ref_home_unrestricted( 181 | &self, 182 | user_name: String, 183 | please_suspend: bool, 184 | ) -> crate::zbus::Result; 185 | 186 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ReleaseHome()) Call interface method `ReleaseHome`. 187 | #[zbus(name = "ReleaseHome")] 188 | fn release_home(&self, user_name: String) -> crate::zbus::Result<()>; 189 | 190 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#LockAllHomes()) Call interface method `LockAllHomes`. 191 | #[zbus(name = "LockAllHomes")] 192 | fn lock_all_homes(&self) -> crate::zbus::Result<()>; 193 | 194 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#DeactivateAllHomes()) Call interface method `DeactivateAllHomes`. 195 | #[zbus(name = "DeactivateAllHomes")] 196 | fn deactivate_all_homes(&self) -> crate::zbus::Result<()>; 197 | 198 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Rebalance()) Call interface method `Rebalance`. 199 | #[zbus(name = "Rebalance")] 200 | fn rebalance(&self) -> crate::zbus::Result<()>; 201 | 202 | /// Get property `AutoLogin`. 203 | #[zbus(property(emits_changed_signal = "true"), name = "AutoLogin")] 204 | fn auto_login( 205 | &self, 206 | ) -> crate::zbus::Result>; 207 | } 208 | 209 | /// Proxy object for `org.freedesktop.home1.Home`. 210 | #[proxy( 211 | interface = "org.freedesktop.home1.Home", 212 | gen_blocking = false, 213 | default_service = "org.freedesktop.home1", 214 | assume_defaults = false 215 | )] 216 | pub trait Home { 217 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Activate()) Call interface method `Activate`. 218 | #[zbus(name = "Activate")] 219 | fn activate(&self, secret: String) -> crate::zbus::Result<()>; 220 | 221 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ActivateIfReferenced()) Call interface method `ActivateIfReferenced`. 222 | #[zbus(name = "ActivateIfReferenced")] 223 | fn activate_if_referenced(&self, secret: String) -> crate::zbus::Result<()>; 224 | 225 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Deactivate()) Call interface method `Deactivate`. 226 | #[zbus(name = "Deactivate")] 227 | fn deactivate(&self) -> crate::zbus::Result<()>; 228 | 229 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Unregister()) Call interface method `Unregister`. 230 | #[zbus(name = "Unregister")] 231 | fn unregister(&self) -> crate::zbus::Result<()>; 232 | 233 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Realize()) Call interface method `Realize`. 234 | #[zbus(name = "Realize")] 235 | fn realize(&self, secret: String) -> crate::zbus::Result<()>; 236 | 237 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Remove()) Call interface method `Remove`. 238 | #[zbus(name = "Remove")] 239 | fn remove(&self) -> crate::zbus::Result<()>; 240 | 241 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Fixate()) Call interface method `Fixate`. 242 | #[zbus(name = "Fixate")] 243 | fn fixate(&self, secret: String) -> crate::zbus::Result<()>; 244 | 245 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Authenticate()) Call interface method `Authenticate`. 246 | #[zbus(name = "Authenticate")] 247 | fn authenticate(&self, secret: String) -> crate::zbus::Result<()>; 248 | 249 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Update()) Call interface method `Update`. 250 | #[zbus(name = "Update")] 251 | fn update(&self, user_record: String) -> crate::zbus::Result<()>; 252 | 253 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#UpdateEx()) Call interface method `UpdateEx`. 254 | #[zbus(name = "UpdateEx")] 255 | fn update_ex( 256 | &self, 257 | user_record: String, 258 | blobs: ::std::collections::HashMap, 259 | flags: u64, 260 | ) -> crate::zbus::Result<()>; 261 | 262 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Resize()) Call interface method `Resize`. 263 | #[zbus(name = "Resize")] 264 | fn resize(&self, size: u64, secret: String) -> crate::zbus::Result<()>; 265 | 266 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ChangePassword()) Call interface method `ChangePassword`. 267 | #[zbus(name = "ChangePassword")] 268 | fn change_password(&self, new_secret: String, old_secret: String) -> crate::zbus::Result<()>; 269 | 270 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Lock()) Call interface method `Lock`. 271 | #[zbus(name = "Lock")] 272 | fn lock(&self) -> crate::zbus::Result<()>; 273 | 274 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Unlock()) Call interface method `Unlock`. 275 | #[zbus(name = "Unlock")] 276 | fn unlock(&self, secret: String) -> crate::zbus::Result<()>; 277 | 278 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Acquire()) Call interface method `Acquire`. 279 | #[zbus(name = "Acquire")] 280 | fn acquire( 281 | &self, 282 | secret: String, 283 | please_suspend: bool, 284 | ) -> crate::zbus::Result; 285 | 286 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Ref()) Call interface method `Ref`. 287 | #[zbus(name = "Ref")] 288 | fn reference(&self, please_suspend: bool) -> crate::zbus::Result; 289 | 290 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#RefUnrestricted()) Call interface method `RefUnrestricted`. 291 | #[zbus(name = "RefUnrestricted")] 292 | fn ref_unrestricted( 293 | &self, 294 | please_suspend: bool, 295 | ) -> crate::zbus::Result; 296 | 297 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Release()) Call interface method `Release`. 298 | #[zbus(name = "Release")] 299 | fn release(&self) -> crate::zbus::Result<()>; 300 | 301 | /// Get property `UserName`. 302 | #[zbus(property(emits_changed_signal = "const"), name = "UserName")] 303 | fn user_name(&self) -> crate::zbus::Result; 304 | 305 | /// Get property `UID`. 306 | #[zbus(property(emits_changed_signal = "true"), name = "UID")] 307 | fn uid(&self) -> crate::zbus::Result; 308 | 309 | /// Get property `UnixRecord`. 310 | #[zbus(property(emits_changed_signal = "true"), name = "UnixRecord")] 311 | fn unix_record(&self) -> crate::zbus::Result<(String, u32, u32, String, String, String)>; 312 | 313 | /// Get property `State`. 314 | #[zbus(property(emits_changed_signal = "false"), name = "State")] 315 | fn state(&self) -> crate::zbus::Result; 316 | 317 | /// Get property `UserRecord`. 318 | #[zbus(property(emits_changed_signal = "invalidates"), name = "UserRecord")] 319 | fn user_record(&self) -> crate::zbus::Result<(String, bool)>; 320 | } 321 | -------------------------------------------------------------------------------- /src/home1/mod.rs: -------------------------------------------------------------------------------- 1 | //! D-Bus interface for systemd-homed ([org.freedesktop.home1](https://www.freedesktop.org/software/systemd/man/org.freedesktop.home1.html)). 2 | 3 | mod generated; 4 | pub use generated::*; 5 | -------------------------------------------------------------------------------- /src/hostname1/generated.rs: -------------------------------------------------------------------------------- 1 | // This file is autogenerated, do not manually edit. 2 | 3 | use crate::zbus::proxy; 4 | 5 | /// Proxy object for `org.freedesktop.hostname1`. 6 | #[proxy( 7 | interface = "org.freedesktop.hostname1", 8 | gen_blocking = false, 9 | default_service = "org.freedesktop.hostname1", 10 | default_path = "/org/freedesktop/hostname1" 11 | )] 12 | pub trait Hostnamed { 13 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetHostname()) Call interface method `SetHostname`. 14 | #[zbus(name = "SetHostname")] 15 | fn set_hostname(&self, hostname: String, interactive: bool) -> crate::zbus::Result<()>; 16 | 17 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetStaticHostname()) Call interface method `SetStaticHostname`. 18 | #[zbus(name = "SetStaticHostname")] 19 | fn set_static_hostname(&self, hostname: String, interactive: bool) -> crate::zbus::Result<()>; 20 | 21 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetPrettyHostname()) Call interface method `SetPrettyHostname`. 22 | #[zbus(name = "SetPrettyHostname")] 23 | fn set_pretty_hostname(&self, hostname: String, interactive: bool) -> crate::zbus::Result<()>; 24 | 25 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetIconName()) Call interface method `SetIconName`. 26 | #[zbus(name = "SetIconName")] 27 | fn set_icon_name(&self, icon: String, interactive: bool) -> crate::zbus::Result<()>; 28 | 29 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetChassis()) Call interface method `SetChassis`. 30 | #[zbus(name = "SetChassis")] 31 | fn set_chassis(&self, chassis: String, interactive: bool) -> crate::zbus::Result<()>; 32 | 33 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetDeployment()) Call interface method `SetDeployment`. 34 | #[zbus(name = "SetDeployment")] 35 | fn set_deployment(&self, deployment: String, interactive: bool) -> crate::zbus::Result<()>; 36 | 37 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetLocation()) Call interface method `SetLocation`. 38 | #[zbus(name = "SetLocation")] 39 | fn set_location(&self, location: String, interactive: bool) -> crate::zbus::Result<()>; 40 | 41 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetProductUUID()) Call interface method `GetProductUUID`. 42 | #[zbus(name = "GetProductUUID")] 43 | fn get_product_uuid(&self, interactive: bool) -> crate::zbus::Result>; 44 | 45 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetHardwareSerial()) Call interface method `GetHardwareSerial`. 46 | #[zbus(name = "GetHardwareSerial")] 47 | fn get_hardware_serial(&self) -> crate::zbus::Result; 48 | 49 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Describe()) Call interface method `Describe`. 50 | #[zbus(name = "Describe")] 51 | fn describe(&self) -> crate::zbus::Result; 52 | 53 | /// Get property `Hostname`. 54 | #[zbus(property(emits_changed_signal = "true"), name = "Hostname")] 55 | fn hostname(&self) -> crate::zbus::Result; 56 | 57 | /// Get property `StaticHostname`. 58 | #[zbus(property(emits_changed_signal = "true"), name = "StaticHostname")] 59 | fn static_hostname(&self) -> crate::zbus::Result; 60 | 61 | /// Get property `PrettyHostname`. 62 | #[zbus(property(emits_changed_signal = "true"), name = "PrettyHostname")] 63 | fn pretty_hostname(&self) -> crate::zbus::Result; 64 | 65 | /// Get property `DefaultHostname`. 66 | #[zbus(property(emits_changed_signal = "const"), name = "DefaultHostname")] 67 | fn default_hostname(&self) -> crate::zbus::Result; 68 | 69 | /// Get property `HostnameSource`. 70 | #[zbus(property(emits_changed_signal = "true"), name = "HostnameSource")] 71 | fn hostname_source(&self) -> crate::zbus::Result; 72 | 73 | /// Get property `IconName`. 74 | #[zbus(property(emits_changed_signal = "true"), name = "IconName")] 75 | fn icon_name(&self) -> crate::zbus::Result; 76 | 77 | /// Get property `Chassis`. 78 | #[zbus(property(emits_changed_signal = "true"), name = "Chassis")] 79 | fn chassis(&self) -> crate::zbus::Result; 80 | 81 | /// Get property `Deployment`. 82 | #[zbus(property(emits_changed_signal = "true"), name = "Deployment")] 83 | fn deployment(&self) -> crate::zbus::Result; 84 | 85 | /// Get property `Location`. 86 | #[zbus(property(emits_changed_signal = "true"), name = "Location")] 87 | fn location(&self) -> crate::zbus::Result; 88 | 89 | /// Get property `KernelName`. 90 | #[zbus(property(emits_changed_signal = "const"), name = "KernelName")] 91 | fn kernel_name(&self) -> crate::zbus::Result; 92 | 93 | /// Get property `KernelRelease`. 94 | #[zbus(property(emits_changed_signal = "const"), name = "KernelRelease")] 95 | fn kernel_release(&self) -> crate::zbus::Result; 96 | 97 | /// Get property `KernelVersion`. 98 | #[zbus(property(emits_changed_signal = "const"), name = "KernelVersion")] 99 | fn kernel_version(&self) -> crate::zbus::Result; 100 | 101 | /// Get property `OperatingSystemPrettyName`. 102 | #[zbus( 103 | property(emits_changed_signal = "const"), 104 | name = "OperatingSystemPrettyName" 105 | )] 106 | fn operating_system_pretty_name(&self) -> crate::zbus::Result; 107 | 108 | /// Get property `OperatingSystemCPEName`. 109 | #[zbus( 110 | property(emits_changed_signal = "const"), 111 | name = "OperatingSystemCPEName" 112 | )] 113 | fn operating_system_cpe_name(&self) -> crate::zbus::Result; 114 | 115 | /// Get property `OperatingSystemSupportEnd`. 116 | #[zbus( 117 | property(emits_changed_signal = "const"), 118 | name = "OperatingSystemSupportEnd" 119 | )] 120 | fn operating_system_support_end(&self) -> crate::zbus::Result; 121 | 122 | /// Get property `HomeURL`. 123 | #[zbus(property(emits_changed_signal = "const"), name = "HomeURL")] 124 | fn home_url(&self) -> crate::zbus::Result; 125 | 126 | /// Get property `HardwareVendor`. 127 | #[zbus(property(emits_changed_signal = "const"), name = "HardwareVendor")] 128 | fn hardware_vendor(&self) -> crate::zbus::Result; 129 | 130 | /// Get property `HardwareModel`. 131 | #[zbus(property(emits_changed_signal = "const"), name = "HardwareModel")] 132 | fn hardware_model(&self) -> crate::zbus::Result; 133 | 134 | /// Get property `FirmwareVersion`. 135 | #[zbus(property(emits_changed_signal = "const"), name = "FirmwareVersion")] 136 | fn firmware_version(&self) -> crate::zbus::Result; 137 | 138 | /// Get property `FirmwareVendor`. 139 | #[zbus(property(emits_changed_signal = "const"), name = "FirmwareVendor")] 140 | fn firmware_vendor(&self) -> crate::zbus::Result; 141 | 142 | /// Get property `FirmwareDate`. 143 | #[zbus(property(emits_changed_signal = "const"), name = "FirmwareDate")] 144 | fn firmware_date(&self) -> crate::zbus::Result; 145 | 146 | /// Get property `MachineID`. 147 | #[zbus(property(emits_changed_signal = "const"), name = "MachineID")] 148 | fn machine_id(&self) -> crate::zbus::Result>; 149 | 150 | /// Get property `BootID`. 151 | #[zbus(property(emits_changed_signal = "const"), name = "BootID")] 152 | fn boot_id(&self) -> crate::zbus::Result>; 153 | 154 | /// Get property `VSockCID`. 155 | #[zbus(property(emits_changed_signal = "const"), name = "VSockCID")] 156 | fn v_sock_cid(&self) -> crate::zbus::Result; 157 | } 158 | -------------------------------------------------------------------------------- /src/hostname1/mod.rs: -------------------------------------------------------------------------------- 1 | //! D-Bus interface for systemd-hostnamed ([org.freedesktop.hostname1](https://www.freedesktop.org/software/systemd/man/org.freedesktop.hostname1.html)). 2 | 3 | mod generated; 4 | pub use generated::*; 5 | -------------------------------------------------------------------------------- /src/import1/generated.rs: -------------------------------------------------------------------------------- 1 | // This file is autogenerated, do not manually edit. 2 | 3 | use crate::zbus::proxy; 4 | 5 | /// Proxy object for `org.freedesktop.import1.Manager`. 6 | #[proxy( 7 | interface = "org.freedesktop.import1.Manager", 8 | gen_blocking = false, 9 | default_service = "org.freedesktop.import1", 10 | default_path = "/org/freedesktop/import1" 11 | )] 12 | pub trait Manager { 13 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ImportTar()) Call interface method `ImportTar`. 14 | #[zbus(name = "ImportTar")] 15 | fn import_tar( 16 | &self, 17 | fd: crate::zvariant::OwnedFd, 18 | local_name: String, 19 | force: bool, 20 | read_only: bool, 21 | ) -> crate::zbus::Result<(u32, crate::zvariant::OwnedObjectPath)>; 22 | 23 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ImportTarEx()) Call interface method `ImportTarEx`. 24 | #[zbus(name = "ImportTarEx")] 25 | fn import_tar_ex( 26 | &self, 27 | fd: crate::zvariant::OwnedFd, 28 | local_name: String, 29 | class: String, 30 | flags: u64, 31 | ) -> crate::zbus::Result<(u32, crate::zvariant::OwnedObjectPath)>; 32 | 33 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ImportRaw()) Call interface method `ImportRaw`. 34 | #[zbus(name = "ImportRaw")] 35 | fn import_raw( 36 | &self, 37 | fd: crate::zvariant::OwnedFd, 38 | local_name: String, 39 | force: bool, 40 | read_only: bool, 41 | ) -> crate::zbus::Result<(u32, crate::zvariant::OwnedObjectPath)>; 42 | 43 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ImportRawEx()) Call interface method `ImportRawEx`. 44 | #[zbus(name = "ImportRawEx")] 45 | fn import_raw_ex( 46 | &self, 47 | fd: crate::zvariant::OwnedFd, 48 | local_name: String, 49 | class: String, 50 | flags: u64, 51 | ) -> crate::zbus::Result<(u32, crate::zvariant::OwnedObjectPath)>; 52 | 53 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ImportFileSystem()) Call interface method `ImportFileSystem`. 54 | #[zbus(name = "ImportFileSystem")] 55 | fn import_file_system( 56 | &self, 57 | fd: crate::zvariant::OwnedFd, 58 | local_name: String, 59 | force: bool, 60 | read_only: bool, 61 | ) -> crate::zbus::Result<(u32, crate::zvariant::OwnedObjectPath)>; 62 | 63 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ImportFileSystemEx()) Call interface method `ImportFileSystemEx`. 64 | #[zbus(name = "ImportFileSystemEx")] 65 | fn import_file_system_ex( 66 | &self, 67 | fd: crate::zvariant::OwnedFd, 68 | local_name: String, 69 | class: String, 70 | flags: u64, 71 | ) -> crate::zbus::Result<(u32, crate::zvariant::OwnedObjectPath)>; 72 | 73 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ExportTar()) Call interface method `ExportTar`. 74 | #[zbus(name = "ExportTar")] 75 | fn export_tar( 76 | &self, 77 | local_name: String, 78 | fd: crate::zvariant::OwnedFd, 79 | format: String, 80 | ) -> crate::zbus::Result<(u32, crate::zvariant::OwnedObjectPath)>; 81 | 82 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ExportTarEx()) Call interface method `ExportTarEx`. 83 | #[zbus(name = "ExportTarEx")] 84 | fn export_tar_ex( 85 | &self, 86 | local_name: String, 87 | class: String, 88 | fd: crate::zvariant::OwnedFd, 89 | format: String, 90 | flags: u64, 91 | ) -> crate::zbus::Result<(u32, crate::zvariant::OwnedObjectPath)>; 92 | 93 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ExportRaw()) Call interface method `ExportRaw`. 94 | #[zbus(name = "ExportRaw")] 95 | fn export_raw( 96 | &self, 97 | local_name: String, 98 | fd: crate::zvariant::OwnedFd, 99 | format: String, 100 | ) -> crate::zbus::Result<(u32, crate::zvariant::OwnedObjectPath)>; 101 | 102 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ExportRawEx()) Call interface method `ExportRawEx`. 103 | #[zbus(name = "ExportRawEx")] 104 | fn export_raw_ex( 105 | &self, 106 | local_name: String, 107 | class: String, 108 | fd: crate::zvariant::OwnedFd, 109 | format: String, 110 | flags: u64, 111 | ) -> crate::zbus::Result<(u32, crate::zvariant::OwnedObjectPath)>; 112 | 113 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#PullTar()) Call interface method `PullTar`. 114 | #[zbus(name = "PullTar")] 115 | fn pull_tar( 116 | &self, 117 | url: String, 118 | local_name: String, 119 | verify_mode: String, 120 | force: bool, 121 | ) -> crate::zbus::Result<(u32, crate::zvariant::OwnedObjectPath)>; 122 | 123 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#PullTarEx()) Call interface method `PullTarEx`. 124 | #[zbus(name = "PullTarEx")] 125 | fn pull_tar_ex( 126 | &self, 127 | url: String, 128 | local_name: String, 129 | class: String, 130 | verify_mode: String, 131 | flags: u64, 132 | ) -> crate::zbus::Result<(u32, crate::zvariant::OwnedObjectPath)>; 133 | 134 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#PullRaw()) Call interface method `PullRaw`. 135 | #[zbus(name = "PullRaw")] 136 | fn pull_raw( 137 | &self, 138 | url: String, 139 | local_name: String, 140 | verify_mode: String, 141 | force: bool, 142 | ) -> crate::zbus::Result<(u32, crate::zvariant::OwnedObjectPath)>; 143 | 144 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#PullRawEx()) Call interface method `PullRawEx`. 145 | #[zbus(name = "PullRawEx")] 146 | fn pull_raw_ex( 147 | &self, 148 | url: String, 149 | local_name: String, 150 | class: String, 151 | verify_mode: String, 152 | flags: u64, 153 | ) -> crate::zbus::Result<(u32, crate::zvariant::OwnedObjectPath)>; 154 | 155 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ListTransfers()) Call interface method `ListTransfers`. 156 | #[zbus(name = "ListTransfers")] 157 | fn list_transfers( 158 | &self, 159 | ) -> crate::zbus::Result< 160 | Vec<( 161 | u32, 162 | String, 163 | String, 164 | String, 165 | f64, 166 | crate::zvariant::OwnedObjectPath, 167 | )>, 168 | >; 169 | 170 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ListTransfersEx()) Call interface method `ListTransfersEx`. 171 | #[zbus(name = "ListTransfersEx")] 172 | fn list_transfers_ex( 173 | &self, 174 | class: String, 175 | flags: u64, 176 | ) -> crate::zbus::Result< 177 | Vec<( 178 | u32, 179 | String, 180 | String, 181 | String, 182 | String, 183 | f64, 184 | crate::zvariant::OwnedObjectPath, 185 | )>, 186 | >; 187 | 188 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#CancelTransfer()) Call interface method `CancelTransfer`. 189 | #[zbus(name = "CancelTransfer")] 190 | fn cancel_transfer(&self, transfer_id: u32) -> crate::zbus::Result<()>; 191 | 192 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ListImages()) Call interface method `ListImages`. 193 | #[zbus(name = "ListImages")] 194 | fn list_images( 195 | &self, 196 | class: String, 197 | flags: u64, 198 | ) -> crate::zbus::Result< 199 | Vec<( 200 | String, 201 | String, 202 | String, 203 | String, 204 | bool, 205 | u64, 206 | u64, 207 | u64, 208 | u64, 209 | u64, 210 | u64, 211 | )>, 212 | >; 213 | 214 | /// Receive `TransferNew` signal. 215 | #[zbus(signal, name = "TransferNew")] 216 | fn transfer_new( 217 | &self, 218 | transfer_id: u32, 219 | transfer_path: crate::zvariant::OwnedObjectPath, 220 | ) -> crate::zbus::Result<()>; 221 | 222 | /// Receive `TransferRemoved` signal. 223 | #[zbus(signal, name = "TransferRemoved")] 224 | fn transfer_removed( 225 | &self, 226 | transfer_id: u32, 227 | transfer_path: crate::zvariant::OwnedObjectPath, 228 | result: String, 229 | ) -> crate::zbus::Result<()>; 230 | } 231 | 232 | /// Proxy object for `org.freedesktop.import1.Transfer`. 233 | #[proxy( 234 | interface = "org.freedesktop.import1.Transfer", 235 | gen_blocking = false, 236 | default_service = "org.freedesktop.import1", 237 | assume_defaults = false 238 | )] 239 | pub trait Transfer { 240 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Cancel()) Call interface method `Cancel`. 241 | #[zbus(name = "Cancel")] 242 | fn cancel(&self) -> crate::zbus::Result<()>; 243 | 244 | /// Receive `LogMessage` signal. 245 | #[zbus(signal, name = "LogMessage")] 246 | fn log_message(&self, priority: u32, line: String) -> crate::zbus::Result<()>; 247 | 248 | /// Receive `ProgressUpdate` signal. 249 | #[zbus(signal, name = "ProgressUpdate")] 250 | fn progress_update(&self, progress: f64) -> crate::zbus::Result<()>; 251 | 252 | /// Get property `Id`. 253 | #[zbus(property(emits_changed_signal = "const"), name = "Id")] 254 | fn id(&self) -> crate::zbus::Result; 255 | 256 | /// Get property `Local`. 257 | #[zbus(property(emits_changed_signal = "const"), name = "Local")] 258 | fn local(&self) -> crate::zbus::Result; 259 | 260 | /// Get property `Remote`. 261 | #[zbus(property(emits_changed_signal = "const"), name = "Remote")] 262 | fn remote(&self) -> crate::zbus::Result; 263 | 264 | /// Get property `Type`. 265 | #[zbus(property(emits_changed_signal = "const"), name = "Type")] 266 | fn type_property(&self) -> crate::zbus::Result; 267 | 268 | /// Get property `Verify`. 269 | #[zbus(property(emits_changed_signal = "const"), name = "Verify")] 270 | fn verify(&self) -> crate::zbus::Result; 271 | 272 | /// Get property `Progress`. 273 | #[zbus(property(emits_changed_signal = "false"), name = "Progress")] 274 | fn progress(&self) -> crate::zbus::Result; 275 | } 276 | -------------------------------------------------------------------------------- /src/import1/mod.rs: -------------------------------------------------------------------------------- 1 | //! D-Bus interface for systemd-importd ([org.freedesktop.import1](https://www.freedesktop.org/software/systemd/man/org.freedesktop.import1.html)). 2 | 3 | mod generated; 4 | pub use generated::*; 5 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | //! A pure-Rust library to interact with systemd DBus services. 2 | 3 | #![cfg_attr(docsrs, feature(doc_cfg))] 4 | 5 | mod helpers; 6 | pub use helpers::*; 7 | 8 | pub use zbus; 9 | pub use zbus::names as znames; 10 | pub use zbus::zvariant; 11 | 12 | #[cfg_attr(docsrs, doc(cfg(feature = "home1")))] 13 | #[cfg(feature = "home1")] 14 | pub mod home1; 15 | 16 | #[cfg_attr(docsrs, doc(cfg(feature = "hostname1")))] 17 | #[cfg(feature = "hostname1")] 18 | pub mod hostname1; 19 | 20 | #[cfg_attr(docsrs, doc(cfg(feature = "import1")))] 21 | #[cfg(feature = "import1")] 22 | pub mod import1; 23 | 24 | #[cfg_attr(docsrs, doc(cfg(feature = "locale1")))] 25 | #[cfg(feature = "locale1")] 26 | pub mod locale1; 27 | 28 | #[cfg_attr(docsrs, doc(cfg(feature = "login1")))] 29 | #[cfg(feature = "login1")] 30 | pub mod login1; 31 | 32 | #[cfg_attr(docsrs, doc(cfg(feature = "machine1")))] 33 | #[cfg(feature = "machine1")] 34 | pub mod machine1; 35 | 36 | #[cfg_attr(docsrs, doc(cfg(feature = "network1")))] 37 | #[cfg(feature = "network1")] 38 | pub mod network1; 39 | 40 | #[cfg_attr(docsrs, doc(cfg(feature = "oom1")))] 41 | #[cfg(feature = "oom1")] 42 | pub mod oom1; 43 | 44 | #[cfg_attr(docsrs, doc(cfg(feature = "portable1")))] 45 | #[cfg(feature = "portable1")] 46 | pub mod portable1; 47 | 48 | #[cfg_attr(docsrs, doc(cfg(feature = "resolve1")))] 49 | #[cfg(feature = "resolve1")] 50 | pub mod resolve1; 51 | 52 | #[cfg_attr(docsrs, doc(cfg(feature = "systemd1")))] 53 | #[cfg(feature = "systemd1")] 54 | pub mod systemd1; 55 | 56 | #[cfg_attr(docsrs, doc(cfg(feature = "sysupdate1")))] 57 | #[cfg(feature = "sysupdate1")] 58 | pub mod sysupdate1; 59 | 60 | #[cfg_attr(docsrs, doc(cfg(feature = "timedate1")))] 61 | #[cfg(feature = "timedate1")] 62 | pub mod timedate1; 63 | 64 | #[cfg_attr(docsrs, doc(cfg(feature = "timesync1")))] 65 | #[cfg(feature = "timesync1")] 66 | pub mod timesync1; 67 | -------------------------------------------------------------------------------- /src/locale1/generated.rs: -------------------------------------------------------------------------------- 1 | // This file is autogenerated, do not manually edit. 2 | 3 | use crate::zbus::proxy; 4 | 5 | /// Proxy object for `org.freedesktop.locale1`. 6 | #[proxy( 7 | interface = "org.freedesktop.locale1", 8 | gen_blocking = false, 9 | default_service = "org.freedesktop.locale1", 10 | default_path = "/org/freedesktop/locale1" 11 | )] 12 | pub trait Localed { 13 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetLocale()) Call interface method `SetLocale`. 14 | #[zbus(name = "SetLocale")] 15 | fn set_locale(&self, locale: Vec, interactive: bool) -> crate::zbus::Result<()>; 16 | 17 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetVConsoleKeyboard()) Call interface method `SetVConsoleKeyboard`. 18 | #[zbus(name = "SetVConsoleKeyboard")] 19 | fn set_v_console_keyboard( 20 | &self, 21 | keymap: String, 22 | keymap_toggle: String, 23 | convert: bool, 24 | interactive: bool, 25 | ) -> crate::zbus::Result<()>; 26 | 27 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetX11Keyboard()) Call interface method `SetX11Keyboard`. 28 | #[zbus(name = "SetX11Keyboard")] 29 | fn set_x11_keyboard( 30 | &self, 31 | layout: String, 32 | model: String, 33 | variant: String, 34 | options: String, 35 | convert: bool, 36 | interactive: bool, 37 | ) -> crate::zbus::Result<()>; 38 | 39 | /// Get property `Locale`. 40 | #[zbus(property(emits_changed_signal = "true"), name = "Locale")] 41 | fn locale(&self) -> crate::zbus::Result>; 42 | 43 | /// Get property `X11Layout`. 44 | #[zbus(property(emits_changed_signal = "true"), name = "X11Layout")] 45 | fn x11_layout(&self) -> crate::zbus::Result; 46 | 47 | /// Get property `X11Model`. 48 | #[zbus(property(emits_changed_signal = "true"), name = "X11Model")] 49 | fn x11_model(&self) -> crate::zbus::Result; 50 | 51 | /// Get property `X11Variant`. 52 | #[zbus(property(emits_changed_signal = "true"), name = "X11Variant")] 53 | fn x11_variant(&self) -> crate::zbus::Result; 54 | 55 | /// Get property `X11Options`. 56 | #[zbus(property(emits_changed_signal = "true"), name = "X11Options")] 57 | fn x11_options(&self) -> crate::zbus::Result; 58 | 59 | /// Get property `VConsoleKeymap`. 60 | #[zbus(property(emits_changed_signal = "true"), name = "VConsoleKeymap")] 61 | fn v_console_keymap(&self) -> crate::zbus::Result; 62 | 63 | /// Get property `VConsoleKeymapToggle`. 64 | #[zbus(property(emits_changed_signal = "true"), name = "VConsoleKeymapToggle")] 65 | fn v_console_keymap_toggle(&self) -> crate::zbus::Result; 66 | } 67 | -------------------------------------------------------------------------------- /src/locale1/mod.rs: -------------------------------------------------------------------------------- 1 | //! D-Bus interface for systemd-localed ([org.freedesktop.locale1](https://www.freedesktop.org/software/systemd/man/org.freedesktop.locale1.html)). 2 | 3 | mod generated; 4 | pub use generated::*; 5 | -------------------------------------------------------------------------------- /src/login1/mod.rs: -------------------------------------------------------------------------------- 1 | //! D-Bus interface for systemd-logind ([org.freedesktop.login1](https://www.freedesktop.org/software/systemd/man/org.freedesktop.login1.html)). 2 | 3 | mod generated; 4 | pub use generated::*; 5 | -------------------------------------------------------------------------------- /src/machine1/generated.rs: -------------------------------------------------------------------------------- 1 | // This file is autogenerated, do not manually edit. 2 | 3 | use crate::zbus::proxy; 4 | 5 | /// Proxy object for `org.freedesktop.machine1.Manager`. 6 | #[proxy( 7 | interface = "org.freedesktop.machine1.Manager", 8 | gen_blocking = false, 9 | default_service = "org.freedesktop.machine1", 10 | default_path = "/org/freedesktop/machine1" 11 | )] 12 | pub trait Manager { 13 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetMachine()) Call interface method `GetMachine`. 14 | #[zbus(name = "GetMachine")] 15 | fn get_machine(&self, name: String) -> crate::zbus::Result; 16 | 17 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetImage()) Call interface method `GetImage`. 18 | #[zbus(name = "GetImage")] 19 | fn get_image(&self, name: String) -> crate::zbus::Result; 20 | 21 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetMachineByPID()) Call interface method `GetMachineByPID`. 22 | #[zbus(name = "GetMachineByPID")] 23 | fn get_machine_by_pid(&self, pid: u32) 24 | -> crate::zbus::Result; 25 | 26 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ListMachines()) Call interface method `ListMachines`. 27 | #[zbus(name = "ListMachines")] 28 | fn list_machines( 29 | &self, 30 | ) -> crate::zbus::Result>; 31 | 32 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ListImages()) Call interface method `ListImages`. 33 | #[zbus(name = "ListImages")] 34 | fn list_images( 35 | &self, 36 | ) -> crate::zbus::Result< 37 | Vec<( 38 | String, 39 | String, 40 | bool, 41 | u64, 42 | u64, 43 | u64, 44 | crate::zvariant::OwnedObjectPath, 45 | )>, 46 | >; 47 | 48 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#CreateMachine()) Call interface method `CreateMachine`. 49 | #[zbus(name = "CreateMachine")] 50 | fn create_machine( 51 | &self, 52 | name: String, 53 | id: Vec, 54 | service: String, 55 | class: String, 56 | leader: u32, 57 | root_directory: String, 58 | scope_properties: Vec<(String, crate::zvariant::OwnedValue)>, 59 | ) -> crate::zbus::Result; 60 | 61 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#CreateMachineWithNetwork()) Call interface method `CreateMachineWithNetwork`. 62 | #[zbus(name = "CreateMachineWithNetwork")] 63 | fn create_machine_with_network( 64 | &self, 65 | name: String, 66 | id: Vec, 67 | service: String, 68 | class: String, 69 | leader: u32, 70 | root_directory: String, 71 | ifindices: Vec, 72 | scope_properties: Vec<(String, crate::zvariant::OwnedValue)>, 73 | ) -> crate::zbus::Result; 74 | 75 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#RegisterMachine()) Call interface method `RegisterMachine`. 76 | #[zbus(name = "RegisterMachine")] 77 | fn register_machine( 78 | &self, 79 | name: String, 80 | id: Vec, 81 | service: String, 82 | class: String, 83 | leader: u32, 84 | root_directory: String, 85 | ) -> crate::zbus::Result; 86 | 87 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#RegisterMachineWithNetwork()) Call interface method `RegisterMachineWithNetwork`. 88 | #[zbus(name = "RegisterMachineWithNetwork")] 89 | fn register_machine_with_network( 90 | &self, 91 | name: String, 92 | id: Vec, 93 | service: String, 94 | class: String, 95 | leader: u32, 96 | root_directory: String, 97 | ifindices: Vec, 98 | ) -> crate::zbus::Result; 99 | 100 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#UnregisterMachine()) Call interface method `UnregisterMachine`. 101 | #[zbus(name = "UnregisterMachine")] 102 | fn unregister_machine(&self, name: String) -> crate::zbus::Result<()>; 103 | 104 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#TerminateMachine()) Call interface method `TerminateMachine`. 105 | #[zbus(name = "TerminateMachine")] 106 | fn terminate_machine(&self, id: String) -> crate::zbus::Result<()>; 107 | 108 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#KillMachine()) Call interface method `KillMachine`. 109 | #[zbus(name = "KillMachine")] 110 | fn kill_machine(&self, name: String, whom: String, signal: i32) -> crate::zbus::Result<()>; 111 | 112 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetMachineAddresses()) Call interface method `GetMachineAddresses`. 113 | #[zbus(name = "GetMachineAddresses")] 114 | fn get_machine_addresses(&self, name: String) -> crate::zbus::Result)>>; 115 | 116 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetMachineSSHInfo()) Call interface method `GetMachineSSHInfo`. 117 | #[zbus(name = "GetMachineSSHInfo")] 118 | fn get_machine_ssh_info(&self, name: String) -> crate::zbus::Result<(String, String)>; 119 | 120 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetMachineOSRelease()) Call interface method `GetMachineOSRelease`. 121 | #[zbus(name = "GetMachineOSRelease")] 122 | fn get_machine_os_release( 123 | &self, 124 | name: String, 125 | ) -> crate::zbus::Result<::std::collections::HashMap>; 126 | 127 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#OpenMachinePTY()) Call interface method `OpenMachinePTY`. 128 | #[zbus(name = "OpenMachinePTY")] 129 | fn open_machine_pty( 130 | &self, 131 | name: String, 132 | ) -> crate::zbus::Result<(crate::zvariant::OwnedFd, String)>; 133 | 134 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#OpenMachineLogin()) Call interface method `OpenMachineLogin`. 135 | #[zbus(name = "OpenMachineLogin")] 136 | fn open_machine_login( 137 | &self, 138 | name: String, 139 | ) -> crate::zbus::Result<(crate::zvariant::OwnedFd, String)>; 140 | 141 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#OpenMachineShell()) Call interface method `OpenMachineShell`. 142 | #[zbus(name = "OpenMachineShell")] 143 | fn open_machine_shell( 144 | &self, 145 | name: String, 146 | user: String, 147 | path: String, 148 | args: Vec, 149 | environment: Vec, 150 | ) -> crate::zbus::Result<(crate::zvariant::OwnedFd, String)>; 151 | 152 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#BindMountMachine()) Call interface method `BindMountMachine`. 153 | #[zbus(name = "BindMountMachine")] 154 | fn bind_mount_machine( 155 | &self, 156 | name: String, 157 | source: String, 158 | destination: String, 159 | read_only: bool, 160 | mkdir: bool, 161 | ) -> crate::zbus::Result<()>; 162 | 163 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#CopyFromMachine()) Call interface method `CopyFromMachine`. 164 | #[zbus(name = "CopyFromMachine")] 165 | fn copy_from_machine( 166 | &self, 167 | name: String, 168 | source: String, 169 | destination: String, 170 | ) -> crate::zbus::Result<()>; 171 | 172 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#CopyToMachine()) Call interface method `CopyToMachine`. 173 | #[zbus(name = "CopyToMachine")] 174 | fn copy_to_machine( 175 | &self, 176 | name: String, 177 | source: String, 178 | destination: String, 179 | ) -> crate::zbus::Result<()>; 180 | 181 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#CopyFromMachineWithFlags()) Call interface method `CopyFromMachineWithFlags`. 182 | #[zbus(name = "CopyFromMachineWithFlags")] 183 | fn copy_from_machine_with_flags( 184 | &self, 185 | name: String, 186 | source: String, 187 | destination: String, 188 | flags: u64, 189 | ) -> crate::zbus::Result<()>; 190 | 191 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#CopyToMachineWithFlags()) Call interface method `CopyToMachineWithFlags`. 192 | #[zbus(name = "CopyToMachineWithFlags")] 193 | fn copy_to_machine_with_flags( 194 | &self, 195 | name: String, 196 | source: String, 197 | destination: String, 198 | flags: u64, 199 | ) -> crate::zbus::Result<()>; 200 | 201 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#OpenMachineRootDirectory()) Call interface method `OpenMachineRootDirectory`. 202 | #[zbus(name = "OpenMachineRootDirectory")] 203 | fn open_machine_root_directory( 204 | &self, 205 | name: String, 206 | ) -> crate::zbus::Result; 207 | 208 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetMachineUIDShift()) Call interface method `GetMachineUIDShift`. 209 | #[zbus(name = "GetMachineUIDShift")] 210 | fn get_machine_uid_shift(&self, name: String) -> crate::zbus::Result; 211 | 212 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#RemoveImage()) Call interface method `RemoveImage`. 213 | #[zbus(name = "RemoveImage")] 214 | fn remove_image(&self, name: String) -> crate::zbus::Result<()>; 215 | 216 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#RenameImage()) Call interface method `RenameImage`. 217 | #[zbus(name = "RenameImage")] 218 | fn rename_image(&self, name: String, new_name: String) -> crate::zbus::Result<()>; 219 | 220 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#CloneImage()) Call interface method `CloneImage`. 221 | #[zbus(name = "CloneImage")] 222 | fn clone_image( 223 | &self, 224 | name: String, 225 | new_name: String, 226 | read_only: bool, 227 | ) -> crate::zbus::Result<()>; 228 | 229 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#MarkImageReadOnly()) Call interface method `MarkImageReadOnly`. 230 | #[zbus(name = "MarkImageReadOnly")] 231 | fn mark_image_read_only(&self, name: String, read_only: bool) -> crate::zbus::Result<()>; 232 | 233 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetImageHostname()) Call interface method `GetImageHostname`. 234 | #[zbus(name = "GetImageHostname")] 235 | fn get_image_hostname(&self, name: String) -> crate::zbus::Result; 236 | 237 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetImageMachineID()) Call interface method `GetImageMachineID`. 238 | #[zbus(name = "GetImageMachineID")] 239 | fn get_image_machine_id(&self, name: String) -> crate::zbus::Result>; 240 | 241 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetImageMachineInfo()) Call interface method `GetImageMachineInfo`. 242 | #[zbus(name = "GetImageMachineInfo")] 243 | fn get_image_machine_info( 244 | &self, 245 | name: String, 246 | ) -> crate::zbus::Result<::std::collections::HashMap>; 247 | 248 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetImageOSRelease()) Call interface method `GetImageOSRelease`. 249 | #[zbus(name = "GetImageOSRelease")] 250 | fn get_image_os_release( 251 | &self, 252 | name: String, 253 | ) -> crate::zbus::Result<::std::collections::HashMap>; 254 | 255 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetPoolLimit()) Call interface method `SetPoolLimit`. 256 | #[zbus(name = "SetPoolLimit")] 257 | fn set_pool_limit(&self, size: u64) -> crate::zbus::Result<()>; 258 | 259 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetImageLimit()) Call interface method `SetImageLimit`. 260 | #[zbus(name = "SetImageLimit")] 261 | fn set_image_limit(&self, name: String, size: u64) -> crate::zbus::Result<()>; 262 | 263 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#CleanPool()) Call interface method `CleanPool`. 264 | #[zbus(name = "CleanPool")] 265 | fn clean_pool(&self, mode: String) -> crate::zbus::Result>; 266 | 267 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#MapFromMachineUser()) Call interface method `MapFromMachineUser`. 268 | #[zbus(name = "MapFromMachineUser")] 269 | fn map_from_machine_user(&self, name: String, uid_inner: u32) -> crate::zbus::Result; 270 | 271 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#MapToMachineUser()) Call interface method `MapToMachineUser`. 272 | #[zbus(name = "MapToMachineUser")] 273 | fn map_to_machine_user( 274 | &self, 275 | uid_outer: u32, 276 | ) -> crate::zbus::Result<(String, crate::zvariant::OwnedObjectPath, u32)>; 277 | 278 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#MapFromMachineGroup()) Call interface method `MapFromMachineGroup`. 279 | #[zbus(name = "MapFromMachineGroup")] 280 | fn map_from_machine_group(&self, name: String, gid_inner: u32) -> crate::zbus::Result; 281 | 282 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#MapToMachineGroup()) Call interface method `MapToMachineGroup`. 283 | #[zbus(name = "MapToMachineGroup")] 284 | fn map_to_machine_group( 285 | &self, 286 | gid_outer: u32, 287 | ) -> crate::zbus::Result<(String, crate::zvariant::OwnedObjectPath, u32)>; 288 | 289 | /// Receive `MachineNew` signal. 290 | #[zbus(signal, name = "MachineNew")] 291 | fn machine_new( 292 | &self, 293 | machine: String, 294 | path: crate::zvariant::OwnedObjectPath, 295 | ) -> crate::zbus::Result<()>; 296 | 297 | /// Receive `MachineRemoved` signal. 298 | #[zbus(signal, name = "MachineRemoved")] 299 | fn machine_removed( 300 | &self, 301 | machine: String, 302 | path: crate::zvariant::OwnedObjectPath, 303 | ) -> crate::zbus::Result<()>; 304 | 305 | /// Get property `PoolPath`. 306 | #[zbus(property(emits_changed_signal = "false"), name = "PoolPath")] 307 | fn pool_path(&self) -> crate::zbus::Result; 308 | 309 | /// Get property `PoolUsage`. 310 | #[zbus(property(emits_changed_signal = "false"), name = "PoolUsage")] 311 | fn pool_usage(&self) -> crate::zbus::Result; 312 | 313 | /// Get property `PoolLimit`. 314 | #[zbus(property(emits_changed_signal = "false"), name = "PoolLimit")] 315 | fn pool_limit(&self) -> crate::zbus::Result; 316 | } 317 | 318 | /// Proxy object for `org.freedesktop.machine1.Machine`. 319 | #[proxy( 320 | interface = "org.freedesktop.machine1.Machine", 321 | gen_blocking = false, 322 | default_service = "org.freedesktop.machine1", 323 | assume_defaults = false 324 | )] 325 | pub trait Machine { 326 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Terminate()) Call interface method `Terminate`. 327 | #[zbus(name = "Terminate")] 328 | fn terminate(&self) -> crate::zbus::Result<()>; 329 | 330 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Kill()) Call interface method `Kill`. 331 | #[zbus(name = "Kill")] 332 | fn kill(&self, whom: String, signal: i32) -> crate::zbus::Result<()>; 333 | 334 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetAddresses()) Call interface method `GetAddresses`. 335 | #[zbus(name = "GetAddresses")] 336 | fn get_addresses(&self) -> crate::zbus::Result)>>; 337 | 338 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetSSHInfo()) Call interface method `GetSSHInfo`. 339 | #[zbus(name = "GetSSHInfo")] 340 | fn get_ssh_info(&self) -> crate::zbus::Result<(String, String)>; 341 | 342 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetOSRelease()) Call interface method `GetOSRelease`. 343 | #[zbus(name = "GetOSRelease")] 344 | fn get_os_release(&self) -> crate::zbus::Result<::std::collections::HashMap>; 345 | 346 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetUIDShift()) Call interface method `GetUIDShift`. 347 | #[zbus(name = "GetUIDShift")] 348 | fn get_uid_shift(&self) -> crate::zbus::Result; 349 | 350 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#OpenPTY()) Call interface method `OpenPTY`. 351 | #[zbus(name = "OpenPTY")] 352 | fn open_pty(&self) -> crate::zbus::Result<(crate::zvariant::OwnedFd, String)>; 353 | 354 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#OpenLogin()) Call interface method `OpenLogin`. 355 | #[zbus(name = "OpenLogin")] 356 | fn open_login(&self) -> crate::zbus::Result<(crate::zvariant::OwnedFd, String)>; 357 | 358 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#OpenShell()) Call interface method `OpenShell`. 359 | #[zbus(name = "OpenShell")] 360 | fn open_shell( 361 | &self, 362 | user: String, 363 | path: String, 364 | args: Vec, 365 | environment: Vec, 366 | ) -> crate::zbus::Result<(crate::zvariant::OwnedFd, String)>; 367 | 368 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#BindMount()) Call interface method `BindMount`. 369 | #[zbus(name = "BindMount")] 370 | fn bind_mount( 371 | &self, 372 | source: String, 373 | destination: String, 374 | read_only: bool, 375 | mkdir: bool, 376 | ) -> crate::zbus::Result<()>; 377 | 378 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#CopyFrom()) Call interface method `CopyFrom`. 379 | #[zbus(name = "CopyFrom")] 380 | fn copy_from(&self, source: String, destination: String) -> crate::zbus::Result<()>; 381 | 382 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#CopyTo()) Call interface method `CopyTo`. 383 | #[zbus(name = "CopyTo")] 384 | fn copy_to(&self, source: String, destination: String) -> crate::zbus::Result<()>; 385 | 386 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#CopyFromWithFlags()) Call interface method `CopyFromWithFlags`. 387 | #[zbus(name = "CopyFromWithFlags")] 388 | fn copy_from_with_flags( 389 | &self, 390 | source: String, 391 | destination: String, 392 | flags: u64, 393 | ) -> crate::zbus::Result<()>; 394 | 395 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#CopyToWithFlags()) Call interface method `CopyToWithFlags`. 396 | #[zbus(name = "CopyToWithFlags")] 397 | fn copy_to_with_flags( 398 | &self, 399 | source: String, 400 | destination: String, 401 | flags: u64, 402 | ) -> crate::zbus::Result<()>; 403 | 404 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#OpenRootDirectory()) Call interface method `OpenRootDirectory`. 405 | #[zbus(name = "OpenRootDirectory")] 406 | fn open_root_directory(&self) -> crate::zbus::Result; 407 | 408 | /// Get property `Name`. 409 | #[zbus(property(emits_changed_signal = "const"), name = "Name")] 410 | fn name(&self) -> crate::zbus::Result; 411 | 412 | /// Get property `Id`. 413 | #[zbus(property(emits_changed_signal = "const"), name = "Id")] 414 | fn id(&self) -> crate::zbus::Result>; 415 | 416 | /// Get property `Timestamp`. 417 | #[zbus(property(emits_changed_signal = "const"), name = "Timestamp")] 418 | fn timestamp(&self) -> crate::zbus::Result; 419 | 420 | /// Get property `TimestampMonotonic`. 421 | #[zbus(property(emits_changed_signal = "const"), name = "TimestampMonotonic")] 422 | fn timestamp_monotonic(&self) -> crate::zbus::Result; 423 | 424 | /// Get property `Service`. 425 | #[zbus(property(emits_changed_signal = "const"), name = "Service")] 426 | fn service(&self) -> crate::zbus::Result; 427 | 428 | /// Get property `Unit`. 429 | #[zbus(property(emits_changed_signal = "const"), name = "Unit")] 430 | fn unit(&self) -> crate::zbus::Result; 431 | 432 | /// Get property `Leader`. 433 | #[zbus(property(emits_changed_signal = "const"), name = "Leader")] 434 | fn leader(&self) -> crate::zbus::Result; 435 | 436 | /// Get property `Class`. 437 | #[zbus(property(emits_changed_signal = "const"), name = "Class")] 438 | fn class(&self) -> crate::zbus::Result; 439 | 440 | /// Get property `RootDirectory`. 441 | #[zbus(property(emits_changed_signal = "const"), name = "RootDirectory")] 442 | fn root_directory(&self) -> crate::zbus::Result; 443 | 444 | /// Get property `NetworkInterfaces`. 445 | #[zbus(property(emits_changed_signal = "const"), name = "NetworkInterfaces")] 446 | fn network_interfaces(&self) -> crate::zbus::Result>; 447 | 448 | /// Get property `VSockCID`. 449 | #[zbus(property(emits_changed_signal = "const"), name = "VSockCID")] 450 | fn v_sock_cid(&self) -> crate::zbus::Result; 451 | 452 | /// Get property `SSHAddress`. 453 | #[zbus(property(emits_changed_signal = "const"), name = "SSHAddress")] 454 | fn ssh_address(&self) -> crate::zbus::Result; 455 | 456 | /// Get property `SSHPrivateKeyPath`. 457 | #[zbus(property(emits_changed_signal = "const"), name = "SSHPrivateKeyPath")] 458 | fn ssh_private_key_path(&self) -> crate::zbus::Result; 459 | 460 | /// Get property `State`. 461 | #[zbus(property(emits_changed_signal = "false"), name = "State")] 462 | fn state(&self) -> crate::zbus::Result; 463 | } 464 | -------------------------------------------------------------------------------- /src/machine1/mod.rs: -------------------------------------------------------------------------------- 1 | //! D-Bus interface for systemd-machined ([org.freedesktop.machine1](https://www.freedesktop.org/software/systemd/man/org.freedesktop.machine1.html)). 2 | 3 | mod generated; 4 | pub use generated::*; 5 | -------------------------------------------------------------------------------- /src/network1/generated.rs: -------------------------------------------------------------------------------- 1 | // This file is autogenerated, do not manually edit. 2 | 3 | use crate::zbus::proxy; 4 | 5 | /// Proxy object for `org.freedesktop.network1.Manager`. 6 | #[proxy( 7 | interface = "org.freedesktop.network1.Manager", 8 | gen_blocking = false, 9 | default_service = "org.freedesktop.network1", 10 | default_path = "/org/freedesktop/network1" 11 | )] 12 | pub trait Manager { 13 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ListLinks()) Call interface method `ListLinks`. 14 | #[zbus(name = "ListLinks")] 15 | fn list_links( 16 | &self, 17 | ) -> crate::zbus::Result>; 18 | 19 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetLinkByName()) Call interface method `GetLinkByName`. 20 | #[zbus(name = "GetLinkByName")] 21 | fn get_link_by_name( 22 | &self, 23 | name: String, 24 | ) -> crate::zbus::Result<(i32, crate::zvariant::OwnedObjectPath)>; 25 | 26 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetLinkByIndex()) Call interface method `GetLinkByIndex`. 27 | #[zbus(name = "GetLinkByIndex")] 28 | fn get_link_by_index( 29 | &self, 30 | ifindex: i32, 31 | ) -> crate::zbus::Result<(String, crate::zvariant::OwnedObjectPath)>; 32 | 33 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetLinkNTP()) Call interface method `SetLinkNTP`. 34 | #[zbus(name = "SetLinkNTP")] 35 | fn set_link_ntp(&self, ifindex: i32, servers: Vec) -> crate::zbus::Result<()>; 36 | 37 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetLinkDNS()) Call interface method `SetLinkDNS`. 38 | #[zbus(name = "SetLinkDNS")] 39 | fn set_link_dns(&self, ifindex: i32, addresses: Vec<(i32, Vec)>) 40 | -> crate::zbus::Result<()>; 41 | 42 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetLinkDNSEx()) Call interface method `SetLinkDNSEx`. 43 | #[zbus(name = "SetLinkDNSEx")] 44 | fn set_link_dns_ex( 45 | &self, 46 | ifindex: i32, 47 | addresses: Vec<(i32, Vec, u16, String)>, 48 | ) -> crate::zbus::Result<()>; 49 | 50 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetLinkDomains()) Call interface method `SetLinkDomains`. 51 | #[zbus(name = "SetLinkDomains")] 52 | fn set_link_domains( 53 | &self, 54 | ifindex: i32, 55 | domains: Vec<(String, bool)>, 56 | ) -> crate::zbus::Result<()>; 57 | 58 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetLinkDefaultRoute()) Call interface method `SetLinkDefaultRoute`. 59 | #[zbus(name = "SetLinkDefaultRoute")] 60 | fn set_link_default_route(&self, ifindex: i32, enable: bool) -> crate::zbus::Result<()>; 61 | 62 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetLinkLLMNR()) Call interface method `SetLinkLLMNR`. 63 | #[zbus(name = "SetLinkLLMNR")] 64 | fn set_link_llmnr(&self, ifindex: i32, mode: String) -> crate::zbus::Result<()>; 65 | 66 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetLinkMulticastDNS()) Call interface method `SetLinkMulticastDNS`. 67 | #[zbus(name = "SetLinkMulticastDNS")] 68 | fn set_link_multicast_dns(&self, ifindex: i32, mode: String) -> crate::zbus::Result<()>; 69 | 70 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetLinkDNSOverTLS()) Call interface method `SetLinkDNSOverTLS`. 71 | #[zbus(name = "SetLinkDNSOverTLS")] 72 | fn set_link_dns_over_tls(&self, ifindex: i32, mode: String) -> crate::zbus::Result<()>; 73 | 74 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetLinkDNSSEC()) Call interface method `SetLinkDNSSEC`. 75 | #[zbus(name = "SetLinkDNSSEC")] 76 | fn set_link_dnssec(&self, ifindex: i32, mode: String) -> crate::zbus::Result<()>; 77 | 78 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetLinkDNSSECNegativeTrustAnchors()) Call interface method `SetLinkDNSSECNegativeTrustAnchors`. 79 | #[zbus(name = "SetLinkDNSSECNegativeTrustAnchors")] 80 | fn set_link_dnssec_negative_trust_anchors( 81 | &self, 82 | ifindex: i32, 83 | names: Vec, 84 | ) -> crate::zbus::Result<()>; 85 | 86 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#RevertLinkNTP()) Call interface method `RevertLinkNTP`. 87 | #[zbus(name = "RevertLinkNTP")] 88 | fn revert_link_ntp(&self, ifindex: i32) -> crate::zbus::Result<()>; 89 | 90 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#RevertLinkDNS()) Call interface method `RevertLinkDNS`. 91 | #[zbus(name = "RevertLinkDNS")] 92 | fn revert_link_dns(&self, ifindex: i32) -> crate::zbus::Result<()>; 93 | 94 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#RenewLink()) Call interface method `RenewLink`. 95 | #[zbus(name = "RenewLink")] 96 | fn renew_link(&self, ifindex: i32) -> crate::zbus::Result<()>; 97 | 98 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ForceRenewLink()) Call interface method `ForceRenewLink`. 99 | #[zbus(name = "ForceRenewLink")] 100 | fn force_renew_link(&self, ifindex: i32) -> crate::zbus::Result<()>; 101 | 102 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ReconfigureLink()) Call interface method `ReconfigureLink`. 103 | #[zbus(name = "ReconfigureLink")] 104 | fn reconfigure_link(&self, ifindex: i32) -> crate::zbus::Result<()>; 105 | 106 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Reload()) Call interface method `Reload`. 107 | #[zbus(name = "Reload")] 108 | fn reload(&self) -> crate::zbus::Result<()>; 109 | 110 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#DescribeLink()) Call interface method `DescribeLink`. 111 | #[zbus(name = "DescribeLink")] 112 | fn describe_link(&self, ifindex: i32) -> crate::zbus::Result; 113 | 114 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Describe()) Call interface method `Describe`. 115 | #[zbus(name = "Describe")] 116 | fn describe(&self) -> crate::zbus::Result; 117 | 118 | /// Get property `OperationalState`. 119 | #[zbus(property(emits_changed_signal = "true"), name = "OperationalState")] 120 | fn operational_state(&self) -> crate::zbus::Result; 121 | 122 | /// Get property `CarrierState`. 123 | #[zbus(property(emits_changed_signal = "true"), name = "CarrierState")] 124 | fn carrier_state(&self) -> crate::zbus::Result; 125 | 126 | /// Get property `AddressState`. 127 | #[zbus(property(emits_changed_signal = "true"), name = "AddressState")] 128 | fn address_state(&self) -> crate::zbus::Result; 129 | 130 | /// Get property `IPv4AddressState`. 131 | #[zbus(property(emits_changed_signal = "true"), name = "IPv4AddressState")] 132 | fn i_pv4_address_state(&self) -> crate::zbus::Result; 133 | 134 | /// Get property `IPv6AddressState`. 135 | #[zbus(property(emits_changed_signal = "true"), name = "IPv6AddressState")] 136 | fn i_pv6_address_state(&self) -> crate::zbus::Result; 137 | 138 | /// Get property `OnlineState`. 139 | #[zbus(property(emits_changed_signal = "true"), name = "OnlineState")] 140 | fn online_state(&self) -> crate::zbus::Result; 141 | 142 | /// Get property `NamespaceId`. 143 | #[zbus(property(emits_changed_signal = "const"), name = "NamespaceId")] 144 | fn namespace_id(&self) -> crate::zbus::Result; 145 | 146 | /// Get property `NamespaceNSID`. 147 | #[zbus(property(emits_changed_signal = "false"), name = "NamespaceNSID")] 148 | fn namespace_nsid(&self) -> crate::zbus::Result; 149 | } 150 | 151 | /// Proxy object for `org.freedesktop.network1.Link`. 152 | #[proxy( 153 | interface = "org.freedesktop.network1.Link", 154 | gen_blocking = false, 155 | default_service = "org.freedesktop.network1", 156 | assume_defaults = false 157 | )] 158 | pub trait Link { 159 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetNTP()) Call interface method `SetNTP`. 160 | #[zbus(name = "SetNTP")] 161 | fn set_ntp(&self, servers: Vec) -> crate::zbus::Result<()>; 162 | 163 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetDNS()) Call interface method `SetDNS`. 164 | #[zbus(name = "SetDNS")] 165 | fn set_dns(&self, addresses: Vec<(i32, Vec)>) -> crate::zbus::Result<()>; 166 | 167 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetDNSEx()) Call interface method `SetDNSEx`. 168 | #[zbus(name = "SetDNSEx")] 169 | fn set_dns_ex(&self, addresses: Vec<(i32, Vec, u16, String)>) -> crate::zbus::Result<()>; 170 | 171 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetDomains()) Call interface method `SetDomains`. 172 | #[zbus(name = "SetDomains")] 173 | fn set_domains(&self, domains: Vec<(String, bool)>) -> crate::zbus::Result<()>; 174 | 175 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetDefaultRoute()) Call interface method `SetDefaultRoute`. 176 | #[zbus(name = "SetDefaultRoute")] 177 | fn set_default_route(&self, enable: bool) -> crate::zbus::Result<()>; 178 | 179 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetLLMNR()) Call interface method `SetLLMNR`. 180 | #[zbus(name = "SetLLMNR")] 181 | fn set_llmnr(&self, mode: String) -> crate::zbus::Result<()>; 182 | 183 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetMulticastDNS()) Call interface method `SetMulticastDNS`. 184 | #[zbus(name = "SetMulticastDNS")] 185 | fn set_multicast_dns(&self, mode: String) -> crate::zbus::Result<()>; 186 | 187 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetDNSOverTLS()) Call interface method `SetDNSOverTLS`. 188 | #[zbus(name = "SetDNSOverTLS")] 189 | fn set_dns_over_tls(&self, mode: String) -> crate::zbus::Result<()>; 190 | 191 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetDNSSEC()) Call interface method `SetDNSSEC`. 192 | #[zbus(name = "SetDNSSEC")] 193 | fn set_dnssec(&self, mode: String) -> crate::zbus::Result<()>; 194 | 195 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetDNSSECNegativeTrustAnchors()) Call interface method `SetDNSSECNegativeTrustAnchors`. 196 | #[zbus(name = "SetDNSSECNegativeTrustAnchors")] 197 | fn set_dnssec_negative_trust_anchors(&self, names: Vec) -> crate::zbus::Result<()>; 198 | 199 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#RevertNTP()) Call interface method `RevertNTP`. 200 | #[zbus(name = "RevertNTP")] 201 | fn revert_ntp(&self) -> crate::zbus::Result<()>; 202 | 203 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#RevertDNS()) Call interface method `RevertDNS`. 204 | #[zbus(name = "RevertDNS")] 205 | fn revert_dns(&self) -> crate::zbus::Result<()>; 206 | 207 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Renew()) Call interface method `Renew`. 208 | #[zbus(name = "Renew")] 209 | fn renew(&self) -> crate::zbus::Result<()>; 210 | 211 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ForceRenew()) Call interface method `ForceRenew`. 212 | #[zbus(name = "ForceRenew")] 213 | fn force_renew(&self) -> crate::zbus::Result<()>; 214 | 215 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Reconfigure()) Call interface method `Reconfigure`. 216 | #[zbus(name = "Reconfigure")] 217 | fn reconfigure(&self) -> crate::zbus::Result<()>; 218 | 219 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Describe()) Call interface method `Describe`. 220 | #[zbus(name = "Describe")] 221 | fn describe(&self) -> crate::zbus::Result; 222 | 223 | /// Get property `OperationalState`. 224 | #[zbus(property(emits_changed_signal = "true"), name = "OperationalState")] 225 | fn operational_state(&self) -> crate::zbus::Result; 226 | 227 | /// Get property `CarrierState`. 228 | #[zbus(property(emits_changed_signal = "true"), name = "CarrierState")] 229 | fn carrier_state(&self) -> crate::zbus::Result; 230 | 231 | /// Get property `AddressState`. 232 | #[zbus(property(emits_changed_signal = "true"), name = "AddressState")] 233 | fn address_state(&self) -> crate::zbus::Result; 234 | 235 | /// Get property `IPv4AddressState`. 236 | #[zbus(property(emits_changed_signal = "true"), name = "IPv4AddressState")] 237 | fn i_pv4_address_state(&self) -> crate::zbus::Result; 238 | 239 | /// Get property `IPv6AddressState`. 240 | #[zbus(property(emits_changed_signal = "true"), name = "IPv6AddressState")] 241 | fn i_pv6_address_state(&self) -> crate::zbus::Result; 242 | 243 | /// Get property `OnlineState`. 244 | #[zbus(property(emits_changed_signal = "true"), name = "OnlineState")] 245 | fn online_state(&self) -> crate::zbus::Result; 246 | 247 | /// Get property `AdministrativeState`. 248 | #[zbus(property(emits_changed_signal = "true"), name = "AdministrativeState")] 249 | fn administrative_state(&self) -> crate::zbus::Result; 250 | 251 | /// Get property `BitRates`. 252 | #[zbus(property(emits_changed_signal = "false"), name = "BitRates")] 253 | fn bit_rates(&self) -> crate::zbus::Result<(u64, u64)>; 254 | } 255 | 256 | /// Proxy object for `org.freedesktop.network1.Network`. 257 | #[proxy( 258 | interface = "org.freedesktop.network1.Network", 259 | gen_blocking = false, 260 | default_service = "org.freedesktop.network1", 261 | assume_defaults = false 262 | )] 263 | pub trait Network { 264 | /// Get property `Description`. 265 | #[zbus(property(emits_changed_signal = "const"), name = "Description")] 266 | fn description(&self) -> crate::zbus::Result; 267 | 268 | /// Get property `SourcePath`. 269 | #[zbus(property(emits_changed_signal = "const"), name = "SourcePath")] 270 | fn source_path(&self) -> crate::zbus::Result; 271 | 272 | /// Get property `MatchMAC`. 273 | #[zbus(property(emits_changed_signal = "const"), name = "MatchMAC")] 274 | fn match_mac(&self) -> crate::zbus::Result>; 275 | 276 | /// Get property `MatchPath`. 277 | #[zbus(property(emits_changed_signal = "const"), name = "MatchPath")] 278 | fn match_path(&self) -> crate::zbus::Result>; 279 | 280 | /// Get property `MatchDriver`. 281 | #[zbus(property(emits_changed_signal = "const"), name = "MatchDriver")] 282 | fn match_driver(&self) -> crate::zbus::Result>; 283 | 284 | /// Get property `MatchType`. 285 | #[zbus(property(emits_changed_signal = "const"), name = "MatchType")] 286 | fn match_type(&self) -> crate::zbus::Result>; 287 | 288 | /// Get property `MatchName`. 289 | #[zbus(property(emits_changed_signal = "const"), name = "MatchName")] 290 | fn match_name(&self) -> crate::zbus::Result>; 291 | } 292 | 293 | /// Proxy object for `org.freedesktop.network1.DHCPServer`. 294 | #[proxy( 295 | interface = "org.freedesktop.network1.DHCPServer", 296 | gen_blocking = false, 297 | default_service = "org.freedesktop.network1", 298 | assume_defaults = false 299 | )] 300 | pub trait DHCPServer { 301 | /// Get property `Leases`. 302 | #[zbus(property(emits_changed_signal = "true"), name = "Leases")] 303 | fn leases(&self) -> crate::zbus::Result, Vec, Vec, Vec, u64)>>; 304 | } 305 | 306 | /// Proxy object for `org.freedesktop.network1.DHCPv4Client`. 307 | #[proxy( 308 | interface = "org.freedesktop.network1.DHCPv4Client", 309 | gen_blocking = false, 310 | default_service = "org.freedesktop.network1", 311 | assume_defaults = false 312 | )] 313 | pub trait DHCPv4Client { 314 | /// Get property `State`. 315 | #[zbus(property(emits_changed_signal = "true"), name = "State")] 316 | fn state(&self) -> crate::zbus::Result; 317 | } 318 | 319 | /// Proxy object for `org.freedesktop.network1.DHCPv6Client`. 320 | #[proxy( 321 | interface = "org.freedesktop.network1.DHCPv6Client", 322 | gen_blocking = false, 323 | default_service = "org.freedesktop.network1", 324 | assume_defaults = false 325 | )] 326 | pub trait DHCPv6Client { 327 | /// Get property `State`. 328 | #[zbus(property(emits_changed_signal = "true"), name = "State")] 329 | fn state(&self) -> crate::zbus::Result; 330 | } 331 | -------------------------------------------------------------------------------- /src/network1/mod.rs: -------------------------------------------------------------------------------- 1 | //! D-Bus interface for systemd-networkd ([org.freedesktop.network1](https://www.freedesktop.org/software/systemd/man/org.freedesktop.network1.html)). 2 | 3 | mod generated; 4 | pub use generated::*; 5 | -------------------------------------------------------------------------------- /src/oom1/generated.rs: -------------------------------------------------------------------------------- 1 | // This file is autogenerated, do not manually edit. 2 | 3 | use crate::zbus::proxy; 4 | 5 | /// Proxy object for `org.freedesktop.oom1.Manager`. 6 | #[proxy( 7 | interface = "org.freedesktop.oom1.Manager", 8 | gen_blocking = false, 9 | default_service = "org.freedesktop.oom1", 10 | default_path = "/org/freedesktop/oom1" 11 | )] 12 | pub trait Manager { 13 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#DumpByFileDescriptor()) Call interface method `DumpByFileDescriptor`. 14 | #[zbus(name = "DumpByFileDescriptor")] 15 | fn dump_by_file_descriptor(&self) -> crate::zbus::Result; 16 | 17 | /// Receive `Killed` signal. 18 | #[zbus(signal, name = "Killed")] 19 | fn killed(&self, cgroup: String, reason: String) -> crate::zbus::Result<()>; 20 | } 21 | -------------------------------------------------------------------------------- /src/oom1/mod.rs: -------------------------------------------------------------------------------- 1 | //! D-Bus interface for systemd-oomd ([org.freedesktop.oom1](https://www.freedesktop.org/software/systemd/man/org.freedesktop.oom1.html)). 2 | 3 | mod generated; 4 | pub use generated::*; 5 | -------------------------------------------------------------------------------- /src/portable1/generated.rs: -------------------------------------------------------------------------------- 1 | // This file is autogenerated, do not manually edit. 2 | 3 | use crate::zbus::proxy; 4 | 5 | /// Proxy object for `org.freedesktop.portable1.Manager`. 6 | #[proxy( 7 | interface = "org.freedesktop.portable1.Manager", 8 | gen_blocking = false, 9 | default_service = "org.freedesktop.portable1", 10 | default_path = "/org/freedesktop/portable1" 11 | )] 12 | pub trait Manager { 13 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetImage()) Call interface method `GetImage`. 14 | #[zbus(name = "GetImage")] 15 | fn get_image(&self, image: String) -> crate::zbus::Result; 16 | 17 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ListImages()) Call interface method `ListImages`. 18 | #[zbus(name = "ListImages")] 19 | fn list_images( 20 | &self, 21 | ) -> crate::zbus::Result< 22 | Vec<( 23 | String, 24 | String, 25 | bool, 26 | u64, 27 | u64, 28 | u64, 29 | String, 30 | crate::zvariant::OwnedObjectPath, 31 | )>, 32 | >; 33 | 34 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetImageOSRelease()) Call interface method `GetImageOSRelease`. 35 | #[zbus(name = "GetImageOSRelease")] 36 | fn get_image_os_release( 37 | &self, 38 | image: String, 39 | ) -> crate::zbus::Result<::std::collections::HashMap>; 40 | 41 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetImageMetadata()) Call interface method `GetImageMetadata`. 42 | #[zbus(name = "GetImageMetadata")] 43 | fn get_image_metadata( 44 | &self, 45 | image: String, 46 | matches: Vec, 47 | ) -> crate::zbus::Result<( 48 | String, 49 | Vec, 50 | ::std::collections::HashMap>, 51 | )>; 52 | 53 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetImageMetadataWithExtensions()) Call interface method `GetImageMetadataWithExtensions`. 54 | #[zbus(name = "GetImageMetadataWithExtensions")] 55 | fn get_image_metadata_with_extensions( 56 | &self, 57 | image: String, 58 | extensions: Vec, 59 | matches: Vec, 60 | flags: u64, 61 | ) -> crate::zbus::Result<( 62 | String, 63 | Vec, 64 | ::std::collections::HashMap>, 65 | ::std::collections::HashMap>, 66 | )>; 67 | 68 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetImageState()) Call interface method `GetImageState`. 69 | #[zbus(name = "GetImageState")] 70 | fn get_image_state(&self, image: String) -> crate::zbus::Result; 71 | 72 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetImageStateWithExtensions()) Call interface method `GetImageStateWithExtensions`. 73 | #[zbus(name = "GetImageStateWithExtensions")] 74 | fn get_image_state_with_extensions( 75 | &self, 76 | image: String, 77 | extensions: Vec, 78 | flags: u64, 79 | ) -> crate::zbus::Result; 80 | 81 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#AttachImage()) Call interface method `AttachImage`. 82 | #[zbus(name = "AttachImage")] 83 | fn attach_image( 84 | &self, 85 | image: String, 86 | matches: Vec, 87 | profile: String, 88 | runtime: bool, 89 | copy_mode: String, 90 | ) -> crate::zbus::Result>; 91 | 92 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#AttachImageWithExtensions()) Call interface method `AttachImageWithExtensions`. 93 | #[zbus(name = "AttachImageWithExtensions")] 94 | fn attach_image_with_extensions( 95 | &self, 96 | image: String, 97 | extensions: Vec, 98 | matches: Vec, 99 | profile: String, 100 | copy_mode: String, 101 | flags: u64, 102 | ) -> crate::zbus::Result>; 103 | 104 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#DetachImage()) Call interface method `DetachImage`. 105 | #[zbus(name = "DetachImage")] 106 | fn detach_image( 107 | &self, 108 | image: String, 109 | runtime: bool, 110 | ) -> crate::zbus::Result>; 111 | 112 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#DetachImageWithExtensions()) Call interface method `DetachImageWithExtensions`. 113 | #[zbus(name = "DetachImageWithExtensions")] 114 | fn detach_image_with_extensions( 115 | &self, 116 | image: String, 117 | extensions: Vec, 118 | flags: u64, 119 | ) -> crate::zbus::Result>; 120 | 121 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ReattachImage()) Call interface method `ReattachImage`. 122 | #[zbus(name = "ReattachImage")] 123 | fn reattach_image( 124 | &self, 125 | image: String, 126 | matches: Vec, 127 | profile: String, 128 | runtime: bool, 129 | copy_mode: String, 130 | ) -> crate::zbus::Result<(Vec<(String, String, String)>, Vec<(String, String, String)>)>; 131 | 132 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ReattachImageWithExtensions()) Call interface method `ReattachImageWithExtensions`. 133 | #[zbus(name = "ReattachImageWithExtensions")] 134 | fn reattach_image_with_extensions( 135 | &self, 136 | image: String, 137 | extensions: Vec, 138 | matches: Vec, 139 | profile: String, 140 | copy_mode: String, 141 | flags: u64, 142 | ) -> crate::zbus::Result<(Vec<(String, String, String)>, Vec<(String, String, String)>)>; 143 | 144 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#RemoveImage()) Call interface method `RemoveImage`. 145 | #[zbus(name = "RemoveImage")] 146 | fn remove_image(&self, image: String) -> crate::zbus::Result<()>; 147 | 148 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#MarkImageReadOnly()) Call interface method `MarkImageReadOnly`. 149 | #[zbus(name = "MarkImageReadOnly")] 150 | fn mark_image_read_only(&self, image: String, read_only: bool) -> crate::zbus::Result<()>; 151 | 152 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetImageLimit()) Call interface method `SetImageLimit`. 153 | #[zbus(name = "SetImageLimit")] 154 | fn set_image_limit(&self, image: String, limit: u64) -> crate::zbus::Result<()>; 155 | 156 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetPoolLimit()) Call interface method `SetPoolLimit`. 157 | #[zbus(name = "SetPoolLimit")] 158 | fn set_pool_limit(&self, limit: u64) -> crate::zbus::Result<()>; 159 | 160 | /// Get property `PoolPath`. 161 | #[zbus(property(emits_changed_signal = "false"), name = "PoolPath")] 162 | fn pool_path(&self) -> crate::zbus::Result; 163 | 164 | /// Get property `PoolUsage`. 165 | #[zbus(property(emits_changed_signal = "false"), name = "PoolUsage")] 166 | fn pool_usage(&self) -> crate::zbus::Result; 167 | 168 | /// Get property `PoolLimit`. 169 | #[zbus(property(emits_changed_signal = "false"), name = "PoolLimit")] 170 | fn pool_limit(&self) -> crate::zbus::Result; 171 | 172 | /// Get property `Profiles`. 173 | #[zbus(property(emits_changed_signal = "false"), name = "Profiles")] 174 | fn profiles(&self) -> crate::zbus::Result>; 175 | } 176 | 177 | /// Proxy object for `org.freedesktop.portable1.Image`. 178 | #[proxy( 179 | interface = "org.freedesktop.portable1.Image", 180 | gen_blocking = false, 181 | default_service = "org.freedesktop.portable1", 182 | default_path = "/org/freedesktop/portable1" 183 | )] 184 | pub trait Image { 185 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetOSRelease()) Call interface method `GetOSRelease`. 186 | #[zbus(name = "GetOSRelease")] 187 | fn get_os_release(&self) -> crate::zbus::Result<::std::collections::HashMap>; 188 | 189 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetMetadata()) Call interface method `GetMetadata`. 190 | #[zbus(name = "GetMetadata")] 191 | fn get_metadata( 192 | &self, 193 | matches: Vec, 194 | ) -> crate::zbus::Result<( 195 | String, 196 | Vec, 197 | ::std::collections::HashMap>, 198 | )>; 199 | 200 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetMetadataWithExtensions()) Call interface method `GetMetadataWithExtensions`. 201 | #[zbus(name = "GetMetadataWithExtensions")] 202 | fn get_metadata_with_extensions( 203 | &self, 204 | extensions: Vec, 205 | matches: Vec, 206 | flags: u64, 207 | ) -> crate::zbus::Result<( 208 | String, 209 | Vec, 210 | ::std::collections::HashMap>, 211 | ::std::collections::HashMap>, 212 | )>; 213 | 214 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetState()) Call interface method `GetState`. 215 | #[zbus(name = "GetState")] 216 | fn get_state(&self) -> crate::zbus::Result; 217 | 218 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetStateWithExtensions()) Call interface method `GetStateWithExtensions`. 219 | #[zbus(name = "GetStateWithExtensions")] 220 | fn get_state_with_extensions( 221 | &self, 222 | extensions: Vec, 223 | flags: u64, 224 | ) -> crate::zbus::Result; 225 | 226 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Attach()) Call interface method `Attach`. 227 | #[zbus(name = "Attach")] 228 | fn attach( 229 | &self, 230 | matches: Vec, 231 | profile: String, 232 | runtime: bool, 233 | copy_mode: String, 234 | ) -> crate::zbus::Result>; 235 | 236 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#AttachWithExtensions()) Call interface method `AttachWithExtensions`. 237 | #[zbus(name = "AttachWithExtensions")] 238 | fn attach_with_extensions( 239 | &self, 240 | extensions: Vec, 241 | matches: Vec, 242 | profile: String, 243 | copy_mode: String, 244 | flags: u64, 245 | ) -> crate::zbus::Result>; 246 | 247 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Detach()) Call interface method `Detach`. 248 | #[zbus(name = "Detach")] 249 | fn detach(&self, runtime: bool) -> crate::zbus::Result>; 250 | 251 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#DetachWithExtensions()) Call interface method `DetachWithExtensions`. 252 | #[zbus(name = "DetachWithExtensions")] 253 | fn detach_with_extensions( 254 | &self, 255 | extensions: Vec, 256 | flags: u64, 257 | ) -> crate::zbus::Result>; 258 | 259 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Reattach()) Call interface method `Reattach`. 260 | #[zbus(name = "Reattach")] 261 | fn reattach( 262 | &self, 263 | matches: Vec, 264 | profile: String, 265 | runtime: bool, 266 | copy_mode: String, 267 | ) -> crate::zbus::Result<(Vec<(String, String, String)>, Vec<(String, String, String)>)>; 268 | 269 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ReattachWithExtensions()) Call interface method `ReattachWithExtensions`. 270 | #[zbus(name = "ReattachWithExtensions")] 271 | fn reattach_with_extensions( 272 | &self, 273 | extensions: Vec, 274 | matches: Vec, 275 | profile: String, 276 | copy_mode: String, 277 | flags: u64, 278 | ) -> crate::zbus::Result<(Vec<(String, String, String)>, Vec<(String, String, String)>)>; 279 | 280 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Remove()) Call interface method `Remove`. 281 | #[zbus(name = "Remove")] 282 | fn remove(&self) -> crate::zbus::Result<()>; 283 | 284 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#MarkReadOnly()) Call interface method `MarkReadOnly`. 285 | #[zbus(name = "MarkReadOnly")] 286 | fn mark_read_only(&self, read_only: bool) -> crate::zbus::Result<()>; 287 | 288 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetLimit()) Call interface method `SetLimit`. 289 | #[zbus(name = "SetLimit")] 290 | fn set_limit(&self, limit: u64) -> crate::zbus::Result<()>; 291 | 292 | /// Get property `Name`. 293 | #[zbus(property(emits_changed_signal = "false"), name = "Name")] 294 | fn name(&self) -> crate::zbus::Result; 295 | 296 | /// Get property `Path`. 297 | #[zbus(property(emits_changed_signal = "false"), name = "Path")] 298 | fn path(&self) -> crate::zbus::Result; 299 | 300 | /// Get property `Type`. 301 | #[zbus(property(emits_changed_signal = "false"), name = "Type")] 302 | fn type_property(&self) -> crate::zbus::Result; 303 | 304 | /// Get property `ReadOnly`. 305 | #[zbus(property(emits_changed_signal = "false"), name = "ReadOnly")] 306 | fn read_only(&self) -> crate::zbus::Result; 307 | 308 | /// Get property `CreationTimestamp`. 309 | #[zbus(property(emits_changed_signal = "false"), name = "CreationTimestamp")] 310 | fn creation_timestamp(&self) -> crate::zbus::Result; 311 | 312 | /// Get property `ModificationTimestamp`. 313 | #[zbus( 314 | property(emits_changed_signal = "false"), 315 | name = "ModificationTimestamp" 316 | )] 317 | fn modification_timestamp(&self) -> crate::zbus::Result; 318 | 319 | /// Get property `Usage`. 320 | #[zbus(property(emits_changed_signal = "false"), name = "Usage")] 321 | fn usage(&self) -> crate::zbus::Result; 322 | 323 | /// Get property `Limit`. 324 | #[zbus(property(emits_changed_signal = "false"), name = "Limit")] 325 | fn limit(&self) -> crate::zbus::Result; 326 | 327 | /// Get property `UsageExclusive`. 328 | #[zbus(property(emits_changed_signal = "false"), name = "UsageExclusive")] 329 | fn usage_exclusive(&self) -> crate::zbus::Result; 330 | 331 | /// Get property `LimitExclusive`. 332 | #[zbus(property(emits_changed_signal = "false"), name = "LimitExclusive")] 333 | fn limit_exclusive(&self) -> crate::zbus::Result; 334 | } 335 | -------------------------------------------------------------------------------- /src/portable1/mod.rs: -------------------------------------------------------------------------------- 1 | //! D-Bus interface for systemd-portabled ([org.freedesktop.portable1](https://www.freedesktop.org/software/systemd/man/org.freedesktop.portable1.html)). 2 | 3 | mod generated; 4 | pub use generated::*; 5 | -------------------------------------------------------------------------------- /src/resolve1/generated.rs: -------------------------------------------------------------------------------- 1 | // This file is autogenerated, do not manually edit. 2 | 3 | use crate::zbus::proxy; 4 | 5 | /// Proxy object for `org.freedesktop.resolve1.Manager`. 6 | #[proxy( 7 | interface = "org.freedesktop.resolve1.Manager", 8 | gen_blocking = false, 9 | default_service = "org.freedesktop.resolve1", 10 | default_path = "/org/freedesktop/resolve1" 11 | )] 12 | pub trait Manager { 13 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ResolveHostname()) Call interface method `ResolveHostname`. 14 | #[zbus(name = "ResolveHostname")] 15 | fn resolve_hostname( 16 | &self, 17 | ifindex: i32, 18 | name: String, 19 | family: i32, 20 | flags: u64, 21 | ) -> crate::zbus::Result<(Vec<(i32, i32, Vec)>, String, u64)>; 22 | 23 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ResolveAddress()) Call interface method `ResolveAddress`. 24 | #[zbus(name = "ResolveAddress")] 25 | fn resolve_address( 26 | &self, 27 | ifindex: i32, 28 | family: i32, 29 | address: Vec, 30 | flags: u64, 31 | ) -> crate::zbus::Result<(Vec<(i32, String)>, u64)>; 32 | 33 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ResolveRecord()) Call interface method `ResolveRecord`. 34 | #[zbus(name = "ResolveRecord")] 35 | fn resolve_record( 36 | &self, 37 | ifindex: i32, 38 | name: String, 39 | class: u16, 40 | typelabel: u16, 41 | flags: u64, 42 | ) -> crate::zbus::Result<(Vec<(i32, u16, u16, Vec)>, u64)>; 43 | 44 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ResolveService()) Call interface method `ResolveService`. 45 | #[zbus(name = "ResolveService")] 46 | fn resolve_service( 47 | &self, 48 | ifindex: i32, 49 | name: String, 50 | typelabel: String, 51 | domain: String, 52 | family: i32, 53 | flags: u64, 54 | ) -> crate::zbus::Result<( 55 | Vec<(u16, u16, u16, String, Vec<(i32, i32, Vec)>, String)>, 56 | Vec>, 57 | String, 58 | String, 59 | String, 60 | u64, 61 | )>; 62 | 63 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetLink()) Call interface method `GetLink`. 64 | #[zbus(name = "GetLink")] 65 | fn get_link(&self, ifindex: i32) -> crate::zbus::Result; 66 | 67 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetLinkDNS()) Call interface method `SetLinkDNS`. 68 | #[zbus(name = "SetLinkDNS")] 69 | fn set_link_dns(&self, ifindex: i32, addresses: Vec<(i32, Vec)>) 70 | -> crate::zbus::Result<()>; 71 | 72 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetLinkDNSEx()) Call interface method `SetLinkDNSEx`. 73 | #[zbus(name = "SetLinkDNSEx")] 74 | fn set_link_dns_ex( 75 | &self, 76 | ifindex: i32, 77 | addresses: Vec<(i32, Vec, u16, String)>, 78 | ) -> crate::zbus::Result<()>; 79 | 80 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetLinkDomains()) Call interface method `SetLinkDomains`. 81 | #[zbus(name = "SetLinkDomains")] 82 | fn set_link_domains( 83 | &self, 84 | ifindex: i32, 85 | domains: Vec<(String, bool)>, 86 | ) -> crate::zbus::Result<()>; 87 | 88 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetLinkDefaultRoute()) Call interface method `SetLinkDefaultRoute`. 89 | #[zbus(name = "SetLinkDefaultRoute")] 90 | fn set_link_default_route(&self, ifindex: i32, enable: bool) -> crate::zbus::Result<()>; 91 | 92 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetLinkLLMNR()) Call interface method `SetLinkLLMNR`. 93 | #[zbus(name = "SetLinkLLMNR")] 94 | fn set_link_llmnr(&self, ifindex: i32, mode: String) -> crate::zbus::Result<()>; 95 | 96 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetLinkMulticastDNS()) Call interface method `SetLinkMulticastDNS`. 97 | #[zbus(name = "SetLinkMulticastDNS")] 98 | fn set_link_multicast_dns(&self, ifindex: i32, mode: String) -> crate::zbus::Result<()>; 99 | 100 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetLinkDNSOverTLS()) Call interface method `SetLinkDNSOverTLS`. 101 | #[zbus(name = "SetLinkDNSOverTLS")] 102 | fn set_link_dns_over_tls(&self, ifindex: i32, mode: String) -> crate::zbus::Result<()>; 103 | 104 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetLinkDNSSEC()) Call interface method `SetLinkDNSSEC`. 105 | #[zbus(name = "SetLinkDNSSEC")] 106 | fn set_link_dnssec(&self, ifindex: i32, mode: String) -> crate::zbus::Result<()>; 107 | 108 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetLinkDNSSECNegativeTrustAnchors()) Call interface method `SetLinkDNSSECNegativeTrustAnchors`. 109 | #[zbus(name = "SetLinkDNSSECNegativeTrustAnchors")] 110 | fn set_link_dnssec_negative_trust_anchors( 111 | &self, 112 | ifindex: i32, 113 | names: Vec, 114 | ) -> crate::zbus::Result<()>; 115 | 116 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#RevertLink()) Call interface method `RevertLink`. 117 | #[zbus(name = "RevertLink")] 118 | fn revert_link(&self, ifindex: i32) -> crate::zbus::Result<()>; 119 | 120 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#RegisterService()) Call interface method `RegisterService`. 121 | #[zbus(name = "RegisterService")] 122 | fn register_service( 123 | &self, 124 | id: String, 125 | name_template: String, 126 | typelabel: String, 127 | service_port: u16, 128 | service_priority: u16, 129 | service_weight: u16, 130 | txt_datas: Vec<::std::collections::HashMap>>, 131 | ) -> crate::zbus::Result; 132 | 133 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#UnregisterService()) Call interface method `UnregisterService`. 134 | #[zbus(name = "UnregisterService")] 135 | fn unregister_service( 136 | &self, 137 | service_path: crate::zvariant::OwnedObjectPath, 138 | ) -> crate::zbus::Result<()>; 139 | 140 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ResetStatistics()) Call interface method `ResetStatistics`. 141 | #[zbus(name = "ResetStatistics")] 142 | fn reset_statistics(&self) -> crate::zbus::Result<()>; 143 | 144 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#FlushCaches()) Call interface method `FlushCaches`. 145 | #[zbus(name = "FlushCaches")] 146 | fn flush_caches(&self) -> crate::zbus::Result<()>; 147 | 148 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ResetServerFeatures()) Call interface method `ResetServerFeatures`. 149 | #[zbus(name = "ResetServerFeatures")] 150 | fn reset_server_features(&self) -> crate::zbus::Result<()>; 151 | 152 | /// Get property `LLMNRHostname`. 153 | #[zbus(property(emits_changed_signal = "true"), name = "LLMNRHostname")] 154 | fn llmnr_hostname(&self) -> crate::zbus::Result; 155 | 156 | /// Get property `LLMNR`. 157 | #[zbus(property(emits_changed_signal = "false"), name = "LLMNR")] 158 | fn llmnr(&self) -> crate::zbus::Result; 159 | 160 | /// Get property `MulticastDNS`. 161 | #[zbus(property(emits_changed_signal = "false"), name = "MulticastDNS")] 162 | fn multicast_dns(&self) -> crate::zbus::Result; 163 | 164 | /// Get property `DNSOverTLS`. 165 | #[zbus(property(emits_changed_signal = "false"), name = "DNSOverTLS")] 166 | fn dns_over_tls(&self) -> crate::zbus::Result; 167 | 168 | /// Get property `DNS`. 169 | #[zbus(property(emits_changed_signal = "true"), name = "DNS")] 170 | fn dns(&self) -> crate::zbus::Result)>>; 171 | 172 | /// Get property `DNSEx`. 173 | #[zbus(property(emits_changed_signal = "true"), name = "DNSEx")] 174 | fn dns_ex(&self) -> crate::zbus::Result, u16, String)>>; 175 | 176 | /// Get property `FallbackDNS`. 177 | #[zbus(property(emits_changed_signal = "const"), name = "FallbackDNS")] 178 | fn fallback_dns(&self) -> crate::zbus::Result)>>; 179 | 180 | /// Get property `FallbackDNSEx`. 181 | #[zbus(property(emits_changed_signal = "const"), name = "FallbackDNSEx")] 182 | fn fallback_dns_ex(&self) -> crate::zbus::Result, u16, String)>>; 183 | 184 | /// Get property `CurrentDNSServer`. 185 | #[zbus(property(emits_changed_signal = "true"), name = "CurrentDNSServer")] 186 | fn current_dns_server(&self) -> crate::zbus::Result<(i32, i32, Vec)>; 187 | 188 | /// Get property `CurrentDNSServerEx`. 189 | #[zbus(property(emits_changed_signal = "true"), name = "CurrentDNSServerEx")] 190 | fn current_dns_server_ex(&self) -> crate::zbus::Result<(i32, i32, Vec, u16, String)>; 191 | 192 | /// Get property `Domains`. 193 | #[zbus(property(emits_changed_signal = "false"), name = "Domains")] 194 | fn domains(&self) -> crate::zbus::Result>; 195 | 196 | /// Get property `TransactionStatistics`. 197 | #[zbus( 198 | property(emits_changed_signal = "false"), 199 | name = "TransactionStatistics" 200 | )] 201 | fn transaction_statistics(&self) -> crate::zbus::Result<(u64, u64)>; 202 | 203 | /// Get property `CacheStatistics`. 204 | #[zbus(property(emits_changed_signal = "false"), name = "CacheStatistics")] 205 | fn cache_statistics(&self) -> crate::zbus::Result<(u64, u64, u64)>; 206 | 207 | /// Get property `DNSSEC`. 208 | #[zbus(property(emits_changed_signal = "false"), name = "DNSSEC")] 209 | fn dnssec(&self) -> crate::zbus::Result; 210 | 211 | /// Get property `DNSSECStatistics`. 212 | #[zbus(property(emits_changed_signal = "false"), name = "DNSSECStatistics")] 213 | fn dnssec_statistics(&self) -> crate::zbus::Result<(u64, u64, u64, u64)>; 214 | 215 | /// Get property `DNSSECSupported`. 216 | #[zbus(property(emits_changed_signal = "false"), name = "DNSSECSupported")] 217 | fn dnssec_supported(&self) -> crate::zbus::Result; 218 | 219 | /// Get property `DNSSECNegativeTrustAnchors`. 220 | #[zbus( 221 | property(emits_changed_signal = "false"), 222 | name = "DNSSECNegativeTrustAnchors" 223 | )] 224 | fn dnssec_negative_trust_anchors(&self) -> crate::zbus::Result>; 225 | 226 | /// Get property `DNSStubListener`. 227 | #[zbus(property(emits_changed_signal = "false"), name = "DNSStubListener")] 228 | fn dns_stub_listener(&self) -> crate::zbus::Result; 229 | 230 | /// Get property `ResolvConfMode`. 231 | #[zbus(property(emits_changed_signal = "false"), name = "ResolvConfMode")] 232 | fn resolv_conf_mode(&self) -> crate::zbus::Result; 233 | } 234 | 235 | /// Proxy object for `org.freedesktop.resolve1.Link`. 236 | #[proxy( 237 | interface = "org.freedesktop.resolve1.Link", 238 | gen_blocking = false, 239 | default_service = "org.freedesktop.resolve1", 240 | assume_defaults = false 241 | )] 242 | pub trait Link { 243 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetDNS()) Call interface method `SetDNS`. 244 | #[zbus(name = "SetDNS")] 245 | fn set_dns(&self, addresses: Vec<(i32, Vec)>) -> crate::zbus::Result<()>; 246 | 247 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetDNSEx()) Call interface method `SetDNSEx`. 248 | #[zbus(name = "SetDNSEx")] 249 | fn set_dns_ex(&self, addresses: Vec<(i32, Vec, u16, String)>) -> crate::zbus::Result<()>; 250 | 251 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetDomains()) Call interface method `SetDomains`. 252 | #[zbus(name = "SetDomains")] 253 | fn set_domains(&self, domains: Vec<(String, bool)>) -> crate::zbus::Result<()>; 254 | 255 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetDefaultRoute()) Call interface method `SetDefaultRoute`. 256 | #[zbus(name = "SetDefaultRoute")] 257 | fn set_default_route(&self, enable: bool) -> crate::zbus::Result<()>; 258 | 259 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetLLMNR()) Call interface method `SetLLMNR`. 260 | #[zbus(name = "SetLLMNR")] 261 | fn set_llmnr(&self, mode: String) -> crate::zbus::Result<()>; 262 | 263 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetMulticastDNS()) Call interface method `SetMulticastDNS`. 264 | #[zbus(name = "SetMulticastDNS")] 265 | fn set_multicast_dns(&self, mode: String) -> crate::zbus::Result<()>; 266 | 267 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetDNSOverTLS()) Call interface method `SetDNSOverTLS`. 268 | #[zbus(name = "SetDNSOverTLS")] 269 | fn set_dns_over_tls(&self, mode: String) -> crate::zbus::Result<()>; 270 | 271 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetDNSSEC()) Call interface method `SetDNSSEC`. 272 | #[zbus(name = "SetDNSSEC")] 273 | fn set_dnssec(&self, mode: String) -> crate::zbus::Result<()>; 274 | 275 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetDNSSECNegativeTrustAnchors()) Call interface method `SetDNSSECNegativeTrustAnchors`. 276 | #[zbus(name = "SetDNSSECNegativeTrustAnchors")] 277 | fn set_dnssec_negative_trust_anchors(&self, names: Vec) -> crate::zbus::Result<()>; 278 | 279 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Revert()) Call interface method `Revert`. 280 | #[zbus(name = "Revert")] 281 | fn revert(&self) -> crate::zbus::Result<()>; 282 | 283 | /// Get property `ScopesMask`. 284 | #[zbus(property(emits_changed_signal = "false"), name = "ScopesMask")] 285 | fn scopes_mask(&self) -> crate::zbus::Result; 286 | 287 | /// Get property `DNS`. 288 | #[zbus(property(emits_changed_signal = "false"), name = "DNS")] 289 | fn dns(&self) -> crate::zbus::Result)>>; 290 | 291 | /// Get property `DNSEx`. 292 | #[zbus(property(emits_changed_signal = "false"), name = "DNSEx")] 293 | fn dns_ex(&self) -> crate::zbus::Result, u16, String)>>; 294 | 295 | /// Get property `CurrentDNSServer`. 296 | #[zbus(property(emits_changed_signal = "false"), name = "CurrentDNSServer")] 297 | fn current_dns_server(&self) -> crate::zbus::Result<(i32, Vec)>; 298 | 299 | /// Get property `CurrentDNSServerEx`. 300 | #[zbus(property(emits_changed_signal = "false"), name = "CurrentDNSServerEx")] 301 | fn current_dns_server_ex(&self) -> crate::zbus::Result<(i32, Vec, u16, String)>; 302 | 303 | /// Get property `Domains`. 304 | #[zbus(property(emits_changed_signal = "false"), name = "Domains")] 305 | fn domains(&self) -> crate::zbus::Result>; 306 | 307 | /// Get property `DefaultRoute`. 308 | #[zbus(property(emits_changed_signal = "false"), name = "DefaultRoute")] 309 | fn default_route(&self) -> crate::zbus::Result; 310 | 311 | /// Get property `LLMNR`. 312 | #[zbus(property(emits_changed_signal = "false"), name = "LLMNR")] 313 | fn llmnr(&self) -> crate::zbus::Result; 314 | 315 | /// Get property `MulticastDNS`. 316 | #[zbus(property(emits_changed_signal = "false"), name = "MulticastDNS")] 317 | fn multicast_dns(&self) -> crate::zbus::Result; 318 | 319 | /// Get property `DNSOverTLS`. 320 | #[zbus(property(emits_changed_signal = "false"), name = "DNSOverTLS")] 321 | fn dns_over_tls(&self) -> crate::zbus::Result; 322 | 323 | /// Get property `DNSSEC`. 324 | #[zbus(property(emits_changed_signal = "false"), name = "DNSSEC")] 325 | fn dnssec(&self) -> crate::zbus::Result; 326 | 327 | /// Get property `DNSSECNegativeTrustAnchors`. 328 | #[zbus( 329 | property(emits_changed_signal = "false"), 330 | name = "DNSSECNegativeTrustAnchors" 331 | )] 332 | fn dnssec_negative_trust_anchors(&self) -> crate::zbus::Result>; 333 | 334 | /// Get property `DNSSECSupported`. 335 | #[zbus(property(emits_changed_signal = "false"), name = "DNSSECSupported")] 336 | fn dnssec_supported(&self) -> crate::zbus::Result; 337 | } 338 | -------------------------------------------------------------------------------- /src/resolve1/mod.rs: -------------------------------------------------------------------------------- 1 | //! D-Bus interface for systemd-resolved ([org.freedesktop.resolve1](https://www.freedesktop.org/software/systemd/man/org.freedesktop.resolve1.html)). 2 | 3 | mod generated; 4 | pub use generated::*; 5 | -------------------------------------------------------------------------------- /src/systemd1/mod.rs: -------------------------------------------------------------------------------- 1 | //! D-Bus interface for systemd ([org.freedesktop.systemd1](https://www.freedesktop.org/software/systemd/man/org.freedesktop.systemd1.html)). 2 | 3 | mod generated; 4 | pub use generated::*; 5 | -------------------------------------------------------------------------------- /src/sysupdate1/generated.rs: -------------------------------------------------------------------------------- 1 | // This file is autogenerated, do not manually edit. 2 | 3 | use crate::zbus::proxy; 4 | 5 | /// Proxy object for `org.freedesktop.sysupdate1.Manager`. 6 | #[proxy( 7 | interface = "org.freedesktop.sysupdate1.Manager", 8 | gen_blocking = false, 9 | default_service = "org.freedesktop.sysupdate1", 10 | default_path = "/org/freedesktop/sysupdate1" 11 | )] 12 | pub trait Manager { 13 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ListTargets()) Call interface method `ListTargets`. 14 | #[zbus(name = "ListTargets")] 15 | fn list_targets( 16 | &self, 17 | ) -> crate::zbus::Result>; 18 | 19 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ListJobs()) Call interface method `ListJobs`. 20 | #[zbus(name = "ListJobs")] 21 | fn list_jobs( 22 | &self, 23 | ) -> crate::zbus::Result>; 24 | 25 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ListAppStream()) Call interface method `ListAppStream`. 26 | #[zbus(name = "ListAppStream")] 27 | fn list_app_stream(&self) -> crate::zbus::Result>; 28 | 29 | /// Receive `JobRemoved` signal. 30 | #[zbus(signal, name = "JobRemoved")] 31 | fn job_removed( 32 | &self, 33 | id: u64, 34 | path: crate::zvariant::OwnedObjectPath, 35 | status: i32, 36 | ) -> crate::zbus::Result<()>; 37 | } 38 | 39 | /// Proxy object for `org.freedesktop.sysupdate1.Target`. 40 | #[proxy( 41 | interface = "org.freedesktop.sysupdate1.Target", 42 | gen_blocking = false, 43 | default_service = "org.freedesktop.sysupdate1", 44 | assume_defaults = false 45 | )] 46 | pub trait Target { 47 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#List()) Call interface method `List`. 48 | #[zbus(name = "List")] 49 | fn list(&self, flags: u64) -> crate::zbus::Result>; 50 | 51 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Describe()) Call interface method `Describe`. 52 | #[zbus(name = "Describe")] 53 | fn describe(&self, version: String, flags: u64) -> crate::zbus::Result; 54 | 55 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#CheckNew()) Call interface method `CheckNew`. 56 | #[zbus(name = "CheckNew")] 57 | fn check_new(&self) -> crate::zbus::Result; 58 | 59 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Update()) Call interface method `Update`. 60 | #[zbus(name = "Update")] 61 | fn update( 62 | &self, 63 | new_version: String, 64 | flags: u64, 65 | ) -> crate::zbus::Result<(String, u64, crate::zvariant::OwnedObjectPath)>; 66 | 67 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Vacuum()) Call interface method `Vacuum`. 68 | #[zbus(name = "Vacuum")] 69 | fn vacuum(&self) -> crate::zbus::Result<(u32, u32)>; 70 | 71 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetAppStream()) Call interface method `GetAppStream`. 72 | #[zbus(name = "GetAppStream")] 73 | fn get_app_stream(&self) -> crate::zbus::Result>; 74 | 75 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#GetVersion()) Call interface method `GetVersion`. 76 | #[zbus(name = "GetVersion")] 77 | fn get_version(&self) -> crate::zbus::Result; 78 | 79 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ListFeatures()) Call interface method `ListFeatures`. 80 | #[zbus(name = "ListFeatures")] 81 | fn list_features(&self, flags: u64) -> crate::zbus::Result>; 82 | 83 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#DescribeFeature()) Call interface method `DescribeFeature`. 84 | #[zbus(name = "DescribeFeature")] 85 | fn describe_feature(&self, feature: String, flags: u64) -> crate::zbus::Result; 86 | 87 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetFeatureEnabled()) Call interface method `SetFeatureEnabled`. 88 | #[zbus(name = "SetFeatureEnabled")] 89 | fn set_feature_enabled( 90 | &self, 91 | feature: String, 92 | enabled: i32, 93 | flags: u64, 94 | ) -> crate::zbus::Result<()>; 95 | 96 | /// Get property `Class`. 97 | #[zbus(property(emits_changed_signal = "const"), name = "Class")] 98 | fn class(&self) -> crate::zbus::Result; 99 | 100 | /// Get property `Name`. 101 | #[zbus(property(emits_changed_signal = "const"), name = "Name")] 102 | fn name(&self) -> crate::zbus::Result; 103 | 104 | /// Get property `Path`. 105 | #[zbus(property(emits_changed_signal = "const"), name = "Path")] 106 | fn path(&self) -> crate::zbus::Result; 107 | } 108 | 109 | /// Proxy object for `org.freedesktop.sysupdate1.Job`. 110 | #[proxy( 111 | interface = "org.freedesktop.sysupdate1.Job", 112 | gen_blocking = false, 113 | default_service = "org.freedesktop.sysupdate1", 114 | assume_defaults = false 115 | )] 116 | pub trait Job { 117 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#Cancel()) Call interface method `Cancel`. 118 | #[zbus(name = "Cancel")] 119 | fn cancel(&self) -> crate::zbus::Result<()>; 120 | 121 | /// Get property `Id`. 122 | #[zbus(property(emits_changed_signal = "const"), name = "Id")] 123 | fn id(&self) -> crate::zbus::Result; 124 | 125 | /// Get property `Type`. 126 | #[zbus(property(emits_changed_signal = "const"), name = "Type")] 127 | fn type_property(&self) -> crate::zbus::Result; 128 | 129 | /// Get property `Offline`. 130 | #[zbus(property(emits_changed_signal = "const"), name = "Offline")] 131 | fn offline(&self) -> crate::zbus::Result; 132 | 133 | /// Get property `Progress`. 134 | #[zbus(property(emits_changed_signal = "true"), name = "Progress")] 135 | fn progress(&self) -> crate::zbus::Result; 136 | } 137 | -------------------------------------------------------------------------------- /src/sysupdate1/mod.rs: -------------------------------------------------------------------------------- 1 | //! D-Bus interface for systemd-sysupdated ([org.freedesktop.sysupdate1](https://www.freedesktop.org/software/systemd/man/org.freedesktop.sysupdate1.html)). 2 | mod generated; 3 | pub use generated::*; 4 | -------------------------------------------------------------------------------- /src/timedate1/generated.rs: -------------------------------------------------------------------------------- 1 | // This file is autogenerated, do not manually edit. 2 | 3 | use crate::zbus::proxy; 4 | 5 | /// Proxy object for `org.freedesktop.timedate1`. 6 | #[proxy( 7 | interface = "org.freedesktop.timedate1", 8 | gen_blocking = false, 9 | default_service = "org.freedesktop.timedate1", 10 | default_path = "/org/freedesktop/timedate1" 11 | )] 12 | pub trait Timedated { 13 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetTime()) Call interface method `SetTime`. 14 | #[zbus(name = "SetTime")] 15 | fn set_time(&self, usec_utc: i64, relative: bool, interactive: bool) 16 | -> crate::zbus::Result<()>; 17 | 18 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetTimezone()) Call interface method `SetTimezone`. 19 | #[zbus(name = "SetTimezone")] 20 | fn set_timezone(&self, timezone: String, interactive: bool) -> crate::zbus::Result<()>; 21 | 22 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetLocalRTC()) Call interface method `SetLocalRTC`. 23 | #[zbus(name = "SetLocalRTC")] 24 | fn set_local_rtc( 25 | &self, 26 | local_rtc: bool, 27 | fix_system: bool, 28 | interactive: bool, 29 | ) -> crate::zbus::Result<()>; 30 | 31 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetNTP()) Call interface method `SetNTP`. 32 | #[zbus(name = "SetNTP")] 33 | fn set_ntp(&self, use_ntp: bool, interactive: bool) -> crate::zbus::Result<()>; 34 | 35 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#ListTimezones()) Call interface method `ListTimezones`. 36 | #[zbus(name = "ListTimezones")] 37 | fn list_timezones(&self) -> crate::zbus::Result>; 38 | 39 | /// Get property `Timezone`. 40 | #[zbus(property(emits_changed_signal = "true"), name = "Timezone")] 41 | fn timezone(&self) -> crate::zbus::Result; 42 | 43 | /// Get property `LocalRTC`. 44 | #[zbus(property(emits_changed_signal = "true"), name = "LocalRTC")] 45 | fn local_rtc(&self) -> crate::zbus::Result; 46 | 47 | /// Get property `CanNTP`. 48 | #[zbus(property(emits_changed_signal = "false"), name = "CanNTP")] 49 | fn can_ntp(&self) -> crate::zbus::Result; 50 | 51 | /// Get property `NTP`. 52 | #[zbus(property(emits_changed_signal = "true"), name = "NTP")] 53 | fn ntp(&self) -> crate::zbus::Result; 54 | 55 | /// Get property `NTPSynchronized`. 56 | #[zbus(property(emits_changed_signal = "false"), name = "NTPSynchronized")] 57 | fn ntp_synchronized(&self) -> crate::zbus::Result; 58 | 59 | /// Get property `TimeUSec`. 60 | #[zbus(property(emits_changed_signal = "false"), name = "TimeUSec")] 61 | fn time_u_sec(&self) -> crate::zbus::Result; 62 | 63 | /// Get property `RTCTimeUSec`. 64 | #[zbus(property(emits_changed_signal = "false"), name = "RTCTimeUSec")] 65 | fn rtc_time_u_sec(&self) -> crate::zbus::Result; 66 | } 67 | -------------------------------------------------------------------------------- /src/timedate1/mod.rs: -------------------------------------------------------------------------------- 1 | //! D-Bus interface for systemd-timedated ([org.freedesktop.timedate1](https://www.freedesktop.org/software/systemd/man/org.freedesktop.timedate1.html)). 2 | 3 | mod generated; 4 | pub use generated::*; 5 | -------------------------------------------------------------------------------- /src/timesync1/generated.rs: -------------------------------------------------------------------------------- 1 | // This file is autogenerated, do not manually edit. 2 | 3 | use crate::zbus::proxy; 4 | 5 | /// Proxy object for `org.freedesktop.timesync1.Manager`. 6 | #[proxy( 7 | interface = "org.freedesktop.timesync1.Manager", 8 | gen_blocking = false, 9 | default_service = "org.freedesktop.timesync1", 10 | default_path = "/org/freedesktop/timesync1" 11 | )] 12 | pub trait Manager { 13 | /// [📖](https://www.freedesktop.org/software/systemd/man/systemd.directives.html#SetRuntimeNTPServers()) Call interface method `SetRuntimeNTPServers`. 14 | #[zbus(name = "SetRuntimeNTPServers")] 15 | fn set_runtime_ntp_servers(&self, runtime_servers: Vec) -> crate::zbus::Result<()>; 16 | 17 | /// Get property `LinkNTPServers`. 18 | #[zbus(property(emits_changed_signal = "true"), name = "LinkNTPServers")] 19 | fn link_ntp_servers(&self) -> crate::zbus::Result>; 20 | 21 | /// Get property `SystemNTPServers`. 22 | #[zbus(property(emits_changed_signal = "true"), name = "SystemNTPServers")] 23 | fn system_ntp_servers(&self) -> crate::zbus::Result>; 24 | 25 | /// Get property `RuntimeNTPServers`. 26 | #[zbus(property(emits_changed_signal = "true"), name = "RuntimeNTPServers")] 27 | fn runtime_ntp_servers(&self) -> crate::zbus::Result>; 28 | 29 | /// Get property `FallbackNTPServers`. 30 | #[zbus(property(emits_changed_signal = "true"), name = "FallbackNTPServers")] 31 | fn fallback_ntp_servers(&self) -> crate::zbus::Result>; 32 | 33 | /// Get property `ServerName`. 34 | #[zbus(property(emits_changed_signal = "false"), name = "ServerName")] 35 | fn server_name(&self) -> crate::zbus::Result; 36 | 37 | /// Get property `ServerAddress`. 38 | #[zbus(property(emits_changed_signal = "false"), name = "ServerAddress")] 39 | fn server_address(&self) -> crate::zbus::Result<(i32, Vec)>; 40 | 41 | /// Get property `RootDistanceMaxUSec`. 42 | #[zbus(property(emits_changed_signal = "const"), name = "RootDistanceMaxUSec")] 43 | fn root_distance_max_u_sec(&self) -> crate::zbus::Result; 44 | 45 | /// Get property `PollIntervalMinUSec`. 46 | #[zbus(property(emits_changed_signal = "const"), name = "PollIntervalMinUSec")] 47 | fn poll_interval_min_u_sec(&self) -> crate::zbus::Result; 48 | 49 | /// Get property `PollIntervalMaxUSec`. 50 | #[zbus(property(emits_changed_signal = "const"), name = "PollIntervalMaxUSec")] 51 | fn poll_interval_max_u_sec(&self) -> crate::zbus::Result; 52 | 53 | /// Get property `PollIntervalUSec`. 54 | #[zbus(property(emits_changed_signal = "false"), name = "PollIntervalUSec")] 55 | fn poll_interval_u_sec(&self) -> crate::zbus::Result; 56 | 57 | /// Get property `NTPMessage`. 58 | #[zbus(property(emits_changed_signal = "true"), name = "NTPMessage")] 59 | fn ntp_message( 60 | &self, 61 | ) -> crate::zbus::Result<( 62 | u32, 63 | u32, 64 | u32, 65 | u32, 66 | i32, 67 | u64, 68 | u64, 69 | Vec, 70 | u64, 71 | u64, 72 | u64, 73 | u64, 74 | bool, 75 | u64, 76 | u64, 77 | )>; 78 | 79 | /// Get property `Frequency`. 80 | #[zbus(property(emits_changed_signal = "false"), name = "Frequency")] 81 | fn frequency(&self) -> crate::zbus::Result; 82 | } 83 | -------------------------------------------------------------------------------- /src/timesync1/mod.rs: -------------------------------------------------------------------------------- 1 | //! D-Bus interface for systemd-timesyncd ([org.freedesktop.timesync1](https://www.freedesktop.org/software/systemd/man/org.freedesktop.timesync1.html)). 2 | mod generated; 3 | pub use generated::*; 4 | --------------------------------------------------------------------------------