diff options
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/lib.rs | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/client/src/lib.rs b/client/src/lib.rs index 39bd1fd..b208525 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -5,7 +5,7 @@ use reqwest::{ Client, }; use serde_json::json; -use std::time::Duration; +use std::{io::Write, time::Duration}; #[derive(Debug, Clone)] pub struct Instance { @@ -79,15 +79,18 @@ impl Session { .await?) } - // pub async fn node_asset(&self, id: &str, role: AssetRole) -> Result<Node> { - // Ok(self - // .client - // .get(format!("/n/{id}")) - // .send() - // .await? - // .bytes() - // .await?) - // } + // TODO use AssetRole instead of str + pub async fn node_asset(&self, id: &str, role: &str, mut writer: impl Write) -> Result<()> { + let mut r = self + .client + .get(format!("{}/n/{id}/asset?role={role}", self.instance.base())) + .send() + .await?; + while let Some(chunk) = r.chunk().await? { + writer.write_all(&chunk)?; + } + Ok(()) + } pub fn stream(&self, id: &str, tracks: &[usize], webm: bool) -> String { format!( |