diff options
Diffstat (limited to 'src/datatype/event.rs')
-rw-r--r-- | src/datatype/event.rs | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/datatype/event.rs b/src/datatype/event.rs new file mode 100644 index 0000000..e3f84ca --- /dev/null +++ b/src/datatype/event.rs @@ -0,0 +1,56 @@ +use std::fmt::{Display, Formatter, Result as FmtResult}; + +use datatype::{DownloadComplete, Package, UpdateAvailable, UpdateReport, + UpdateRequestId}; + + +/// System-wide events that are broadcast to all interested parties. +#[derive(RustcEncodable, RustcDecodable, Debug, Clone, PartialEq, Eq)] +pub enum Event { + /// General error event with a printable representation for debugging. + Error(String), + + /// Authentication was successful. + Authenticated, + /// An operation failed because we are not currently authenticated. + NotAuthenticated, + + /// There are new updates available. + NewUpdatesReceived(Vec<UpdateRequestId>), + /// A notification from RVI of a new update. + NewUpdateAvailable(UpdateAvailable), + /// There are no new updates available. + NoNewUpdates, + + /// The following packages are installed on the device. + FoundInstalledPackages(Vec<Package>), + /// An update on the system information was received. + FoundSystemInfo(String), + /// A list of installed packages was sent to the Core server. + InstalledPackagesSent, + /// An update report was sent to the Core server. + UpdateReportSent, + + /// Downloading an update. + DownloadingUpdate(UpdateRequestId), + /// An update was downloaded. + DownloadComplete(DownloadComplete), + /// Downloading an update failed. + DownloadFailed(UpdateRequestId, String), + + /// Installing an update. + InstallingUpdate(UpdateRequestId), + /// An update was installed. + InstallComplete(UpdateReport), + /// The installation of an update failed. + InstallFailed(UpdateReport), + + /// A broadcast event requesting an update on externally installed software. + InstalledSoftwareNeeded, +} + +impl Display for Event { + fn fmt(&self, f: &mut Formatter) -> FmtResult { + write!(f, "{:?}", self) + } +} |