pub trait VirtualTable: Send + Sync {
type Cursor: VirtualTableCursor;
Show 15 methods
// Required methods
fn connect(cx: &Cx, args: &[&str]) -> Result<Self>
where Self: Sized;
fn best_index(&self, info: &mut IndexInfo) -> Result<()>;
fn open(&self) -> Result<Self::Cursor>;
// Provided methods
fn create(cx: &Cx, args: &[&str]) -> Result<Self>
where Self: Sized { ... }
fn disconnect(&mut self, _cx: &Cx) -> Result<()> { ... }
fn destroy(&mut self, cx: &Cx) -> Result<()> { ... }
fn update(&mut self, _cx: &Cx, _args: &[SqliteValue]) -> Result<Option<i64>> { ... }
fn begin(&mut self, _cx: &Cx) -> Result<()> { ... }
fn sync_txn(&mut self, _cx: &Cx) -> Result<()> { ... }
fn commit(&mut self, _cx: &Cx) -> Result<()> { ... }
fn rollback(&mut self, _cx: &Cx) -> Result<()> { ... }
fn rename(&mut self, _cx: &Cx, _new_name: &str) -> Result<()> { ... }
fn savepoint(&mut self, _cx: &Cx, _n: i32) -> Result<()> { ... }
fn release(&mut self, _cx: &Cx, _n: i32) -> Result<()> { ... }
fn rollback_to(&mut self, _cx: &Cx, _n: i32) -> Result<()> { ... }
}Expand description
A virtual table module.
Virtual tables expose external data sources as SQL tables. This trait covers the full lifecycle: creation, connection, scanning, mutation, and destruction.
This trait is open (user-implementable). The Sized bound on
constructor methods (create, connect) allows the trait to be used
as dyn VirtualTable<Cursor = C> for other methods.
§Default Implementations
Most methods have sensible defaults. At minimum, you must implement
connect, best_index, and open.
Required Associated Types§
Sourcetype Cursor: VirtualTableCursor
type Cursor: VirtualTableCursor
The cursor type for scanning this virtual table.
Required Methods§
Sourcefn connect(cx: &Cx, args: &[&str]) -> Result<Self>where
Self: Sized,
fn connect(cx: &Cx, args: &[&str]) -> Result<Self>where
Self: Sized,
Called for subsequent opens of an existing virtual table.
Sourcefn best_index(&self, info: &mut IndexInfo) -> Result<()>
fn best_index(&self, info: &mut IndexInfo) -> Result<()>
Inform the query planner about available indexes and their costs.
Provided Methods§
Sourcefn create(cx: &Cx, args: &[&str]) -> Result<Self>where
Self: Sized,
fn create(cx: &Cx, args: &[&str]) -> Result<Self>where
Self: Sized,
Called for CREATE VIRTUAL TABLE.
May create backing storage. Default delegates to connect
(suitable for eponymous virtual tables).
Sourcefn disconnect(&mut self, _cx: &Cx) -> Result<()>
fn disconnect(&mut self, _cx: &Cx) -> Result<()>
Drop a virtual table instance (opposite of connect).
Sourcefn destroy(&mut self, cx: &Cx) -> Result<()>
fn destroy(&mut self, cx: &Cx) -> Result<()>
Called for DROP VIRTUAL TABLE — destroy backing storage.
Default delegates to disconnect.
Sourcefn update(&mut self, _cx: &Cx, _args: &[SqliteValue]) -> Result<Option<i64>>
fn update(&mut self, _cx: &Cx, _args: &[SqliteValue]) -> Result<Option<i64>>
INSERT/UPDATE/DELETE on the virtual table.
args[0]: old rowid (Nonefor INSERT)args[1]: new rowidargs[2..]: column values
Returns the new rowid for INSERT, None for UPDATE/DELETE.
Default returns FrankenError::ReadOnly (read-only virtual tables).
Sourcefn sync_txn(&mut self, _cx: &Cx) -> Result<()>
fn sync_txn(&mut self, _cx: &Cx) -> Result<()>
Sync a virtual table transaction (phase 1 of 2PC).