Trait async_std::io::Seek [−][src]
Seek bytes asynchronously.
This trait is analogous to the std::io::Seek
trait, but integrates
with the asynchronous task system. In particular, the poll_seek
method, unlike Seek::seek
, will automatically queue the current task
for wakeup and return if data is not yet available, rather than blocking
the calling thread.
Required methods
pub fn poll_seek(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
pos: SeekFrom
) -> Poll<Result<u64, Error>>
[src]
self: Pin<&mut Self>,
cx: &mut Context<'_>,
pos: SeekFrom
) -> Poll<Result<u64, Error>>
Attempt to seek to an offset, in bytes, in a stream.
A seek beyond the end of a stream is allowed, but behavior is defined by the implementation.
If the seek operation completed successfully,
this method returns the new position from the start of the stream.
That position can be used later with SeekFrom::Start
.
Errors
Seeking to a negative offset is considered an error.
Implementation
This function may not return errors of kind WouldBlock
or
Interrupted
. Implementations must convert WouldBlock
into
Poll::Pending
and either internally retry or convert
Interrupted
into another error kind.
Implementations on Foreign Types
impl<'_, T> AsyncSeek for &'_ mut T where
T: AsyncSeek + Unpin + ?Sized,
[src]
T: AsyncSeek + Unpin + ?Sized,
pub fn poll_seek(
self: Pin<&mut &'_ mut T>,
cx: &mut Context<'_>,
pos: SeekFrom
) -> Poll<Result<u64, Error>>
[src]
self: Pin<&mut &'_ mut T>,
cx: &mut Context<'_>,
pos: SeekFrom
) -> Poll<Result<u64, Error>>
impl<T> AsyncSeek for Box<T, Global> where
T: AsyncSeek + Unpin + ?Sized,
[src]
T: AsyncSeek + Unpin + ?Sized,
pub fn poll_seek(
self: Pin<&mut Box<T, Global>>,
cx: &mut Context<'_>,
pos: SeekFrom
) -> Poll<Result<u64, Error>>
[src]
self: Pin<&mut Box<T, Global>>,
cx: &mut Context<'_>,
pos: SeekFrom
) -> Poll<Result<u64, Error>>
impl<T> AsyncSeek for Cursor<T> where
T: AsRef<[u8]> + Unpin,
[src]
T: AsRef<[u8]> + Unpin,
pub fn poll_seek(
self: Pin<&mut Cursor<T>>,
&mut Context<'_>,
pos: SeekFrom
) -> Poll<Result<u64, Error>>
[src]
self: Pin<&mut Cursor<T>>,
&mut Context<'_>,
pos: SeekFrom
) -> Poll<Result<u64, Error>>
impl<R> AsyncSeek for BufReader<R> where
R: AsyncSeek,
[src]
R: AsyncSeek,
pub fn poll_seek(
self: Pin<&mut BufReader<R>>,
cx: &mut Context<'_>,
pos: SeekFrom
) -> Poll<Result<u64, Error>>
[src]
self: Pin<&mut BufReader<R>>,
cx: &mut Context<'_>,
pos: SeekFrom
) -> Poll<Result<u64, Error>>
Seeks to an offset, in bytes, in the underlying reader.
The position used for seeking with SeekFrom::Current
is the position the underlying
reader would be at if the BufReader
had no internal buffer.
Seeking always discards the internal buffer, even if the seek position would otherwise fall
within it. This guarantees that calling into_inner()
immediately after a seek yields the underlying reader at the same position.
See AsyncSeek
for more details.
Note: In the edge case where you’re seeking with SeekFrom::Current(n)
where n
minus the
internal buffer length overflows an i64
, two seeks will be performed instead of one. If
the second seek returns Err
, the underlying reader will be left at the same position it
would have if you called seek()
with SeekFrom::Current(0)
.
impl<T> AsyncSeek for AssertAsync<T> where
T: Seek,
[src]
T: Seek,
pub fn poll_seek(
self: Pin<&mut AssertAsync<T>>,
&mut Context<'_>,
pos: SeekFrom
) -> Poll<Result<u64, Error>>
[src]
self: Pin<&mut AssertAsync<T>>,
&mut Context<'_>,
pos: SeekFrom
) -> Poll<Result<u64, Error>>
impl<W> AsyncSeek for BufWriter<W> where
W: AsyncWrite + AsyncSeek,
[src]
W: AsyncWrite + AsyncSeek,
pub fn poll_seek(
self: Pin<&mut BufWriter<W>>,
cx: &mut Context<'_>,
pos: SeekFrom
) -> Poll<Result<u64, Error>>
[src]
self: Pin<&mut BufWriter<W>>,
cx: &mut Context<'_>,
pos: SeekFrom
) -> Poll<Result<u64, Error>>
Seek to the offset, in bytes, in the underlying writer.
Seeking always writes out the internal buffer before seeking.
impl<T> AsyncSeek for Unblock<T> where
T: 'static + Seek + Send,
[src]
T: 'static + Seek + Send,
pub fn poll_seek(
self: Pin<&mut Unblock<T>>,
cx: &mut Context<'_>,
pos: SeekFrom
) -> Poll<Result<u64, Error>>
[src]
self: Pin<&mut Unblock<T>>,
cx: &mut Context<'_>,
pos: SeekFrom
) -> Poll<Result<u64, Error>>
Implementors
impl AsyncSeek for &File
[src]
impl AsyncSeek for File
[src]
impl<P> AsyncSeek for Pin<P> where
P: DerefMut + Unpin,
<P as Deref>::Target: AsyncSeek,
[src]
P: DerefMut + Unpin,
<P as Deref>::Target: AsyncSeek,
pub fn poll_seek(
self: Pin<&mut Pin<P>>,
cx: &mut Context<'_>,
pos: SeekFrom
) -> Poll<Result<u64, Error>>
[src]
self: Pin<&mut Pin<P>>,
cx: &mut Context<'_>,
pos: SeekFrom
) -> Poll<Result<u64, Error>>
impl<R: Seek> AsyncSeek for async_std::io::BufReader<R>
[src]
fn poll_seek(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
pos: SeekFrom
) -> Poll<Result<u64>>
[src]
self: Pin<&mut Self>,
cx: &mut Context<'_>,
pos: SeekFrom
) -> Poll<Result<u64>>
Seeks to an offset, in bytes, in the underlying reader.
The position used for seeking with SeekFrom::Current(_)
is the position the underlying
reader would be at if the BufReader
had no internal buffer.
Seeking always discards the internal buffer, even if the seek position would otherwise fall
within it. This guarantees that calling .into_inner()
immediately after a seek yields the
underlying reader at the same position.
See Seek
for more details.
Note: In the edge case where you’re seeking with SeekFrom::Current(n)
where n
minus the
internal buffer length overflows an i64
, two seeks will be performed instead of one. If
the second seek returns Err
, the underlying reader will be left at the same position it
would have if you called seek
with SeekFrom::Current(0)
.
impl<T> AsyncSeek for async_std::io::Cursor<T> where
T: AsRef<[u8]> + Unpin,
[src]
T: AsRef<[u8]> + Unpin,