use futures::TryStreamExt;
pub struct ViewerPlugin {
pub commit_sha: Option<String>,
response: reqwest::Response,
}
impl ViewerPlugin {
pub(crate) fn new(commit_sha: Option<String>, response: reqwest::Response) -> Self {
Self {
commit_sha,
response,
}
}
pub async fn chunk(&mut self) -> Result<Option<bytes::Bytes>, super::Error> {
Ok(self.response.chunk().await?)
}
pub fn bytes_stream(
self,
) -> impl futures::Stream<Item = Result<bytes::Bytes, super::Error>> {
self.response.bytes_stream().map_err(super::Error::from)
}
}