Skip to content

Commit

Permalink
Don't use async in trait.
Browse files Browse the repository at this point in the history
  • Loading branch information
lseelenbinder committed Sep 17, 2024
1 parent 63c4d7e commit 22399fb
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/async_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,18 @@ impl<B: AsyncBackend + Sync + Send, C: DirectoryCache + Sync + Send> AsyncPmTile

pub trait AsyncBackend {
/// Reads exactly `length` bytes starting at `offset`
async fn read_exact(&self, offset: usize, length: usize) -> PmtResult<Bytes> {
let data = self.read(offset, length).await?;

if data.len() == length {
Ok(data)
} else {
Err(PmtError::UnexpectedNumberOfBytesReturned(
length,
data.len(),
))
fn read_exact(&self, offset: usize, length: usize) -> impl Future<Output = PmtResult<Bytes>> {
async move {
let data = self.read(offset, length).await?;

if data.len() == length {
Ok(data)
} else {
Err(PmtError::UnexpectedNumberOfBytesReturned(
length,
data.len(),
))
}
}
}

Expand Down

0 comments on commit 22399fb

Please sign in to comment.