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 writereturns
: 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 blockbuf
: 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
Auto Trait Implementations
impl<'a, Mode, T> RefUnwindSafe for RandFile<'a, Mode, T> where
Mode: RefUnwindSafe,
impl<'a, Mode, T> UnwindSafe for RandFile<'a, Mode, T> where
Mode: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more