Struct glommio::io::ImmutableFileBuilder[][src]

pub struct ImmutableFileBuilder<P> where
    P: AsRef<Path>, 
{ /* fields omitted */ }
Expand description

Builds a new ImmutableFile, allowing linear and random access to a Direct I/O DmaFile.

Working with an ImmutableFile happens in two steps:

  • First, all the writes are done, through the ImmutableFilePreSealSink, which has no read methods.
  • Then, after the sink is sealed, it is no longer possible to write to it

Implementations

Creates a new ImmutableFileBuilder.

If this is a new file, use build_sink to build the ImmutableFilePreSealSink stage that will allow writes until seal. In that case, the filename must not exist. However, no error happens until build_sink is attempted.

If this is an existing file that will be exclusively read, use build_existing to create an ImmutableFile directly, skipping the ImmutableFilePreSealSink stage

Define the number of buffers that will be used by the ImmutableFile during sequential access.

This number is upheld for both the sink and read phases of the ImmutableFile. Higher numbers mean more concurrency but also more memory usage.

Does not issue a sync operation when sealing the file. This is dangerous and in most cases may lead to data loss.

Please note that even for O_DIRECT files, data may still be present in your device’s internal cache until a sync happens.

This option is ignored if you are creating an ImmutableFile directly and skipping the ImmutableFilePreSealSink step

Define the buffer size that will be used by the sequential operations on this ImmutableFile

pre-allocates space in the filesystem to hold a file at least as big as the size argument.

Hint to the OS the size of increase of this file, to allow more efficient allocation of blocks.

Allocating blocks at the filesystem level turns asynchronous writes into threaded synchronous writes, as we need to first find the blocks to host the file.

If the extent is larger, that means many blocks are allocated at a time. For instance, if the extent size is 1MB, that means that only 1 out of 4 256kB writes will be turned synchronous. Combined with diligent use of fallocate we can greatly minimize context switches.

It is important not to set the extent size too big. Writes can fail otherwise if the extent can’t be allocated.

Builds an ImmutableFilePreSealSink with the properties defined by this builder.

The resulting sink can be written to until seal is called.

Builds an ImmutableFile with the properties defined by this builder.

The resulting file cannot be written to. Glommio may optimize access patterns by assuming the file is read only. Writing to this file from an external process leads to undefined behavior.

Trait Implementations

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 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