Move impl block to correct location

This commit is contained in:
Edward Shen 2021-07-14 14:00:02 -04:00
parent 53015e116f
commit 5338ff81a5
Signed by: edward
GPG key ID: 19182661E818369F

26
src/cache/fs.rs vendored
View file

@ -152,19 +152,6 @@ impl<R> EncryptedReader<R> {
}
}
#[async_trait]
pub trait MetadataFetch: AsyncBufRead {
async fn metadata(mut self: Pin<&mut Self>) -> Result<ImageMetadata, ()>;
}
#[async_trait]
impl<R: AsyncBufRead + Send> MetadataFetch for R {
#[inline]
async fn metadata(mut self: Pin<&mut Self>) -> Result<ImageMetadata, ()> {
MetadataFuture(self).await
}
}
impl<R: AsyncRead> AsyncRead for EncryptedReader<R> {
fn poll_read(
mut self: Pin<&mut Self>,
@ -181,6 +168,19 @@ impl<R: AsyncRead> AsyncRead for EncryptedReader<R> {
}
}
#[async_trait]
pub trait MetadataFetch: AsyncBufRead {
async fn metadata(mut self: Pin<&mut Self>) -> Result<ImageMetadata, ()>;
}
#[async_trait]
impl<R: AsyncBufRead + Send> MetadataFetch for R {
#[inline]
async fn metadata(mut self: Pin<&mut Self>) -> Result<ImageMetadata, ()> {
MetadataFuture(self).await
}
}
struct MetadataFuture<'a, R>(Pin<&'a mut R>);
impl<'a, R: AsyncBufRead> Future for MetadataFuture<'a, R> {