Most of the refactor. Need to switch machines.

This commit is contained in:
Olivia Brooks
2026-02-15 09:36:04 -05:00
parent dda863e512
commit e41d4bcd76
61 changed files with 3390 additions and 618 deletions

View File

@@ -0,0 +1,43 @@
use semver::Version;
use serde::{Deserialize, Serialize};
use crate::package::PackageHandler;
/// Data struct
#[derive(Debug, Clone, Deserialize, Serialize, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub struct Dependency {
name: String,
version: Version,
pub checksum: String,
#[serde(skip_serializing_if = "<Option<_>>::is_none")]
source: Option<String>, // Path / URL
}
impl Dependency {
/// Returns a path to the dependency in local storage
/// if there is one.
pub fn local_path(&self) -> String {
if self.source.as_ref().is_some_and(|path| !is_url(path)) {
return self.source.clone().unwrap();
}
// TODO: Convert from reverse domain name to path.
return self.name.clone();
}
}
impl From<PackageHandler> for Dependency {
fn from(value: PackageHandler) -> Self {
Dependency {
name: value.name(),
version: value.version(),
checksum: String::new(),
source: None,
}
}
}
/// TODO: This is just a placeholder at present.
fn is_url<S: ToString>(path: S) -> bool {
return false;
}