Skip to content

Commit 34d3eb9

Browse files
committed
fix and improve docs of AsyncSeekForward
1 parent 1298ad1 commit 34d3eb9

File tree

1 file changed

+14
-12
lines changed
  • crates/bevy_asset/src/io

1 file changed

+14
-12
lines changed

crates/bevy_asset/src/io/mod.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,23 +83,25 @@ pub use stackfuture::StackFuture;
8383

8484
/// Asynchronously advances the cursor position by a specified number of bytes.
8585
///
86-
/// This trait is similar to the `futures_io::AsyncSeek` trait, but it only supports
87-
/// the `SeekFrom::Current` variant, allowing for relative seeking from the current cursor position.
86+
/// This trait is a simplified version of the [`futures_io::AsyncSeek`] trait, providing
87+
/// support exclusively for the [`futures_io::SeekFrom::Current`] variant. It allows for relative
88+
/// seeking from the current cursor position.
8889
pub trait AsyncSeekForward {
89-
/// Attempt to seek to an offset, in bytes, in a stream from the current cursor position.
90+
/// Attempts to asynchronously seek forward by a specified number of bytes from the current cursor position.
9091
///
91-
/// A seek beyond the end of a stream is allowed, but behavior is defined
92-
/// by the implementation.
92+
/// Seeking beyond the end of the stream is allowed and the behavior for this case is defined by the implementation.
93+
/// The new position, relative to the beginning of the stream, should be returned upon successful completion
94+
/// of the seek operation.
9395
///
94-
/// If the seek operation completed successfully,
95-
/// this method returns the new position from the start of the stream.
96+
/// If the seek operation completes successfully,
97+
/// the new position relative to the beginning of the stream should be returned.
9698
///
9799
/// # Implementation
98100
///
99-
/// This function may not return errors of kind `WouldBlock` or
100-
/// `Interrupted`. Implementations must convert `WouldBlock` into
101-
/// `Poll::Pending` and either internally retry or convert
102-
/// `Interrupted` into another error kind.
101+
/// Implementations of this trait should handle [`Poll::Pending`] correctly, converting
102+
/// [`std::io::ErrorKind::WouldBlock`] errors into [`Poll::Pending`] to indicate that the operation is not
103+
/// yet complete and should be retried, and either internally retry or convert
104+
/// [`std::io::ErrorKind::Interrupted`] into another error kind.
103105
fn poll_seek_forward(
104106
self: Pin<&mut Self>,
105107
cx: &mut Context<'_>,
@@ -120,7 +122,7 @@ impl<T: ?Sized + AsyncSeekForward + Unpin> AsyncSeekForward for Box<T> {
120122
/// A type returned from [`AssetReader::read`], which is used to read the contents of a file
121123
/// (or virtual file) corresponding to an asset.
122124
///
123-
/// This is essentially a trait alias for types implementing [`AsyncRead`] and [`AsyncForwardSeek`].
125+
/// This is essentially a trait alias for types implementing [`AsyncRead`] and [`AsyncSeekForward`].
124126
/// The only reason a blanket implementation is not provided for applicable types is to allow
125127
/// implementors to override the provided implementation of [`Reader::read_to_end`].
126128
pub trait Reader: AsyncRead + AsyncSeekForward + Unpin + Send + Sync {

0 commit comments

Comments
 (0)