IntoSelect

Trait IntoSelect 

Source
pub trait IntoSelect<'columns, S>: Sized {
    type Out: 'static;

    // Required method
    fn into_select(self) -> Select<'columns, S, Self::Out>;
}
Expand description

This trait is implemented by everything that can be retrieved from the database.

Making a selection of values to return for each row in the result set is the final step when building queries. rust_query has many different methods of selecting.

  • First, you can specify the columns that you want directly. into_vec(&user.name) or into_vec((&user.name, some_other_expr)) Note that this method only supports tuples of size 2 (which can be nested). If you want to have more expressions, then you probably want to use one of the other methods.
  • Derive crate::Select, super useful when some of the values are aggregates.
  • Derive crate::FromExpr, choose this method if you just want (a subset of) existing columns.
  • Finally, you can implement IntoSelect manually, for maximum flexibility.

Note that you can often easily solve ownership issues by adding a reference. So for example instead of into_vec((user, &user.name)), you should use into_vec((&user, &user.name)).

Required Associated Types§

Source

type Out: 'static

The type that results from executing the Select.

Required Methods§

Source

fn into_select(self) -> Select<'columns, S, Self::Out>

This method is what tells rust-query how to turn the value into a Select.

The only way to implement this method is by constructing a different value that implements IntoSelect and then calling the IntoSelect::into_select method on that other value. The result can then be modified with Select::map.

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<'columns, S> IntoSelect<'columns, S> for ()

Source§

type Out = ()

Source§

fn into_select(self) -> Select<'columns, S, Self::Out>

Source§

impl<'columns, S, A, B> IntoSelect<'columns, S> for (A, B)
where A: IntoSelect<'columns, S>, B: IntoSelect<'columns, S>,

Source§

type Out = (<A as IntoSelect<'columns, S>>::Out, <B as IntoSelect<'columns, S>>::Out)

Source§

fn into_select(self) -> Select<'columns, S, Self::Out>

Source§

impl<'columns, S, T> IntoSelect<'columns, S> for &T
where T: IntoSelect<'columns, S> + Clone,

Source§

type Out = <T as IntoSelect<'columns, S>>::Out

Source§

fn into_select(self) -> Select<'columns, S, Self::Out>

Implementors§

Source§

impl<'columns, S, Out: 'static> IntoSelect<'columns, S> for Select<'columns, S, Out>

Source§

type Out = Out

Source§

impl<'columns, S, T> IntoSelect<'columns, S> for Expr<'columns, S, T>
where T: MyTyp,

Source§

type Out = <T as MyTyp>::Out