1use crate::http;
2use crate::{Backend, Build, Error};
3
4use sipper::Straw;
5use tokio::io::AsyncWrite;
6
7#[derive(Debug, Clone, Copy, PartialEq, Eq)]
9pub enum Artifact {
10 Server,
12 Backend(Backend),
14}
15
16impl Artifact {
17 pub(crate) fn download<W: AsyncWrite + Unpin>(
18 self,
19 build: Build,
20 writer: &mut W,
21 ) -> impl Straw<(), http::Progress, Error> {
22 let release_url = build.url();
23
24 http::download(
25 match self {
26 Artifact::Server => format!("{release_url}/llama-server-{build}-{PLATFORM}.zip"),
27 Artifact::Backend(backend) => {
28 let name = match backend {
29 Backend::Cuda => "cuda",
30 Backend::Hip => "hip",
31 };
32
33 format!("{release_url}/backend-{name}-{build}-{PLATFORM}.zip")
34 }
35 },
36 writer,
37 )
38 }
39}
40
41#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
42const PLATFORM: &str = "linux-x64";
43
44#[cfg(all(target_os = "macos", target_arch = "x86_64"))]
45const PLATFORM: &str = "macos-x64";
46
47#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
48const PLATFORM: &str = "macos-arm64";
49
50#[cfg(all(target_os = "windows", target_arch = "x86_64"))]
51const PLATFORM: &str = "windows-x64";