summaryrefslogtreecommitdiff
path: root/src/datatype/command.rs
diff options
context:
space:
mode:
authorShaun Taheri <shaun@advancedtelematic.com>2016-08-19 10:12:07 +0200
committerShaun Taheri <shaun@advancedtelematic.com>2016-08-23 18:00:28 +0200
commitba122a6fa07fed1eca61d2fc6c4fd5eebf50449e (patch)
tree31646764e34532f2c616ded6c577d4b5328a41f9 /src/datatype/command.rs
parent5debba21cc671d19c176369b849b5cad9c611071 (diff)
downloadrvi_sota_client-ba122a6fa07fed1eca61d2fc6c4fd5eebf50449e.tar.gz
Add documentation to public functions
Diffstat (limited to 'src/datatype/command.rs')
-rw-r--r--src/datatype/command.rs35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/datatype/command.rs b/src/datatype/command.rs
index ac61774..d29920b 100644
--- a/src/datatype/command.rs
+++ b/src/datatype/command.rs
@@ -1,4 +1,4 @@
-use std::fmt;
+use std::fmt::{Display, Formatter, Result as FmtResult};
use std::str;
use std::str::FromStr;
@@ -7,23 +7,40 @@ use datatype::{ClientCredentials, ClientId, ClientSecret, Error, InstalledSoftwa
UpdateReport, UpdateRequestId};
+/// System-wide commands that are sent to the interpreter.
#[derive(RustcDecodable, RustcEncodable, PartialEq, Eq, Debug, Clone)]
pub enum Command {
+ /// Authenticate with the auth server.
Authenticate(Option<ClientCredentials>),
+ /// Shutdown the client immediately.
Shutdown,
+ /// Check for any new updates.
GetPendingUpdates,
+ /// Start downloading and installing one or more updates.
AcceptUpdates(Vec<UpdateRequestId>),
+ /// Cancel the installation process of one or more updates.
AbortUpdates(Vec<UpdateRequestId>),
+ /// Query the system to find all the currently installed packages.
ListInstalledPackages,
+ /// Publish the currently installed packages to the core server.
UpdateInstalledPackages,
+ /// Send a list of packages and firmwares installed via RVI.
SendInstalledSoftware(Option<InstalledSoftware>),
+ /// Send a report of the system information to the core server.
SendSystemInfo,
+ /// Send an installation report via RVI.
SendUpdateReport(Option<UpdateReport>),
}
+impl Display for Command {
+ fn fmt(&self, f: &mut Formatter) -> FmtResult {
+ write!(f, "{:?}", self)
+ }
+}
+
impl FromStr for Command {
type Err = Error;
@@ -35,12 +52,6 @@ impl FromStr for Command {
}
}
-impl fmt::Display for Command {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "{:?}", self)
- }
-}
-
named!(command <(Command, Vec<&str>)>, chain!(
space?
@@ -99,10 +110,10 @@ fn parse_arguments(cmd: Command, args: Vec<&str>) -> Result<Command, Error> {
Command::Authenticate(_) => match args.len() {
0 => Ok(Command::Authenticate(None)),
- 1 => Err(Error::Command("usage: auth <id> <secret>".to_string())),
+ 1 => Err(Error::Command("usage: auth <client-id> <client-secret>".to_string())),
2 => Ok(Command::Authenticate(Some(ClientCredentials {
- id: ClientId(args[0].to_string()),
- secret: ClientSecret(args[1].to_string())}))),
+ client_id: ClientId(args[0].to_string()),
+ client_secret: ClientSecret(args[1].to_string())}))),
_ => Err(Error::Command(format!("unexpected Authenticate args: {:?}", args))),
},
@@ -193,8 +204,8 @@ mod tests {
assert_eq!("Authenticate".parse::<Command>().unwrap(), Command::Authenticate(None));
assert_eq!("auth user pass".parse::<Command>().unwrap(),
Command::Authenticate(Some(ClientCredentials {
- id: ClientId("user".to_string()),
- secret: ClientSecret("pass".to_string()),
+ client_id: ClientId("user".to_string()),
+ client_secret: ClientSecret("pass".to_string()),
})));
assert!("auth one".parse::<Command>().is_err());
assert!("auth one two three".parse::<Command>().is_err());