fennec_common/
workspace.rs

1// Copyright 2023 Gregory Petrosyan <pgregory@pgregory.net>
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at https://mozilla.org/MPL/2.0/.
6
7use std::{path::PathBuf, sync::Arc};
8
9use crate::types;
10
11pub struct File {
12    pub source: PathBuf,
13    pub content: Arc<str>, // for updates, empty in case of deleted file
14}
15
16pub struct Package {
17    pub source: PathBuf,
18    pub path: types::ImportPath,
19    pub files: Vec<File>,
20}
21
22pub struct Module {
23    pub source: PathBuf,
24    pub manifest: ModuleManifest,
25    pub packages: Vec<Package>,
26}
27
28pub struct PackageUpdate {
29    pub source: PathBuf,
30    pub path: types::ImportPath,
31    pub files: Vec<File>,
32    pub update: PackageUpdateKind,
33}
34
35pub enum PackageUpdateKind {
36    PackageAdded,
37    PackageRemoved,
38    PackageUpdated,
39}
40
41#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug)]
42pub struct ModuleManifest {
43    pub module: types::ImportPath,
44    pub fennec: types::FennecVersion,
45}
46
47pub struct ModuleUpdate {
48    pub source: PathBuf,
49    pub module: types::ImportPath,        // same as manifest.module
50    pub manifest: Option<ModuleManifest>, // empty in case of no changes to the manifest or module was removed
51    pub packages: Vec<PackageUpdate>, // empty in case of no changes to the packages or module was removed
52    pub update: ModuleUpdateKind,
53}
54
55pub enum ModuleUpdateKind {
56    ModuleAdded,
57    ModuleRemoved,
58    ModuleUpdated,
59}