pub struct SyncFile { /* private fields */ }
Expand description

A file wrapper that is safe to use concurrently.

This wrapper exists because std::fs::File uses a single cursor, so reading from a file concurrently will likely produce race conditions.

SyncFiles are cheap to clone and clones use distinct cursors, so they can be used concurrently without issues.

Implementations

Attempts to open a file in read-only mode.

See File::open for details.

Opens a file in write-only mode.

See File::create for details.

Returns the offset used when reading the file.

This is equivalent to io::Seek::stream_position but does not use a fallible API nor require a mutable reference.

Methods from Deref<Target = RandomAccessFile>

Attempts to sync all OS-internal metadata to disk.

See File::sync_all for details.

This function is similar to sync_all, except that it may not synchronize file metadata to the filesystem.

See File::sync_data for details.

Truncates or extends the underlying file, updating the size of this file to become size.

See File::set_len for details.

Queries metadata about the underlying file.

See File::metadata for details.

Changes the permissions on the underlying file.

See File::set_permissions for details.

Trait Implementations

Extracts the raw handle. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Creates a new SyncFile from an open File.

The cursor starts at the beginning of the file.

Creates a new SyncFile from an open RandomAccessFile.

The cursor starts at the beginning of the file.

Constructs a new I/O object from the specified raw handle. Read more

Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more

Read the exact number of bytes required to fill buf. Read more

Like read, except that it reads into a slice of buffers. Read more

🔬 This is a nightly-only experimental API. (can_vector)

Determines if this Reader has an efficient read_vectored implementation. Read more

Read all bytes until EOF in this source, placing them into buf. Read more

Read all bytes until EOF in this source, appending them to buf. Read more

🔬 This is a nightly-only experimental API. (read_buf)

Pull some bytes from this source into the specified buffer. Read more

🔬 This is a nightly-only experimental API. (read_buf)

Read the exact number of bytes required to fill buf. Read more

Creates a “by reference” adaptor for this instance of Read. Read more

Transforms this Read instance to an Iterator over its bytes. Read more

Creates an adapter which will chain this stream with another. Read more

Creates an adapter which will read at most limit bytes from it. Read more

Reads a number of bytes starting from a given offset. Read more

Reads the exact number of byte required to fill buf from the given offset. Read more

Seek to an offset, in bytes, in a stream. Read more

Returns the current seek position from the start of the stream. Read more

Rewind to the beginning of a stream. Read more

🔬 This is a nightly-only experimental API. (seek_stream_len)

Returns the length of this stream (in bytes). Read more

Write a buffer into this writer, returning how many bytes were written. Read more

Attempts to write an entire buffer into this writer. Read more

Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more

Like write, except that it writes from a slice of buffers. Read more

🔬 This is a nightly-only experimental API. (can_vector)

Determines if this Writer has an efficient write_vectored implementation. Read more

🔬 This is a nightly-only experimental API. (write_all_vectored)

Attempts to write multiple buffers into this writer. Read more

Writes a formatted string into this writer, returning any error encountered. Read more

Creates a “by reference” adapter for this instance of Write. Read more

Writes a number of bytes starting from a given offset. Read more

Attempts to write an entire buffer starting from a given offset. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.