Skip to main content

bv_core/
data.rs

1use serde::{Deserialize, Serialize};
2
3use crate::error::{BvError, Result};
4
5#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
6#[serde(rename_all = "lowercase")]
7pub enum PostDownloadAction {
8    #[default]
9    Noop,
10    Extract,
11}
12
13#[derive(Debug, Clone, Serialize, Deserialize)]
14pub struct DataEntry {
15    pub id: String,
16    pub version: String,
17    pub description: Option<String>,
18    pub source_urls: Vec<String>,
19    /// Expected SHA-256 of the downloaded file as `sha256:<hex>`.
20    pub sha256: String,
21    pub size_bytes: u64,
22    /// File format hint, e.g. `"tar"`, `"fasta_gz"`, `"raw"`.
23    pub format: String,
24    #[serde(default)]
25    pub post_download_action: PostDownloadAction,
26    pub license: Option<String>,
27}
28
29#[derive(Debug, Clone, Serialize, Deserialize)]
30pub struct DataManifest {
31    pub data: DataEntry,
32}
33
34impl DataManifest {
35    pub fn from_toml_str(s: &str) -> Result<Self> {
36        toml::from_str(s).map_err(|e| BvError::ManifestParse(e.to_string()))
37    }
38}