|
| 1 | +// This Source Code Form is subject to the terms of the Mozilla Public |
| 2 | +// License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 | +// file, You can obtain one at https://mozilla.org/MPL/2.0/. |
| 4 | + |
| 5 | +use iddqd::{IdOrdItem, IdOrdMap, id_upcast}; |
| 6 | +use omicron_uuid_kinds::MupdateUuid; |
| 7 | +use serde::{Deserialize, Serialize}; |
| 8 | +use tufaceous_artifact::ArtifactHash; |
| 9 | + |
| 10 | +/// Describes the set of Omicron zones written out into an install dataset. |
| 11 | +#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)] |
| 12 | +pub struct OmicronZoneManifest { |
| 13 | + /// The UUID of the mupdate which created this manifest. Intended primarily |
| 14 | + /// for checking equality. |
| 15 | + pub mupdate_id: MupdateUuid, |
| 16 | + |
| 17 | + /// Omicron zone file names and hashes. |
| 18 | + pub zones: IdOrdMap<OmicronZoneFileMetadata>, |
| 19 | +} |
| 20 | + |
| 21 | +impl OmicronZoneManifest { |
| 22 | + /// The name of the file. |
| 23 | + pub const FILE_NAME: &str = "zones.json"; |
| 24 | +} |
| 25 | + |
| 26 | +/// Information about an Omicron zone file written out to the install dataset. |
| 27 | +/// |
| 28 | +/// Part of [`OmicronZoneManifest`]. |
| 29 | +#[derive( |
| 30 | + Clone, Debug, Eq, Ord, PartialEq, PartialOrd, Deserialize, Serialize, |
| 31 | +)] |
| 32 | +pub struct OmicronZoneFileMetadata { |
| 33 | + /// The file name. |
| 34 | + pub file_name: String, |
| 35 | + |
| 36 | + /// The file size. |
| 37 | + pub file_size: u64, |
| 38 | + |
| 39 | + /// The hash of the file. |
| 40 | + pub hash: ArtifactHash, |
| 41 | +} |
| 42 | + |
| 43 | +impl IdOrdItem for OmicronZoneFileMetadata { |
| 44 | + type Key<'a> = &'a str; |
| 45 | + |
| 46 | + #[inline] |
| 47 | + fn key(&self) -> Self::Key<'_> { |
| 48 | + &self.file_name |
| 49 | + } |
| 50 | + |
| 51 | + id_upcast!(); |
| 52 | +} |
0 commit comments