Add demo vfs module to vtab kvstore

This commit is contained in:
PThorpe92
2025-03-06 15:37:02 -05:00
parent 44f6054657
commit 68eca4feed
3 changed files with 66 additions and 5 deletions

View File

@@ -1,13 +1,13 @@
mod types;
mod vfs_modules;
pub use limbo_macros::{register_extension, scalar, AggregateDerive, VTabModuleDerive};
pub use limbo_macros::{register_extension, scalar, AggregateDerive, VTabModuleDerive, VfsDerive};
use std::{
fmt::Display,
os::raw::{c_char, c_void},
};
pub use types::{ResultCode, Value, ValueType};
use vfs_modules::RegisterVfsFn;
pub use vfs_modules::{VfsFileImpl, VfsImpl};
pub use vfs_modules::{VfsExtension, VfsFile, VfsFileImpl, VfsImpl};
pub type ExtResult<T> = std::result::Result<T, ResultCode>;

View File

@@ -2,7 +2,7 @@ use crate::{ExtResult, ResultCode};
use std::ffi::{c_char, c_void};
#[cfg(not(target_family = "wasm"))]
pub trait VfsExtension: Default {
pub trait VfsExtension: Default + Send + Sync {
const NAME: &'static str;
type File: VfsFile;
fn open_file(&self, path: &str, flags: i32, direct: bool) -> ExtResult<Self::File>;
@@ -23,7 +23,7 @@ pub trait VfsExtension: Default {
}
#[cfg(not(target_family = "wasm"))]
pub trait VfsFile: Sized {
pub trait VfsFile: Send + Sync {
fn lock(&mut self, _exclusive: bool) -> ExtResult<()> {
Ok(())
}