Rename AsyncExtracter::write to feed

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-06-09 22:09:46 +10:00
parent 432376224f
commit 8a812c8d22
No known key found for this signature in database
GPG key ID: 591C0B03040416D6
2 changed files with 6 additions and 6 deletions

View file

@ -74,7 +74,7 @@ pub async fn download_and_extract<P: AsRef<Path>, const N: usize>(
let mut extracter = AsyncExtracter::new(path, fmt, desired_outputs);
while let Some(res) = bytes_stream.next().await {
extracter.write(res?).await?;
extracter.feed(res?).await?;
}
extracter.done().await?;

View file

@ -104,9 +104,9 @@ impl AsyncExtracterInner {
Ok(())
}
/// Upon error, this writer shall not be reused.
/// Upon error, this extracter shall not be reused.
/// Otherwise, `Self::done` would panic.
async fn write(&mut self, bytes: Bytes) -> Result<(), BinstallError> {
async fn feed(&mut self, bytes: Bytes) -> Result<(), BinstallError> {
if self.tx.send(Content::Data(bytes)).await.is_err() {
// task failed
Err(Self::wait(&mut self.handle).await.expect_err(
@ -193,10 +193,10 @@ impl AsyncExtracter {
Self(guard(inner, AsyncExtracterInner::abort))
}
/// Upon error, this writer shall not be reused.
/// Upon error, this extracter shall not be reused.
/// Otherwise, `Self::done` would panic.
pub async fn write(&mut self, bytes: Bytes) -> Result<(), BinstallError> {
self.0.write(bytes).await
pub async fn feed(&mut self, bytes: Bytes) -> Result<(), BinstallError> {
self.0.feed(bytes).await
}
pub async fn done(self) -> Result<(), BinstallError> {