-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit cf32690
Showing
12 changed files
with
728 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Release-plz | ||
|
||
permissions: | ||
pull-requests: write | ||
contents: write | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
release-plz: | ||
name: Release-plz | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Install Rust toolchain | ||
uses: dtolnay/rust-toolchain@stable | ||
- name: Run release-plz | ||
uses: MarcoIeni/release-plz-action@v0.5 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Rust | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Build | ||
run: cargo build --verbose | ||
- name: Run tests | ||
run: cargo test --verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "systemd-directories" | ||
version = "0.1.0" | ||
authors = ["Adam Sasine <adam.sasine@gmail.com>"] | ||
edition = "2021" | ||
description = "A tiny library to retrieve systemd directories following systemd.exec(5)" | ||
homepage = "https://github.com/asasine/systemd-directories" | ||
repository = "https://github.com/asasine/systemd-directories" | ||
license = "MIT" | ||
keywords = ["systemd", "directories"] | ||
categories = ["filesystem", "config"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Adam Sasine | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# systemd-directories | ||
A tiny library to retrieve systemd directories following [systemd.exec(5)](https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#RuntimeDirectory=). | ||
|
||
This library targets Linux when systemd is used as the execution environment. | ||
|
||
[![Crates.io Version](https://img.shields.io/crates/v/systemd-directories?logo=rust)](https://crates.io/crates/systemd-directories) | ||
[![Crates.io Documentation](https://docs.rs/systemd-directories/badge.svg)](https://docs.rs/systemd-directories) | ||
[![CI](https://img.shields.io/github/actions/workflow/status/asasine/systemd-directories/rust.yaml?branch=main&logo=github&label=CI)](https://github.com/asasine/systemd-directories/actions/workflows/rust.yaml?query=branch%3Amain) | ||
[![Crates.io Downloads](https://img.shields.io/crates/d/systemd-directories)](https://crates.io/crates/systemd-directories) | ||
|
||
|
||
# Examples | ||
## Standalone functions | ||
```rust | ||
use systemd_directories; | ||
use std::env; | ||
use std::path::PathBuf; | ||
env::set_var("RUNTIME_DIRECTORY", "/run/foo"); | ||
let runtime_dir = systemd_directories::runtime_dir(); | ||
assert_eq!(runtime_dir, Some(PathBuf::from("/run/foo"))); | ||
``` | ||
|
||
## `SystemdDirs` Struct | ||
```rust | ||
use systemd_directories::SystemdDirs; | ||
use std::env; | ||
use std::path::Path; | ||
env::set_var("RUNTIME_DIRECTORY", "/run/foo"); | ||
let dirs = SystemdDirs::new(); | ||
assert_eq!(dirs.runtime_dir(), Some(Path::new("/run/foo"))); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use systemd_directories; | ||
|
||
fn main() { | ||
println!("runtime dir: {:?}", systemd_directories::runtime_dir()); | ||
println!("state dir: {:?}", systemd_directories::state_dir()); | ||
println!("cache dir: {:?}", systemd_directories::cache_dir()); | ||
println!("log dir: {:?}", systemd_directories::logs_dir()); | ||
println!("config dir: {:?}", systemd_directories::config_dir()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use systemd_directories; | ||
|
||
fn main() { | ||
println!("runtime dir: {:?}", systemd_directories::runtime_dirs()); | ||
println!("state dir: {:?}", systemd_directories::state_dirs()); | ||
println!("cache dir: {:?}", systemd_directories::cache_dirs()); | ||
println!("log dir: {:?}", systemd_directories::logs_dirs()); | ||
println!("config dir: {:?}", systemd_directories::config_dirs()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use systemd_directories::SystemdDirs; | ||
|
||
fn main() { | ||
// NOTE: These will possibly be empty if not running under systemd | ||
let dirs = SystemdDirs::new(); | ||
println!("runtime dir: {:?}", dirs.runtime_dir()); | ||
println!("state dir: {:?}", dirs.state_dir()); | ||
println!("cache dir: {:?}", dirs.cache_dir()); | ||
println!("log dir: {:?}", dirs.logs_dir()); | ||
println!("config dir: {:?}", dirs.config_dir()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use systemd_directories::SystemdDirs; | ||
|
||
fn main() { | ||
// NOTE: These will possibly be empty if not running under systemd | ||
let dirs = SystemdDirs::new(); | ||
println!("runtime dir: {:?}", dirs.runtime_dirs()); | ||
println!("state dir: {:?}", dirs.state_dirs()); | ||
println!("cache dir: {:?}", dirs.cache_dirs()); | ||
println!("log dir: {:?}", dirs.logs_dirs()); | ||
println!("config dir: {:?}", dirs.config_dirs()); | ||
} |
Oops, something went wrong.