use std::path::PathBuf;
#[derive(Debug, Clone)]
pub struct FetchOptions {
pub revision: String,
pub files: Vec<String>,
pub allow_pytorch_pickle: bool,
pub verify_sha256: Option<String>,
pub cache_dir: Option<PathBuf>,
}
impl Default for FetchOptions {
fn default() -> Self {
Self {
revision: "main".into(),
files: vec![],
allow_pytorch_pickle: false,
verify_sha256: None,
cache_dir: None,
}
}
}
impl FetchOptions {
#[must_use]
pub fn new() -> Self {
Self::default()
}
#[must_use]
pub fn revision(mut self, rev: impl Into<String>) -> Self {
self.revision = rev.into();
self
}
#[must_use]
pub fn files(mut self, files: &[&str]) -> Self {
self.files = files.iter().map(|s| (*s).to_string()).collect();
self
}
#[must_use]
pub fn allow_pytorch_pickle(mut self, allow: bool) -> Self {
self.allow_pytorch_pickle = allow;
self
}
#[must_use]
pub fn verify_sha256(mut self, hash: impl Into<String>) -> Self {
self.verify_sha256 = Some(hash.into());
self
}
#[must_use]
pub fn cache_dir(mut self, dir: impl Into<PathBuf>) -> Self {
self.cache_dir = Some(dir.into());
self
}
}