Skip to main content

Source

Trait Source 

Source
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 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 close(&mut self) { ... }
}

Required Methods§

Source

fn open( &mut self, connection: &Map<String, Value>, read_only: bool, ) -> Result<()>

Source

fn execute( &mut self, sql: &str, row_limit: Option<u64>, out: &mut dyn ResultSink, ) -> Result<()>

Run one statement. row_limit is a hint; the SDK enforces it either way.

Provided Methods§

Source

fn connection_fields(&self) -> Vec<ConnectionField>

Source

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.

Source

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.

Source

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.

Source

fn check(&mut self, _sql: &str) -> Result<()>

Verify without executing. Only called when the plugin advertises check.

Source

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.

Source

fn close(&mut self)

End the session cleanly (called on close and at end of input, before exiting).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§