use crate::core::model::*;
use async_trait::async_trait;
use std::path::Path;
#[async_trait]
pub trait Ecosystem: Send + Sync {
fn name(&self) -> &'static str;
async fn detect(&self, path: &Path, content: Option<&str>) -> bool;
async fn read(&self, content: &str) -> miette::Result<Vec<Dependency>>;
async fn source(&self, coordinate: &Coordinate) -> miette::Result<Availability>;
fn scheme(&self) -> &dyn Scheme;
async fn write(
&self,
_content: &str,
_dependency: &Dependency,
_new_version: &Version,
) -> miette::Result<String> {
Err(miette::miette!(
"Ecosystem {} does not support writing",
self.name()
))
}
}
pub trait Scheme: Send + Sync {
fn is_newer(&self, a: &Version, b: &Version) -> bool;
fn satisfies(&self, version: &Version, constraint: &Constraint) -> bool;
}