Skip to content

Commit

Permalink
bmap-parser: require Send bounds on traits
Browse files Browse the repository at this point in the history
Not having the Send bound on the AsyncSeekForward trait in principle
makes it easier to match. However it limits where the async copy can be
used quite a bit. In particular it means it can't be used in a
tokio::spawn, which is rather a big disadvantage.

So start Send for the trait...

Signed-off-by: Sjoerd Simons <sjoerd@collabora.com>
  • Loading branch information
sjoerdsimons committed Feb 24, 2024
1 parent 6d8d741 commit 05ac00e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions bmap-parser/src/discarder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ impl<R: AsyncRead + Unpin> AsyncRead for AsyncDiscarder<R> {
}
}

#[async_trait(?Send)]
impl<R: AsyncRead + Unpin> AsyncSeekForward for AsyncDiscarder<R> {
#[async_trait]
impl<R: AsyncRead + Unpin + Send> AsyncSeekForward for AsyncDiscarder<R> {
async fn async_seek_forward(&mut self, forward: u64) -> IOResult<()> {
let mut buf = [0; 4096];
let mut left = forward as usize;
Expand Down
4 changes: 2 additions & 2 deletions bmap-parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ impl<T: Seek> SeekForward for T {
}
}

#[async_trait(?Send)]
#[async_trait]
pub trait AsyncSeekForward {
async fn async_seek_forward(&mut self, offset: u64) -> IOResult<()>;
}

#[async_trait(?Send)]
#[async_trait]
impl<T: AsyncSeek + Unpin + Send> AsyncSeekForward for T {
async fn async_seek_forward(&mut self, forward: u64) -> IOResult<()> {
self.seek(SeekFrom::Current(forward as i64)).await?;
Expand Down

0 comments on commit 05ac00e

Please sign in to comment.