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)orinto_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§
Required Methods§
Sourcefn into_select(self) -> Select<'columns, S, Self::Out>
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.