Skip to main content

VirtualTable

Trait VirtualTable 

Source
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§

Source

type Cursor: VirtualTableCursor

The cursor type for scanning this virtual table.

Required Methods§

Source

fn connect(cx: &Cx, args: &[&str]) -> Result<Self>
where Self: Sized,

Called for subsequent opens of an existing virtual table.

Source

fn best_index(&self, info: &mut IndexInfo) -> Result<()>

Inform the query planner about available indexes and their costs.

Source

fn open(&self) -> Result<Self::Cursor>

Open a new scan cursor.

Provided Methods§

Source

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).

Source

fn disconnect(&mut self, _cx: &Cx) -> Result<()>

Drop a virtual table instance (opposite of connect).

Source

fn destroy(&mut self, cx: &Cx) -> Result<()>

Called for DROP VIRTUAL TABLE — destroy backing storage.

Default delegates to disconnect.

Source

fn update(&mut self, _cx: &Cx, _args: &[SqliteValue]) -> Result<Option<i64>>

INSERT/UPDATE/DELETE on the virtual table.

  • args[0]: old rowid (None for INSERT)
  • args[1]: new rowid
  • args[2..]: column values

Returns the new rowid for INSERT, None for UPDATE/DELETE.

Default returns FrankenError::ReadOnly (read-only virtual tables).

Source

fn begin(&mut self, _cx: &Cx) -> Result<()>

Begin a virtual table transaction.

Source

fn sync_txn(&mut self, _cx: &Cx) -> Result<()>

Sync a virtual table transaction (phase 1 of 2PC).

Source

fn commit(&mut self, _cx: &Cx) -> Result<()>

Commit a virtual table transaction.

Source

fn rollback(&mut self, _cx: &Cx) -> Result<()>

Roll back a virtual table transaction.

Source

fn rename(&mut self, _cx: &Cx, _new_name: &str) -> Result<()>

Rename the virtual table.

Default returns FrankenError::Unsupported.

Source

fn savepoint(&mut self, _cx: &Cx, _n: i32) -> Result<()>

Create a savepoint at level n.

Source

fn release(&mut self, _cx: &Cx, _n: i32) -> Result<()>

Release savepoint at level n.

Source

fn rollback_to(&mut self, _cx: &Cx, _n: i32) -> Result<()>

Roll back to savepoint at level n.

Implementors§