logo
pub trait VirtualFile: 'static + Debug + Send + Write + Read + Seek + Upcastable {
    fn last_accessed(&self) -> u64;
    fn last_modified(&self) -> u64;
    fn created_time(&self) -> u64;
    fn size(&self) -> u64;
    fn set_len(&mut self, new_size: u64) -> Result<(), FsError>;
    fn unlink(&mut self) -> Result<(), FsError>;
    fn bytes_available(&self) -> Result<usize, FsError>;

    fn sync_to_disk(&self) -> Result<(), FsError> { ... }
    fn get_fd(&self) -> Option<FileDescriptor> { ... }
}
Expand description

This trait relies on your file closing when it goes out of scope via Drop

Required Methods

the last time the file was accessed in nanoseconds as a UNIX timestamp

the last time the file was modified in nanoseconds as a UNIX timestamp

the time at which the file was created in nanoseconds as a UNIX timestamp

the size of the file in bytes

Change the size of the file, if the new_size is greater than the current size the extra bytes will be allocated and zeroed

Request deletion of the file

Returns the number of bytes available. This function must not block

Provided Methods

Store file contents and metadata to disk Default implementation returns Ok(()). You should implement this method if you care about flushing your cache to permanent storage

Used for polling. Default returns None because this method cannot be implemented for most types Returns the underlying host fd

Implementations

Implementors