Trait hyper_staticfile::vfs::FileAccess
source · pub trait FileAccess: AsyncSeek + Send + Unpin + 'static {
fn poll_read(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
len: usize
) -> Poll<Result<Bytes, Error>>;
}
Expand description
Trait that implements all the necessary file access methods used for serving files.
This trait exists as an alternative to AsyncRead
that returns a Bytes
directly, potentially
eliminating a copy. Unlike AsyncRead
, this does mean the implementation is responsible for
providing the read buffer.
Required Methods§
sourcefn poll_read(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
len: usize
) -> Poll<Result<Bytes, Error>>
fn poll_read(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
len: usize
) -> Poll<Result<Bytes, Error>>
Attempts to read from the file.
If no data is available for reading, the method returns Poll::Pending
and arranges for
the current task (via cx.waker()
) to receive a notification when the object becomes
readable or is closed.
An empty Bytes
return value indicates EOF.