| Crates.io | geneos-toolkit |
| lib.rs | geneos-toolkit |
| version | 0.3.1 |
| created_at | 2025-04-07 20:01:18.245754+00 |
| updated_at | 2025-12-12 02:13:32.132988+00 |
| description | Rust library for building Geneos Toolkit compatible applications |
| homepage | |
| repository | https://github.com/ITRS-Group/geneos-toolkit-rs |
| max_upload_size | |
| id | 1624672 |
| size | 94,870 |
geneos-toolkit is a Rust library for building Geneos Toolkit compatible applications. It provides utilities for creating structured Geneos Dataviews, handling environment variables (including encrypted ones), to simplify integration development. For the Geneos Toolkit plugin format and lifecycle, see the Geneos Toolkit docs: https://docs.itrsgroup.com/docs/geneos/current/collection/toolkit-plugin/index.html
Row + add_row without repeating the row id.secure-env to expose secure helpers (decrypt, get_secure_var, etc.) for encrypted env vars.secure-env disabled, secure helpers are absent and there are zero third-party runtime dependencies.Add the following to your Cargo.toml:
# Lean default (no secure env, zero third-party runtime dependencies)
[dependencies]
geneos-toolkit = "0.2"
# Enable secure env helpers (adds crypto dependencies)
# geneos-toolkit = { version = "0.2", features = ["secure-env"] }
set_row_header.add_headline.add_value(row, column, value).Row::new(...).add_cell(...).add_row(row).sort_rows(), sort_rows_by(...), or sort_rows_with(...).get_var/get_var_or always available; secure helpers (get_secure_var, decrypt) only with secure-env.secure-env is enabled.+-------------+-----------------+-----------------+
| row header | column1 | column2 | <-- header row (row header + column names)
+=============+=================+=================+
| <!>headline1| value1 | | <-- headline rows (metadata, prefixed with "<!>")
| <!>headline2| value2 | |
+-------------+-----------------+-----------------+
| rowA | valA1 | valA2 | <-- data rows (row name + cell values)
| rowB | valB1 | valB2 |
+-------------+-----------------+-----------------+
Rendered output for the same layout:
row_header,column1,column2
<!>headline1,value1
<!>headline2,value2
rowA,valA1,valA2
rowB,valB1,valB2
use geneos_toolkit::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let clear_env_var = get_var_or("CLEAR_ENV_VAR", "Default Value")?;
let dataview = Dataview::builder()
.set_row_header("Process")
.add_headline(
"Hostname",
hostname::get().unwrap_or_default().to_string_lossy(),
)
.add_headline("Timestamp", chrono::Utc::now().to_rfc3339())
.add_headline("Clear Env Var", &clear_env_var)
.add_value("process1", "Status", "Running")
.add_value("process1", "CPU", "2.5%")
.add_value("process1", "Memory", "150MB")
.build()?;
println!("{}", dataview);
Ok(())
}
use geneos_toolkit::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let row1 = Row::new("server-02")
.add_cell("cpu", "45%")
.add_cell("status", "active");
let row2 = Row::new("server-01")
.add_cell("cpu", "12%")
.add_cell("status", "idle");
let dataview = Dataview::builder()
.set_row_header("host")
.add_headline("region", "us-east-1")
.add_row(row1)
.add_row(row2)
.sort_rows() // opt-in: otherwise insertion order is kept
.build()?;
println!("{}", dataview);
Ok(())
}
use geneos_toolkit::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Unknown order at runtime; we sort descending by name afterward.
let hosts = ["beta", "alpha", "gamma"];
let mut builder = Dataview::builder()
.set_row_header("host")
.add_headline("source", "inventory");
for name in hosts {
let row = Row::new(name)
.add_cell("status", "up")
.add_cell("cpu", "n/a");
builder = builder.add_row(row);
}
let dataview = builder
.sort_rows_with(|a, b| b.cmp(a)) // custom comparator: reverse lexicographic
.build()?;
println!("{}", dataview);
Ok(())
}
Enable the secure-env feature to add the secure helpers:
[dependencies]
geneos-toolkit = { version = "0.2", features = ["secure-env"] }
This feature gates decrypt, get_secure_var, and related helpers.
use geneos_toolkit::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let secret = get_secure_var("MY_SECRET", "/path/to/keyfile")?;
println!("Secret: {}", secret);
Ok(())
}
secure-env, encrypted values (+encs+) make get_var/get_var_or return MissingSecureEnvSupport, and the secure helpers are not exposed.Contributions are welcome! If you have suggestions, bug fixes, or enhancements, please open an issue or submit a pull request.
This project is licensed under the Apache License, Version 2.0.
Copyright 2025 ITRS Group
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.