FileReader

Trait FileReader 

Source
pub trait FileReader:
    Send
    + Sync
    + HasFileId {
    // Required methods
    fn mark_for_checkpoint(&self);
    fn read_block(
        &self,
        location: BlockLocation,
    ) -> Result<Arc<FBuf>, StorageError>;
    fn get_size(&self) -> Result<u64, StorageError>;

    // Provided method
    fn read_async(
        &self,
        blocks: Vec<BlockLocation>,
        callback: Box<dyn FnOnce(Vec<Result<Arc<FBuf>, StorageError>>) + Send>,
    ) { ... }
}
Expand description

A readable file.

Required Methods§

Source

fn mark_for_checkpoint(&self)

Marks a file to be part of a checkpoint.

This is used to prevent the file from being deleted when it is dropped. This is only useful for files obtained via FileWriter::complete, because files that were opened with StorageBackend::open are never deleted on drop.

Source

fn read_block(&self, location: BlockLocation) -> Result<Arc<FBuf>, StorageError>

Reads data at location from the file. If successful, the result will be exactly the requested length; that is, this API treats read past EOF as an error.

Source

fn get_size(&self) -> Result<u64, StorageError>

Returns the file’s size in bytes.

Provided Methods§

Source

fn read_async( &self, blocks: Vec<BlockLocation>, callback: Box<dyn FnOnce(Vec<Result<Arc<FBuf>, StorageError>>) + Send>, )

Initiates an asynchronous read. When the read completes, callback will be called.

The default implementation is not actually asynchronous.

Implementors§