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    Decompress,
12}
13
14#[derive(Debug, Clone, Serialize, Deserialize)]
15pub struct DataEntry {
16    pub id: String,
17    pub version: String,
18    pub description: Option<String>,
19    pub source_urls: Vec<String>,
20    /// Expected SHA-256 of the primary downloaded file as `sha256:<hex>`.
21    pub sha256: String,
22    pub size_bytes: u64,
23    /// File format hint, e.g. `"tar"`, `"fasta_gz"`, `"raw"`.
24    pub format: String,
25    #[serde(default)]
26    pub post_download_action: PostDownloadAction,
27    pub license: Option<String>,
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
31pub struct DataManifest {
32    pub data: DataEntry,
33}
34
35impl DataManifest {
36    pub fn from_toml_str(s: &str) -> Result<Self> {
37        toml::from_str(s).map_err(|e| BvError::ManifestParse(e.to_string()))
38    }
39}