wick_oci_utils/
package.rs

1mod pull;
2mod push;
3
4use std::path::PathBuf;
5
6pub use pull::*;
7pub use push::*;
8/// Annotation types associated with Wick packages.
9pub mod annotations;
10/// Media types associated with Wick packages.
11pub mod media_types;
12
13/// Represents a single file in a Wick package.
14#[derive(Debug, Clone)]
15pub struct PackageFile {
16  package_path: PathBuf,
17  hash: String,
18  media_type: String,
19  contents: bytes::Bytes,
20}
21
22impl PackageFile {
23  pub fn new(package_path: PathBuf, hash: String, media_type: String, contents: bytes::Bytes) -> Self {
24    Self {
25      package_path,
26      hash,
27      media_type,
28      contents,
29    }
30  }
31
32  /// Get path for the file.
33  #[must_use]
34  pub const fn package_path(&self) -> &PathBuf {
35    &self.package_path
36  }
37
38  /// Get hash for the file.
39  #[must_use]
40  pub fn hash(&self) -> &str {
41    &self.hash
42  }
43
44  /// Get media type for the file.
45  #[must_use]
46  pub fn media_type(&self) -> &str {
47    &self.media_type
48  }
49
50  /// Get contents for the file.
51  #[must_use]
52  pub fn contents(&self) -> &[u8] {
53    &self.contents
54  }
55
56  /// Get contents for the file.
57  #[must_use]
58  #[allow(clippy::missing_const_for_fn)]
59  pub fn into_contents(self) -> bytes::Bytes {
60    self.contents
61  }
62}