Trait Selectable

Source
pub trait Selectable {
    // Required methods
    fn filter(&self) -> Option<String>;
    fn limit(&self) -> Option<usize>;
    fn offset(&self) -> Option<usize>;
    fn order_by(&self) -> Option<String>;

    // Provided method
    fn statement(&self) -> String { ... }
}
Expand description

Definition of trait Selectable. This trait outputs filter, limit and offset statement.

Required Methods§

Source

fn filter(&self) -> Option<String>

Output filter statement - which will be appended to the WHERE clause - such as:

  • field='banana': item where the entry field is equal to 'banana';
  • 1=0: return no items;
  • 1=1: return all items;

Return None if no filtering is requested.

Source

fn limit(&self) -> Option<usize>

Output limit statement - which will be appended to the LIMIT clause - such as:

  • 10: returns only 10 entries

Return None if no limit is requested.

Source

fn offset(&self) -> Option<usize>

Output offset statement - which will be appended to the OFFSET clause - such as:

  • 5: skip the first 5 entry

Return None if no offset is requested.

Source

fn order_by(&self) -> Option<String>

Output order by statement - which will be appended to the ORDER BY clause - such as:

  • name DESC: order by descending name

Return None if no order is requested

Provided Methods§

Source

fn statement(&self) -> String

Implementors§