Skip to content

Commit

Permalink
Add Subtitle::data and deprecate Subtitle::write_to
Browse files Browse the repository at this point in the history
  • Loading branch information
bytedream committed Apr 21, 2024
1 parent d2ddd26 commit 3707f38
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/media/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,19 @@ pub struct Subtitle {
}

impl Subtitle {
#[deprecated(since = "0.10.9", note = "Use `Subtitle::data` instead")]
pub async fn write_to(self, w: &mut impl Write) -> Result<()> {
let resp = self.executor.get(self.url).request_raw(false).await?;
w.write_all(resp.as_ref()).map_err(|e| Error::Input {
message: e.to_string(),
})?;
Ok(())
}

/// Get the subtitle as bytes.
pub async fn data(&self) -> Result<Vec<u8>> {
self.executor.get(&self.url).request_raw(false).await
}
}

#[derive(Clone, Debug, Serialize, Request)]
Expand Down

0 comments on commit 3707f38

Please sign in to comment.