Trait Query

Source
pub trait Query {
    type Input<'p>: Param;
    type Output: ResultSet;

    // Required method
    fn format_sql(&self, formatter: &mut Formatter<'_>) -> Result;

    // Provided method
    fn display_sql(&self) -> SqlDisplay<&Self> { ... }
}
Expand description

Describes the input (parameter) and output (relation/row/tuple) types of a query, as well as its actual SQL source text.

Consult the official SQLite documentation on the supported queries for an in-depth explanation of the precise SQL understood by SQLite.

Required Associated Types§

Source

type Input<'p>: Param

The parameter type of the query. This must be either of the following:

  • a scalar (integer, floating-point number, string, blob, or null/unit);
  • an ordered tuple (or tuple struct) of scalars;
  • a struct with named fields of scalar type;
  • a map with string-like keys and scalar values;
  • or a newtype or anything that implements Param like any of the items above.

The lifetime parameter allows the implementor to use a type containing references, so as to avoid allocations when binding strings and blobs.

Source

type Output: ResultSet

The result type returned by the query. This must be either of the following:

  • a scalar (integer, floating-point number, string, blob, or null/unit);
  • an ordered tuple (or tuple struct) of scalars;
  • a struct with named fields of scalar type;
  • a map with string-like keys and scalar values;
  • a sequence of any of the items above;
  • or a newtype or any other type that deserializes as such (via ResultSet).

Required Methods§

Source

fn format_sql(&self, formatter: &mut Formatter<'_>) -> Result

Provides the SQL source text of the query.

Provided Methods§

Source

fn display_sql(&self) -> SqlDisplay<&Self>

Returns a formatter object that displays the SQL text for this query.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<Q> Query for &Q
where Q: ?Sized + Query,

Source§

type Input<'p> = <Q as Query>::Input<'p>

Source§

type Output = <Q as Query>::Output

Source§

fn format_sql(&self, formatter: &mut Formatter<'_>) -> Result

Source§

impl<Q> Query for &mut Q
where Q: ?Sized + Query,

Source§

type Input<'p> = <Q as Query>::Input<'p>

Source§

type Output = <Q as Query>::Output

Source§

fn format_sql(&self, formatter: &mut Formatter<'_>) -> Result

Source§

impl<Q> Query for Box<Q>
where Q: ?Sized + Query,

Source§

type Input<'p> = <Q as Query>::Input<'p>

Source§

type Output = <Q as Query>::Output

Source§

fn format_sql(&self, formatter: &mut Formatter<'_>) -> Result

Implementors§

Source§

impl Query for TableIndexSpec

Source§

impl<Q: Query> Query for ExplainQueryPlan<Q>

Source§

impl<Q: Query> Query for ExplainVdbeProgram<Q>

Source§

impl<T> Query for DeleteByKey<T>
where T: Table + ResultRecord, for<'p> T::PrimaryKey<'p>: Param,

Source§

type Input<'p> = <T as Table>::PrimaryKey<'p>

Source§

type Output = Option<T>

Source§

impl<T> Query for Insert<T>
where T: Table + ResultRecord,

Source§

type Input<'p> = <T as Table>::InsertInput<'p>

Source§

type Output = Option<T>

Source§

impl<T> Query for SelectByKey<T>
where T: Table + ResultRecord, for<'p> T::PrimaryKey<'p>: Param,

Source§

type Input<'p> = <T as Table>::PrimaryKey<'p>

Source§

type Output = Option<T>

Source§

impl<T, C> Query for Select<T, C>

Source§

type Input<'p> = ()

Source§

type Output = C

Source§

impl<T: Table> Query for CreateTable<T>