Struct d4_framefile::RandFile[][src]

pub struct RandFile<'a, Mode: AccessMode, T: 'a> { /* fields omitted */ }
Expand description

The file object that supports random access. Since in D4 file, we actually use a random access file mode, which means all the read and write should provide the address. And this is the object that provides the low level random access interface.

At the same time, this RandFile object is synchronized, which means we guarantee the thread safety that each block of data is written to file correctly.

The type parameter Mode is served as a type marker that identify the ability of this file.

The rand file provides a offset-based file access API and data can be read and write from the specified address in blocks. But rand file itself doesn’t tracking the block size and it’s the upper layer’s responsibility to determine the correct block beginning.

Implementations

The convenient helper function to create a read-only random file

  • inner: The underlying implementation for this backend

The convenient helper function to create a read-write random file

  • inner: The underlying implementation for this backend

Append a block to the random accessing file the return value is the relative address compare to the last accessed block.

  • buf: The data buffer that needs to be write
  • returns: The absolute address of the block that has been written to the file.

Update a data block with the given data buffer.

  • offset: The offset of the data block
  • buf: The data buffer to write

Reserve some space in the rand file. This is useful when we want to reserve a data block for future use. This is very useful for some volatile data (for example the directory block), etc. And later, we are able to use update_block function to keep the reserved block up-to-dated

Read a block from the random accessing file the size of the buffer slice is equal to the number of bytes that is requesting But there might not be enough bytes available for read, thus we always return the actual number of bytes is loaded

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Executes the destructor for this type. 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.

Performs the conversion.

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.