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§
Sourcefn mark_for_checkpoint(&self)
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.
Sourcefn read_block(&self, location: BlockLocation) -> Result<Arc<FBuf>, StorageError>
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.
Sourcefn get_size(&self) -> Result<u64, StorageError>
fn get_size(&self) -> Result<u64, StorageError>
Returns the file’s size in bytes.
Provided Methods§
Sourcefn read_async(
&self,
blocks: Vec<BlockLocation>,
callback: Box<dyn FnOnce(Vec<Result<Arc<FBuf>, StorageError>>) + Send>,
)
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.