Struct glommio::io::ImmutableFile[][src]

pub struct ImmutableFile { /* fields omitted */ }
Expand description

A Direct I/O enabled file abstraction that can not be written to.

Glommio cannot guarantee that the file is not modified outside the process. But so long as the file is only used within Glommio, using this API guarantees that the file will never change.

This allows us to employ optimizations like caching and request coalescing. The behavior of this API upon external modifications is undefined.

It can be read sequentially by building a stream with stream_reader, or randomly through the read_at (single read) or read_many (multiple reads) APIs.

To build an ImmutableFile, use ImmutableFileBuilder.

Implementations

Returns an Option containing the path associated with this open directory, or None if there isn’t one.

Returns the size of a file, in bytes

Returns true if the [‘ImmutableFile’] represent the same file on the underlying device.

Files are considered to be the same if they live in the same file system and have the same Linux inode. Note that based on this rule a symlink is not considered to be the same file.

Files will be considered to be the same if:

  • A file is opened multiple times (different file descriptors, but same file!)
  • they are hard links.

Reads into buffer in buf from a specific position in the file.

It is not necessary to respect the O_DIRECT alignment of the file, and this API will internally convert the positions and sizes to match, at a cost.

Submit many reads and process the results in a stream-like fashion via a ReadManyResult.

This API will optimistically coalesce and deduplicate IO requests such that two overlapping or adjacent reads will result in a single IO request. This is transparent for the consumer, you will still receive individual ReadResults corresponding to what you asked for.

The first argument is an iterator of IoVec. The last two arguments control how aggressive the IO coalescing should be:

  • max_merged_buffer_size controls how large a merged IO request can be. A value of 0 disables merging completely.
  • max_read_amp is optional and defines the maximum read amplification you are comfortable with. If two read requests are separated by a distance less than this value, they will be merged. A value None disables all read amplification limitation.

It is not necessary to respect the O_DIRECT alignment of the file, and this API will internally convert the positions and sizes to match.

rename this file.

Warning: synchronous operation, will block the reactor

remove this file.

The file does not have to be closed to be removed. Removing removes the name from the filesystem but the file will still be accessible for as long as it is open.

Warning: synchronous operation, will block the reactor

Closes this ImmutableFile Note that this method returns an error if other entities hold references to the underlying file, such as read streams.

Creates a DmaStreamReaderBuilder from this ImmutableFile.

The resulting builder can be augmented with any option available to the DmaStreamReaderBuilder and used to read this file sequentially.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. 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

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

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)

recently added

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.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more