mirror of
https://codeberg.org/demostf/api-client.git
synced 2026-06-03 16:44:09 +02:00
add demo downloading
This commit is contained in:
parent
a5e906fac8
commit
bdd8ec590a
2 changed files with 18 additions and 1 deletions
15
src/lib.rs
15
src/lib.rs
|
|
@ -1,3 +1,5 @@
|
|||
use bytes::Bytes;
|
||||
use futures_util::{Stream, StreamExt};
|
||||
use reqwest::{multipart, Client, IntoUrl, StatusCode, Url};
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
use std::borrow::Cow;
|
||||
|
|
@ -64,6 +66,19 @@ impl Demo {
|
|||
Ok(Cow::Owned(demo.players))
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn download(
|
||||
&self,
|
||||
client: &ApiClient,
|
||||
) -> Result<impl Stream<Item = Result<Bytes, Error>>, Error> {
|
||||
Ok(client
|
||||
.client
|
||||
.get(&self.url)
|
||||
.send()
|
||||
.await?
|
||||
.bytes_stream()
|
||||
.map(|chunk| Ok(chunk?)))
|
||||
}
|
||||
}
|
||||
|
||||
/// Reference to a user, either contains the full user information or only the user id
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue