Skip to main content

Vfs

Trait Vfs 

Source
pub trait Vfs: Send + Sync {
    type Handle: VfsHandle;

Show 22 methods // Required methods fn open( &self, path: Option<&str>, opts: OpenOpts, ) -> VfsResult<Self::Handle>; fn delete(&self, path: &str) -> VfsResult<()>; fn access(&self, path: &str, flags: AccessFlags) -> VfsResult<bool>; fn file_size(&self, handle: &mut Self::Handle) -> VfsResult<usize>; fn truncate(&self, handle: &mut Self::Handle, size: usize) -> VfsResult<()>; fn write( &self, handle: &mut Self::Handle, offset: usize, data: &[u8], ) -> VfsResult<usize>; fn read( &self, handle: &mut Self::Handle, offset: usize, data: &mut [u8], ) -> VfsResult<usize>; fn lock(&self, handle: &mut Self::Handle, level: LockLevel) -> VfsResult<()>; fn unlock( &self, handle: &mut Self::Handle, level: LockLevel, ) -> VfsResult<()>; fn check_reserved_lock(&self, handle: &mut Self::Handle) -> VfsResult<bool>; fn close(&self, handle: Self::Handle) -> VfsResult<()>; // Provided methods fn canonical_path<'a>(&self, path: Cow<'a, str>) -> VfsResult<Cow<'a, str>> { ... } fn sync(&self, handle: &mut Self::Handle) -> VfsResult<()> { ... } fn pragma( &self, handle: &mut Self::Handle, pragma: Pragma<'_>, ) -> Result<Option<String>, PragmaErr> { ... } fn sector_size(&self, handle: &mut Self::Handle) -> VfsResult<i32> { ... } fn device_characteristics( &self, handle: &mut Self::Handle, ) -> VfsResult<i32> { ... } fn shm_map( &self, handle: &mut Self::Handle, region_idx: usize, region_size: usize, extend: bool, ) -> VfsResult<Option<NonNull<u8>>> { ... } fn shm_lock( &self, handle: &mut Self::Handle, offset: u32, count: u32, mode: ShmLockMode, ) -> VfsResult<()> { ... } fn shm_barrier(&self, handle: &mut Self::Handle) { ... } fn shm_unmap( &self, handle: &mut Self::Handle, delete: bool, ) -> VfsResult<()> { ... } fn fetch( &self, handle: &mut Self::Handle, offset: i64, amt: usize, ) -> VfsResult<Option<NonNull<u8>>> { ... } fn unfetch( &self, handle: &mut Self::Handle, offset: i64, ptr: *mut u8, ) -> VfsResult<()> { ... }
}

Required Associated Types§

Required Methods§

Source

fn open(&self, path: Option<&str>, opts: OpenOpts) -> VfsResult<Self::Handle>

Source

fn delete(&self, path: &str) -> VfsResult<()>

Source

fn access(&self, path: &str, flags: AccessFlags) -> VfsResult<bool>

Source

fn file_size(&self, handle: &mut Self::Handle) -> VfsResult<usize>

Source

fn truncate(&self, handle: &mut Self::Handle, size: usize) -> VfsResult<()>

Source

fn write( &self, handle: &mut Self::Handle, offset: usize, data: &[u8], ) -> VfsResult<usize>

Source

fn read( &self, handle: &mut Self::Handle, offset: usize, data: &mut [u8], ) -> VfsResult<usize>

Source

fn lock(&self, handle: &mut Self::Handle, level: LockLevel) -> VfsResult<()>

Source

fn unlock(&self, handle: &mut Self::Handle, level: LockLevel) -> VfsResult<()>

Source

fn check_reserved_lock(&self, handle: &mut Self::Handle) -> VfsResult<bool>

Source

fn close(&self, handle: Self::Handle) -> VfsResult<()>

Provided Methods§

Source

fn canonical_path<'a>(&self, path: Cow<'a, str>) -> VfsResult<Cow<'a, str>>

construct a canonical version of the given path

Source

fn sync(&self, handle: &mut Self::Handle) -> VfsResult<()>

Source

fn pragma( &self, handle: &mut Self::Handle, pragma: Pragma<'_>, ) -> Result<Option<String>, PragmaErr>

Source

fn sector_size(&self, handle: &mut Self::Handle) -> VfsResult<i32>

Source

fn device_characteristics(&self, handle: &mut Self::Handle) -> VfsResult<i32>

Source

fn shm_map( &self, handle: &mut Self::Handle, region_idx: usize, region_size: usize, extend: bool, ) -> VfsResult<Option<NonNull<u8>>>

Source

fn shm_lock( &self, handle: &mut Self::Handle, offset: u32, count: u32, mode: ShmLockMode, ) -> VfsResult<()>

Source

fn shm_barrier(&self, handle: &mut Self::Handle)

Source

fn shm_unmap(&self, handle: &mut Self::Handle, delete: bool) -> VfsResult<()>

Source

fn fetch( &self, handle: &mut Self::Handle, offset: i64, amt: usize, ) -> VfsResult<Option<NonNull<u8>>>

Memory-mapped page read (xFetch). Return a pointer to amt bytes of the file starting at offset, or Ok(None) to decline and have SQLite fall back to xRead.

The default implementation declines all mmap requests. Override this to enable memory-mapped I/O for your VFS (e.g. mmap the database file).

§Safety contract

The returned pointer must remain valid until unfetch is called with the same offset. SQLite may read from the pointer concurrently from multiple threads.

Source

fn unfetch( &self, handle: &mut Self::Handle, offset: i64, ptr: *mut u8, ) -> VfsResult<()>

Release a memory-mapped page previously returned by fetch.

If ptr is null, this is a hint that the VFS should reduce its memory-mapped footprint (SQLite calls this when shrinking mmap). The default implementation is a no-op.

Implementors§