summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@ifm.com>2022-05-17 13:09:43 +0200
committerMatthias Beyer <matthias.beyer@ifm.com>2022-05-17 13:29:37 +0200
commitbab6567ba13b6c9ab3f6c0b9848fd351b36dfe9f (patch)
treeb13a05f32994fed277e15e415a2304606c865f7c
parent834880ed2d276bbcc62300752ef0c3600c0ac32b (diff)
Add getters to sm operation types
The response::List type had to be changed because using the getset crate requires the field for the getter to be named. Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
-rw-r--r--Cargo.lock13
-rw-r--r--crates/core/tedge_lib/Cargo.toml1
-rw-r--r--crates/core/tedge_lib/src/sm.rs61
3 files changed, 58 insertions, 17 deletions
diff --git a/Cargo.lock b/Cargo.lock
index cd02f8da..ab8b6087 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1154,6 +1154,18 @@ dependencies = [
]
[[package]]
+name = "getset"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e45727250e75cc04ff2846a66397da8ef2b3db8e40e0cef4df67950a07621eb9"
+dependencies = [
+ "proc-macro-error",
+ "proc-macro2 1.0.38",
+ "quote 1.0.18",
+ "syn 1.0.93",
+]
+
+[[package]]
name = "gimli"
version = "0.26.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3486,6 +3498,7 @@ version = "0.1.0"
dependencies = [
"async-trait",
"futures",
+ "getset",
"humantime-serde",
"indoc",
"log",
diff --git a/crates/core/tedge_lib/Cargo.toml b/crates/core/tedge_lib/Cargo.toml
index 5c95662a..4a0b842f 100644
--- a/crates/core/tedge_lib/Cargo.toml
+++ b/crates/core/tedge_lib/Cargo.toml
@@ -16,5 +16,6 @@ toml = "0.5.8"
tracing = "0.1"
humantime-serde = "1"
indoc = "1.0.6"
+getset = "0.1"
tedge_api = { path = "../tedge_api" }
diff --git a/crates/core/tedge_lib/src/sm.rs b/crates/core/tedge_lib/src/sm.rs
index 76d6a69e..4049df66 100644
--- a/crates/core/tedge_lib/src/sm.rs
+++ b/crates/core/tedge_lib/src/sm.rs
@@ -7,27 +7,30 @@ pub mod request {
impl tedge_api::Message for List {}
/// Install a software by name
- #[derive(Debug)]
+ #[derive(Debug, getset::Getters)]
pub struct Install {
/// The name of the package in this operation
+ #[getset(get = "pub")]
package_name: String,
}
impl tedge_api::Message for Install {}
/// Update a software by name
- #[derive(Debug)]
+ #[derive(Debug, getset::Getters)]
pub struct Update {
/// The name of the package in this operation
+ #[getset(get = "pub")]
package_name: String,
}
impl tedge_api::Message for Update {}
/// Uninstall a software by name
- #[derive(Debug)]
+ #[derive(Debug, getset::Getters)]
pub struct Uninstall {
/// The name of the package in this operation
+ #[getset(get = "pub")]
package_name: String,
}
@@ -37,8 +40,11 @@ pub mod request {
/// Types for representing a "response" that was yielded by an operation for a "request"
pub mod response {
/// A list of installed things
- #[derive(Debug)]
- pub struct List(Vec<String>);
+ #[derive(Debug, getset::Getters)]
+ pub struct List {
+ #[getset(get = "pub")]
+ list: Vec<String>,
+ }
impl tedge_api::Message for List {}
@@ -49,46 +55,53 @@ pub mod response {
impl tedge_api::Message for ListFailed {}
/// A state representing an ongoing install process
- #[derive(Debug)]
+ #[derive(Debug, getset::Getters, getset::CopyGetters)]
pub struct InstallingState {
/// The name of the package in this operation
+ #[getset(get = "pub")]
package_name: String,
///
/// A number between 0 and 100 describing the progress of the operation
+ #[getset(get_copy = "pub")]
progress: usize,
}
impl tedge_api::Message for InstallingState {}
/// A log line from an install process
- #[derive(Debug)]
+ #[derive(Debug, getset::Getters)]
pub struct InstallingLogLine {
/// The name of the package in this operation
+ #[getset(get = "pub")]
package_name: String,
/// A single line of output from the procedure
+ #[getset(get = "pub")]
log_line: String,
}
impl tedge_api::Message for InstallingLogLine {}
/// Installing a package succeeded
- #[derive(Debug)]
+ #[derive(Debug, getset::Getters)]
pub struct InstallSucceeded {
/// The name of the package in this operation
+ #[getset(get = "pub")]
package_name: String,
}
impl tedge_api::Message for InstallSucceeded {}
/// Installing a package failed
- #[derive(Debug)]
+ #[derive(Debug, getset::Getters)]
pub struct InstallFailed {
/// The name of the package in this operation
+ #[getset(get = "pub")]
package_name: String,
/// A human-readable message describing the failure
+ #[getset(get = "pub")]
failure_message: String,
}
@@ -96,45 +109,52 @@ pub mod response {
///
/// Progress report from an ongoing update process
- #[derive(Debug)]
+ #[derive(Debug, getset::Getters, getset::CopyGetters)]
pub struct UpdatingState {
/// The name of the package in this operation
+ #[getset(get = "pub")]
package_name: String,
/// A number between 0 and 100 describing the progress of the operation
+ #[getset(get_copy = "pub")]
progress: usize,
}
impl tedge_api::Message for UpdatingState {}
/// A log line from an ongoing update process
- #[derive(Debug)]
+ #[derive(Debug, getset::Getters)]
pub struct UpdatingLogLine {
/// The name of the package in this operation
+ #[getset(get = "pub")]
package_name: String,
/// A single line of output from the procedure
+ #[getset(get = "pub")]
log_line: String,
}
impl tedge_api::Message for UpdatingLogLine {}
/// A update process succeeded
- #[derive(Debug)]
+ #[derive(Debug, getset::Getters)]
pub struct UpdateSucceeded {
/// The name of the package in this operation
+ #[getset(get = "pub")]
package_name: String,
}
impl tedge_api::Message for UpdateSucceeded {}
/// A update process failed
- #[derive(Debug)]
+ #[derive(Debug, getset::Getters)]
pub struct UpdateFailed {
/// The name of the package in this operation
+ #[getset(get = "pub")]
package_name: String,
/// A human-readable message describing the failure
+ #[getset(get = "pub")]
failure_message: String,
}
@@ -142,45 +162,52 @@ pub mod response {
///
/// Progress report from an ongoing uninstall process
- #[derive(Debug)]
+ #[derive(Debug, getset::Getters, getset::CopyGetters)]
pub struct UninstallState {
/// The name of the package in this operation
+ #[getset(get = "pub")]
package_name: String,
/// A number between 0 and 100 describing the progress of the operation
+ #[getset(get_copy = "pub")]
progress: usize,
}
impl tedge_api::Message for UninstallState {}
/// A log line from an ongoing uninstall process
- #[derive(Debug)]
+ #[derive(Debug, getset::Getters)]
pub struct UninstallLogLine {
/// The name of the package in this operation
+ #[getset(get = "pub")]
package_name: String,
/// A single line of output from the procedure
+ #[getset(get = "pub")]
log_line: String,
}
impl tedge_api::Message for UninstallLogLine {}
/// Uninstall process succeeded
- #[derive(Debug)]
+ #[derive(Debug, getset::Getters)]
pub struct UninstallSucceeded {
/// The name of the package in this operation
+ #[getset(get = "pub")]
package_name: String,
}
impl tedge_api::Message for UninstallSucceeded {}
/// Uninstall process failed
- #[derive(Debug)]
+ #[derive(Debug, getset::Getters)]
pub struct UninstallFailed {
/// The name of the package in this operation
+ #[getset(get = "pub")]
package_name: String,
/// A human-readable message describing the failure
+ #[getset(get = "pub")]
failure_message: String,
}