chaste_types/derivation/
mod.rs1use crate::error::Result;
5use crate::package::PackageID;
6
7mod patch;
8
9pub use patch::{PackagePatch, PackagePatchBuilder};
10
11#[derive(Debug, Clone, PartialEq, Eq)]
12#[non_exhaustive]
13pub struct PackageDerivationMeta {
14 derivation: PackageDerivation,
15 from: PackageID,
16}
17
18impl PackageDerivationMeta {
19 pub fn derivation(&self) -> &PackageDerivation {
20 &self.derivation
21 }
22
23 pub fn derived_from(&self) -> PackageID {
24 self.from
25 }
26
27 pub fn patch(&self) -> Option<&patch::PackagePatch> {
28 match &self.derivation {
29 PackageDerivation::Patch(package_patch) => Some(package_patch),
30 }
32 }
33}
34
35pub struct PackageDerivationMetaBuilder {
36 derivation: PackageDerivation,
37 from: PackageID,
38}
39
40impl PackageDerivationMetaBuilder {
41 pub fn new(derivation: PackageDerivation, from: PackageID) -> Self {
42 Self { derivation, from }
43 }
44
45 pub fn build(self) -> Result<PackageDerivationMeta> {
46 Ok(PackageDerivationMeta {
47 derivation: self.derivation,
48 from: self.from,
49 })
50 }
51}
52
53#[derive(Debug, Clone, PartialEq, Eq)]
54#[non_exhaustive]
55pub enum PackageDerivation {
56 Patch(PackagePatch),
57}