use crate::error::Result;
use crate::ids::{ArtifactRef, ContentHash, EcosystemId, Pin, SourceId};
use crate::state::ScanVerdict;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum StoreKind {
Dirty,
Prod,
}
pub trait DepEcosystem {
fn id(&self) -> EcosystemId;
fn discover(&self, source: &SourceId) -> Result<Vec<Pin>>;
fn fetch(&self, pin: &Pin) -> Result<Vec<u8>>;
fn verify_integrity(&self, pin: &Pin, raw: &[u8]) -> Result<()>;
}
pub trait ArtifactStore {
fn put(&self, kind: StoreKind, raw: &[u8]) -> Result<ContentHash>;
fn get(&self, kind: StoreKind, hash: &ContentHash) -> Result<Vec<u8>>;
fn contains(&self, kind: StoreKind, hash: &ContentHash) -> Result<bool>;
}
pub trait MetadataStore {
fn record_verdict(&self, artifact: &ArtifactRef, verdict: &ScanVerdict) -> Result<()>;
fn verdict(&self, artifact: &ArtifactRef) -> Result<Option<ScanVerdict>>;
}