pub trait File: Send + Sync {
Show 15 methods
// Required methods
fn lock_file(&self, exclusive: bool) -> Result<()>;
fn unlock_file(&self) -> Result<()>;
fn pread(&self, pos: u64, c: Completion) -> Result<Completion>;
fn pwrite(
&self,
pos: u64,
buffer: Arc<Buffer>,
c: Completion,
) -> Result<Completion>;
fn sync(&self, c: Completion, sync_type: FileSyncType) -> Result<Completion>;
fn size(&self) -> Result<u64>;
fn truncate(&self, len: u64, c: Completion) -> Result<Completion>;
// Provided methods
fn pwritev(
&self,
pos: u64,
buffers: Vec<Arc<Buffer>>,
c: Completion,
) -> Result<Completion> { ... }
fn has_hole(&self, _pos: usize, _len: usize) -> Result<bool> { ... }
fn punch_hole(&self, _pos: usize, _len: usize) -> Result<()> { ... }
fn shared_wal_lock_byte(
&self,
_offset: u64,
_exclusive: bool,
_kind: SharedWalLockKind,
) -> Result<()> { ... }
fn shared_wal_try_lock_byte(
&self,
_offset: u64,
_exclusive: bool,
_kind: SharedWalLockKind,
) -> Result<bool> { ... }
fn shared_wal_unlock_byte(
&self,
_offset: u64,
_kind: SharedWalLockKind,
) -> Result<()> { ... }
fn shared_wal_set_len(&self, _len: u64) -> Result<()> { ... }
fn shared_wal_map(
&self,
_offset: u64,
_len: usize,
) -> Result<Box<dyn SharedWalMappedRegion>> { ... }
}Required Methods§
fn lock_file(&self, exclusive: bool) -> Result<()>
fn unlock_file(&self) -> Result<()>
fn pread(&self, pos: u64, c: Completion) -> Result<Completion>
fn pwrite( &self, pos: u64, buffer: Arc<Buffer>, c: Completion, ) -> Result<Completion>
Sourcefn sync(&self, c: Completion, sync_type: FileSyncType) -> Result<Completion>
fn sync(&self, c: Completion, sync_type: FileSyncType) -> Result<Completion>
Sync file data&metadata to disk.
fn size(&self) -> Result<u64>
fn truncate(&self, len: u64, c: Completion) -> Result<Completion>
Provided Methods§
fn pwritev( &self, pos: u64, buffers: Vec<Arc<Buffer>>, c: Completion, ) -> Result<Completion>
Sourcefn has_hole(&self, _pos: usize, _len: usize) -> Result<bool>
fn has_hole(&self, _pos: usize, _len: usize) -> Result<bool>
Optional method implemented by the IO which supports “partial” files (e.g. file with “holes”) This method is used in sync engine only for now (in partial sync mode) and never used in the core database code
The hole is the contiguous file region which is not allocated by the file-system If there is a single byte which is allocated within a given range - method must return false in this case
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".