Skip to main content

uxn_tal/fetch/
provider.rs

1use std::path::{Path, PathBuf};
2
3#[derive(Debug, Clone)]
4pub struct RepoRef {
5    pub host: String,         // "git.sr.ht" | "github.com"
6    pub owner: String,        // "~rabbits" or "rabbits"
7    pub repo: String,         // "drifblim"
8    pub branch: String,       // "main" | "master" | "HEAD"
9    pub path: Option<String>, // repo-relative file/dir (if any)
10}
11
12#[derive(Debug)]
13pub struct FetchResult {
14    pub entry_local: PathBuf, // local .tal to compile
15    pub all_files: Vec<PathBuf>,
16}
17
18pub trait Provider: Send + Sync {
19    fn parse_url(&self, url: &str) -> Option<RepoRef>;
20    fn fetch_tal_tree(
21        &self,
22        rf: &RepoRef,
23        out_root: &Path,
24    ) -> Result<FetchResult, Box<dyn std::error::Error>>;
25
26    /// Parse a git@ URL and return a RepoRef with url_git populated if this provider can handle it
27    fn parse_git_url(&self, _url: &str) -> Option<(RepoRef, String)> {
28        None // Default implementation returns None for providers that don't support git@ URLs
29    }
30}