pub trait Source {
// Required methods
fn open(
&mut self,
connection: &Map<String, Value>,
read_only: bool,
) -> Result<()>;
fn execute(
&mut self,
sql: &str,
row_limit: Option<u64>,
out: &mut dyn ResultSink,
) -> Result<()>;
// Provided methods
fn connection_fields(&self) -> Vec<ConnectionField> { ... }
fn identifier_quote(&self) -> Option<&'static str> { ... }
fn string_literal(&self) -> Option<&'static str> { ... }
fn single_writer(&self) -> Option<SingleWriter> { ... }
fn validate_connection(
&self,
_connection: &Map<String, Value>,
) -> Vec<String> { ... }
fn open_sandboxed(&mut self, connection: &Map<String, Value>) -> Result<()> { ... }
fn check(&mut self, _sql: &str) -> Result<()> { ... }
fn load(&mut self, _name: &str, _data: &mut ResultSet<'_>) -> Result<Loaded> { ... }
fn catalog(
&mut self,
_tables: &[String],
_schemas: &[String],
) -> Result<Value> { ... }
fn close(&mut self) { ... }
}Required Methods§
Provided Methods§
fn connection_fields(&self) -> Vec<ConnectionField>
Sourcefn identifier_quote(&self) -> Option<&'static str>
fn identifier_quote(&self) -> Option<&'static str>
The character the database quotes identifiers with, reported in describe: " for
most SQL databases, a backtick for Databricks and MySQL. Core doubles it inside a name.
Sourcefn string_literal(&self) -> Option<&'static str>
fn string_literal(&self) -> Option<&'static str>
How core should spell a string holding ' or \ (an inlined lookup), reported in
describe: None for chr(39)/chr(92), Some("backslash") for a database without
chr().
Sourcefn single_writer(&self) -> Option<SingleWriter>
fn single_writer(&self) -> Option<SingleWriter>
A connection field naming a file only one process may write at a time, reported in
describe (DuckDB’s path, unless :memory:): core then runs one Binding at a time on
a connection that sets it.
Sourcefn validate_connection(&self, _connection: &Map<String, Value>) -> Vec<String>
fn validate_connection(&self, _connection: &Map<String, Value>) -> Vec<String>
Rules the declared Source::connection_fields can’t express (two keys that can’t go
together, a value’s form), each a sentence naming the field, never its value. Static:
no network. Run by validate_connection and before open.
A value set through an unset env_var() arrives as null.
Sourcefn open_sandboxed(&mut self, connection: &Map<String, Value>) -> Result<()>
fn open_sandboxed(&mut self, connection: &Map<String, Value>) -> Result<()>
Open a read-only session for core’s dre query: also refuse files, programs and the
network outside the database where the engine can. Default: a read-only Source::open.
Sourcefn check(&mut self, _sql: &str) -> Result<()>
fn check(&mut self, _sql: &str) -> Result<()>
Verify without executing. Only called when the plugin advertises check.
Sourcefn load(&mut self, _name: &str, _data: &mut ResultSet<'_>) -> Result<Loaded>
fn load(&mut self, _name: &str, _data: &mut ResultSet<'_>) -> Result<Loaded>
Load data into a temporary table on the session, named after name. Only called when
the plugin advertises load.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".