pub struct File { /* private fields */ }Implementations§
Source§impl File
impl File
Sourcepub async fn into_stdio_send(
self,
offset: u64,
) -> Result<StdioSend, HandoffError<Self>>
pub async fn into_stdio_send( self, offset: u64, ) -> Result<StdioSend, HandoffError<Self>>
Consumes this handle, converting it into a standard-output or
standard-error endpoint positioned at offset.
The endpoint carries a position of its own and the cursor is kept on this side rather than in the kernel, so the position has to be stated explicitly: this handle’s own is only the right answer when the caller is the one holding it, which is not the case for anything relaying on someone else’s behalf.
The handle is consumed because two live handles onto one description would each believe a cursor the other moves. Callers that want to keep reading or writing should open the file again instead.
§Errors
Returns HandoffError, which carries the handle back. Nothing has
been surrendered when it does — most importantly on the busy path,
where operations are still in flight against the descriptor and the
caller may simply retry once they finish.
Sourcepub async fn into_stdio_recv(
self,
offset: u64,
) -> Result<StdioRecv, HandoffError<Self>>
pub async fn into_stdio_recv( self, offset: u64, ) -> Result<StdioRecv, HandoffError<Self>>
Consumes this handle, converting it into a standard-input endpoint
positioned at offset. See into_stdio_send.
Sourcepub fn read_at<'b>(
&self,
buf: &'b mut BytesMut,
offset: u64,
) -> impl Future<Output = Result<usize>> + Send + use<'b>
pub fn read_at<'b>( &self, buf: &'b mut BytesMut, offset: u64, ) -> impl Future<Output = Result<usize>> + Send + use<'b>
Reads into buf’s spare capacity starting at offset, returning the
transfer count.
Cancelling the read may leave buf empty.
Fewer bytes than the spare capacity available may be read. 0 indicates
either end-of-file or that buf had no spare capacity.
Sourcepub fn write_at(
&self,
data: Bytes,
offset: u64,
) -> impl Future<Output = Result<usize>> + Send + use<>
pub fn write_at( &self, data: Bytes, offset: u64, ) -> impl Future<Output = Result<usize>> + Send + use<>
Writes data at offset, returning the byte count.
May write less than all of data on success, but at least 1 byte unless data is empty.
Use on an append-mode handle is an error; use append there.
Sourcepub fn append(
&self,
data: Bytes,
) -> impl Future<Output = Result<(usize, u64)>> + Send + use<>
pub fn append( &self, data: Bytes, ) -> impl Future<Output = Result<(usize, u64)>> + Send + use<>
Appends data, returning the byte count and the position just past
what was written. Less data may be written than requested on success,
but at least 1 byte will be written unless data was empty.
Sourcepub fn read_at_into<'b>(
&self,
buf: &'b mut [MaybeUninit<u8>],
offset: u64,
) -> impl Future<Output = Result<usize>> + Send + use<'b>
pub fn read_at_into<'b>( &self, buf: &'b mut [MaybeUninit<u8>], offset: u64, ) -> impl Future<Output = Result<usize>> + Send + use<'b>
Reads into the possibly uninitialized `buf``, returning how many bytes at its front were filled.
Sourcepub fn write_at_from<'b>(
&self,
data: &'b [u8],
offset: u64,
) -> impl Future<Output = Result<usize>> + Send + use<'b>
pub fn write_at_from<'b>( &self, data: &'b [u8], offset: u64, ) -> impl Future<Output = Result<usize>> + Send + use<'b>
Writes data at offset from borrowed storage, returning the byte
count.
Less data may be written than requested on success, but always at least 1
byte unless data is empty.
Sourcepub async fn copy_data(
&self,
dst: &File,
src_offset: u64,
target: CopyDest,
len: Option<u64>,
mode: CopyMode,
) -> Result<CopyDataResult>
pub async fn copy_data( &self, dst: &File, src_offset: u64, target: CopyDest, len: Option<u64>, mode: CopyMode, ) -> Result<CopyDataResult>
Copies at most 2 MiB from this file into dst.
len of None copies toward end of source. A positive result may be
short for any reason; callers that want a complete operation must loop.
Zero indicates end of source (or an empty request).
Nothing is promised about physical allocation: an accelerated route may preserve holes, and the fallback does not.
Sourcepub async fn sync(&self, data: bool) -> Result<()>
pub async fn sync(&self, data: bool) -> Result<()>
Flushes the file’s written data to durable storage, returning once the device reports it committed.
data selects a data-only flush (fdatasync), which may skip metadata
the caller does not need — notably the modification time — and so can
avoid a second write to the inode. Size changes are still flushed,
since a reader could not find the data without them.
This durably places the contents. It says nothing about the directory entry naming the file, which is a separate inode and needs its own flush to survive a crash.
Sourcepub async fn fs_metadata(&self) -> Result<FsMetadata>
pub async fn fs_metadata(&self) -> Result<FsMetadata>
Returns metadata for the filesystem containing the open file.
Sourcepub async fn acl(&self, kind: AclKind, default: bool) -> Result<Option<Acl>>
pub async fn acl(&self, kind: AclKind, default: bool) -> Result<Option<Acl>>
Returns the ACL of the requested kind. For a POSIX ACL, default
selects the directory’s default ACL rather than its access ACL; it
must be false for AclKind::Nfs4.
Sourcepub async fn set_acl(
&self,
kind: AclKind,
acl: Option<&Acl>,
default: bool,
) -> Result<()>
pub async fn set_acl( &self, kind: AclKind, acl: Option<&Acl>, default: bool, ) -> Result<()>
Sets or removes the ACL of kind. acl, if present, must match
kind. default selects the POSIX default ACL, as in
acl; it must be false for AclKind::Nfs4.
Sourcepub async fn sec_desc(&self, mask: SecInfo) -> Result<SecDesc>
pub async fn sec_desc(&self, mask: SecInfo) -> Result<SecDesc>
Returns the Windows security descriptor selected by mask.
Sourcepub async fn update_sec_desc(&self, sec_desc: &SecDesc) -> Result<()>
pub async fn update_sec_desc(&self, sec_desc: &SecDesc) -> Result<()>
Replaces the Windows security descriptor.
Sourcepub async fn xattrs(
&self,
namespace: XattrNamespace<'_>,
) -> Result<Vec<XattrEntry>>
pub async fn xattrs( &self, namespace: XattrNamespace<'_>, ) -> Result<Vec<XattrEntry>>
Lists extended attributes in namespace.
Sourcepub async fn xattr(
&self,
name: &str,
namespace: Option<&str>,
) -> Result<Vec<u8>>
pub async fn xattr( &self, name: &str, namespace: Option<&str>, ) -> Result<Vec<u8>>
Reads one extended attribute.
Sourcepub async fn streams(&self) -> Result<Vec<StreamEntry>>
pub async fn streams(&self) -> Result<Vec<StreamEntry>>
Lists alternate data streams.
Sourcepub async fn set_xattr(
&self,
name: &str,
namespace: Option<&str>,
value: &[u8],
) -> Result<()>
pub async fn set_xattr( &self, name: &str, namespace: Option<&str>, value: &[u8], ) -> Result<()>
Creates or replaces an extended attribute.
Sourcepub async fn remove_xattr(
&self,
name: &str,
namespace: Option<&str>,
) -> Result<()>
pub async fn remove_xattr( &self, name: &str, namespace: Option<&str>, ) -> Result<()>
Removes an extended attribute.
Sourcepub async fn lock(
&self,
range: FileLockRange,
mode: FileLockMode,
behavior: FileLockBehavior,
) -> Result<Option<FileLock>>
pub async fn lock( &self, range: FileLockRange, mode: FileLockMode, behavior: FileLockBehavior, ) -> Result<Option<FileLock>>
Acquires a byte-range lock with the requested mode and behavior.
Sourcepub async fn try_into_std(self) -> Result<File, Self>
pub async fn try_into_std(self) -> Result<File, Self>
Converts this handle into a local standard-library file when possible.
Trait Implementations§
Source§impl AsyncWrite for File
impl AsyncWrite for File
Source§fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize>>
fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize>>
buf into the object. Read moreSource§fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
Source§fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
§fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>],
) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll<Result<usize, Error>>
poll_write, except that it writes from a slice of buffers. Read more§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
poll_write_vectored
implementation. Read moreAuto Trait Implementations§
impl !Freeze for File
impl !RefUnwindSafe for File
impl !UnwindSafe for File
impl Send for File
impl Sync for File
impl Unpin for File
impl UnsafeUnpin for File
Blanket Implementations§
§impl<R> AsyncReadExt for Rwhere
R: AsyncRead + ?Sized,
impl<R> AsyncReadExt for Rwhere
R: AsyncRead + ?Sized,
§fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self>where
Self: Unpin,
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self>where
Self: Unpin,
§fn read_buf<'a, B>(&'a mut self, buf: &'a mut B) -> ReadBuf<'a, Self, B>
fn read_buf<'a, B>(&'a mut self, buf: &'a mut B) -> ReadBuf<'a, Self, B>
§fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self>where
Self: Unpin,
fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self>where
Self: Unpin,
buf. Read more§fn read_u8(&mut self) -> ReadU8<&mut Self>where
Self: Unpin,
fn read_u8(&mut self) -> ReadU8<&mut Self>where
Self: Unpin,
§fn read_i8(&mut self) -> ReadI8<&mut Self>where
Self: Unpin,
fn read_i8(&mut self) -> ReadI8<&mut Self>where
Self: Unpin,
§fn read_u16(&mut self) -> ReadU16<&mut Self>where
Self: Unpin,
fn read_u16(&mut self) -> ReadU16<&mut Self>where
Self: Unpin,
§fn read_i16(&mut self) -> ReadI16<&mut Self>where
Self: Unpin,
fn read_i16(&mut self) -> ReadI16<&mut Self>where
Self: Unpin,
§fn read_u32(&mut self) -> ReadU32<&mut Self>where
Self: Unpin,
fn read_u32(&mut self) -> ReadU32<&mut Self>where
Self: Unpin,
§fn read_i32(&mut self) -> ReadI32<&mut Self>where
Self: Unpin,
fn read_i32(&mut self) -> ReadI32<&mut Self>where
Self: Unpin,
§fn read_u64(&mut self) -> ReadU64<&mut Self>where
Self: Unpin,
fn read_u64(&mut self) -> ReadU64<&mut Self>where
Self: Unpin,
§fn read_i64(&mut self) -> ReadI64<&mut Self>where
Self: Unpin,
fn read_i64(&mut self) -> ReadI64<&mut Self>where
Self: Unpin,
§fn read_u128(&mut self) -> ReadU128<&mut Self>where
Self: Unpin,
fn read_u128(&mut self) -> ReadU128<&mut Self>where
Self: Unpin,
§fn read_i128(&mut self) -> ReadI128<&mut Self>where
Self: Unpin,
fn read_i128(&mut self) -> ReadI128<&mut Self>where
Self: Unpin,
§fn read_f32(&mut self) -> ReadF32<&mut Self>where
Self: Unpin,
fn read_f32(&mut self) -> ReadF32<&mut Self>where
Self: Unpin,
§fn read_f64(&mut self) -> ReadF64<&mut Self>where
Self: Unpin,
fn read_f64(&mut self) -> ReadF64<&mut Self>where
Self: Unpin,
§fn read_u16_le(&mut self) -> ReadU16Le<&mut Self>where
Self: Unpin,
fn read_u16_le(&mut self) -> ReadU16Le<&mut Self>where
Self: Unpin,
§fn read_i16_le(&mut self) -> ReadI16Le<&mut Self>where
Self: Unpin,
fn read_i16_le(&mut self) -> ReadI16Le<&mut Self>where
Self: Unpin,
§fn read_u32_le(&mut self) -> ReadU32Le<&mut Self>where
Self: Unpin,
fn read_u32_le(&mut self) -> ReadU32Le<&mut Self>where
Self: Unpin,
§fn read_i32_le(&mut self) -> ReadI32Le<&mut Self>where
Self: Unpin,
fn read_i32_le(&mut self) -> ReadI32Le<&mut Self>where
Self: Unpin,
§fn read_u64_le(&mut self) -> ReadU64Le<&mut Self>where
Self: Unpin,
fn read_u64_le(&mut self) -> ReadU64Le<&mut Self>where
Self: Unpin,
§fn read_i64_le(&mut self) -> ReadI64Le<&mut Self>where
Self: Unpin,
fn read_i64_le(&mut self) -> ReadI64Le<&mut Self>where
Self: Unpin,
§fn read_u128_le(&mut self) -> ReadU128Le<&mut Self>where
Self: Unpin,
fn read_u128_le(&mut self) -> ReadU128Le<&mut Self>where
Self: Unpin,
§fn read_i128_le(&mut self) -> ReadI128Le<&mut Self>where
Self: Unpin,
fn read_i128_le(&mut self) -> ReadI128Le<&mut Self>where
Self: Unpin,
§fn read_f32_le(&mut self) -> ReadF32Le<&mut Self>where
Self: Unpin,
fn read_f32_le(&mut self) -> ReadF32Le<&mut Self>where
Self: Unpin,
§fn read_f64_le(&mut self) -> ReadF64Le<&mut Self>where
Self: Unpin,
fn read_f64_le(&mut self) -> ReadF64Le<&mut Self>where
Self: Unpin,
§fn read_to_end<'a>(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self>where
Self: Unpin,
fn read_to_end<'a>(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self>where
Self: Unpin,
buf. Read more§fn read_to_string<'a>(
&'a mut self,
dst: &'a mut String,
) -> ReadToString<'a, Self>where
Self: Unpin,
fn read_to_string<'a>(
&'a mut self,
dst: &'a mut String,
) -> ReadToString<'a, Self>where
Self: Unpin,
buf. Read more§impl<S> AsyncSeekExt for Swhere
S: AsyncSeek + ?Sized,
impl<S> AsyncSeekExt for Swhere
S: AsyncSeek + ?Sized,
§fn seek(&mut self, pos: SeekFrom) -> Seek<'_, Self>where
Self: Unpin,
fn seek(&mut self, pos: SeekFrom) -> Seek<'_, Self>where
Self: Unpin,
§fn rewind(&mut self) -> Seek<'_, Self>where
Self: Unpin,
fn rewind(&mut self) -> Seek<'_, Self>where
Self: Unpin,
§fn stream_position(&mut self) -> Seek<'_, Self>where
Self: Unpin,
fn stream_position(&mut self) -> Seek<'_, Self>where
Self: Unpin,
§impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
§fn write<'a>(&'a mut self, src: &'a [u8]) -> Write<'a, Self>where
Self: Unpin,
fn write<'a>(&'a mut self, src: &'a [u8]) -> Write<'a, Self>where
Self: Unpin,
§fn write_vectored<'a, 'b>(
&'a mut self,
bufs: &'a [IoSlice<'b>],
) -> WriteVectored<'a, 'b, Self>where
Self: Unpin,
fn write_vectored<'a, 'b>(
&'a mut self,
bufs: &'a [IoSlice<'b>],
) -> WriteVectored<'a, 'b, Self>where
Self: Unpin,
§fn write_buf<'a, B>(&'a mut self, src: &'a mut B) -> WriteBuf<'a, Self, B>
fn write_buf<'a, B>(&'a mut self, src: &'a mut B) -> WriteBuf<'a, Self, B>
§fn write_all_buf<'a, B>(
&'a mut self,
src: &'a mut B,
) -> WriteAllBuf<'a, Self, B>
fn write_all_buf<'a, B>( &'a mut self, src: &'a mut B, ) -> WriteAllBuf<'a, Self, B>
§fn write_all<'a>(&'a mut self, src: &'a [u8]) -> WriteAll<'a, Self>where
Self: Unpin,
fn write_all<'a>(&'a mut self, src: &'a [u8]) -> WriteAll<'a, Self>where
Self: Unpin,
§fn write_u8(&mut self, n: u8) -> WriteU8<&mut Self>where
Self: Unpin,
fn write_u8(&mut self, n: u8) -> WriteU8<&mut Self>where
Self: Unpin,
§fn write_i8(&mut self, n: i8) -> WriteI8<&mut Self>where
Self: Unpin,
fn write_i8(&mut self, n: i8) -> WriteI8<&mut Self>where
Self: Unpin,
§fn write_u16(&mut self, n: u16) -> WriteU16<&mut Self>where
Self: Unpin,
fn write_u16(&mut self, n: u16) -> WriteU16<&mut Self>where
Self: Unpin,
§fn write_i16(&mut self, n: i16) -> WriteI16<&mut Self>where
Self: Unpin,
fn write_i16(&mut self, n: i16) -> WriteI16<&mut Self>where
Self: Unpin,
§fn write_u32(&mut self, n: u32) -> WriteU32<&mut Self>where
Self: Unpin,
fn write_u32(&mut self, n: u32) -> WriteU32<&mut Self>where
Self: Unpin,
§fn write_i32(&mut self, n: i32) -> WriteI32<&mut Self>where
Self: Unpin,
fn write_i32(&mut self, n: i32) -> WriteI32<&mut Self>where
Self: Unpin,
§fn write_u64(&mut self, n: u64) -> WriteU64<&mut Self>where
Self: Unpin,
fn write_u64(&mut self, n: u64) -> WriteU64<&mut Self>where
Self: Unpin,
§fn write_i64(&mut self, n: i64) -> WriteI64<&mut Self>where
Self: Unpin,
fn write_i64(&mut self, n: i64) -> WriteI64<&mut Self>where
Self: Unpin,
§fn write_u128(&mut self, n: u128) -> WriteU128<&mut Self>where
Self: Unpin,
fn write_u128(&mut self, n: u128) -> WriteU128<&mut Self>where
Self: Unpin,
§fn write_i128(&mut self, n: i128) -> WriteI128<&mut Self>where
Self: Unpin,
fn write_i128(&mut self, n: i128) -> WriteI128<&mut Self>where
Self: Unpin,
§fn write_f32(&mut self, n: f32) -> WriteF32<&mut Self>where
Self: Unpin,
fn write_f32(&mut self, n: f32) -> WriteF32<&mut Self>where
Self: Unpin,
§fn write_f64(&mut self, n: f64) -> WriteF64<&mut Self>where
Self: Unpin,
fn write_f64(&mut self, n: f64) -> WriteF64<&mut Self>where
Self: Unpin,
§fn write_u16_le(&mut self, n: u16) -> WriteU16Le<&mut Self>where
Self: Unpin,
fn write_u16_le(&mut self, n: u16) -> WriteU16Le<&mut Self>where
Self: Unpin,
§fn write_i16_le(&mut self, n: i16) -> WriteI16Le<&mut Self>where
Self: Unpin,
fn write_i16_le(&mut self, n: i16) -> WriteI16Le<&mut Self>where
Self: Unpin,
§fn write_u32_le(&mut self, n: u32) -> WriteU32Le<&mut Self>where
Self: Unpin,
fn write_u32_le(&mut self, n: u32) -> WriteU32Le<&mut Self>where
Self: Unpin,
§fn write_i32_le(&mut self, n: i32) -> WriteI32Le<&mut Self>where
Self: Unpin,
fn write_i32_le(&mut self, n: i32) -> WriteI32Le<&mut Self>where
Self: Unpin,
§fn write_u64_le(&mut self, n: u64) -> WriteU64Le<&mut Self>where
Self: Unpin,
fn write_u64_le(&mut self, n: u64) -> WriteU64Le<&mut Self>where
Self: Unpin,
§fn write_i64_le(&mut self, n: i64) -> WriteI64Le<&mut Self>where
Self: Unpin,
fn write_i64_le(&mut self, n: i64) -> WriteI64Le<&mut Self>where
Self: Unpin,
§fn write_u128_le(&mut self, n: u128) -> WriteU128Le<&mut Self>where
Self: Unpin,
fn write_u128_le(&mut self, n: u128) -> WriteU128Le<&mut Self>where
Self: Unpin,
§fn write_i128_le(&mut self, n: i128) -> WriteI128Le<&mut Self>where
Self: Unpin,
fn write_i128_le(&mut self, n: i128) -> WriteI128Le<&mut Self>where
Self: Unpin,
§fn write_f32_le(&mut self, n: f32) -> WriteF32Le<&mut Self>where
Self: Unpin,
fn write_f32_le(&mut self, n: f32) -> WriteF32Le<&mut Self>where
Self: Unpin,
§fn write_f64_le(&mut self, n: f64) -> WriteF64Le<&mut Self>where
Self: Unpin,
fn write_f64_le(&mut self, n: f64) -> WriteF64Le<&mut Self>where
Self: Unpin,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more