1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
use query_builder::AsQuery;
use query_source::QuerySource;

/// Sets the offset clause of a query. If there was already a offset clause, it
/// will be overridden. This is automatically implemented for the various query
/// builder types.
pub trait OffsetDsl: AsQuery {
    type Output: AsQuery<SqlType=Self::SqlType>;

    fn offset(self, offset: i64) -> Self::Output;
}

impl<T, ST> OffsetDsl for T where
    T: QuerySource + AsQuery<SqlType=ST>,
    T::Query: OffsetDsl<SqlType=ST>,
{
    type Output = <T::Query as OffsetDsl>::Output;

    fn offset(self, offset: i64) -> Self::Output {
        self.as_query().offset(offset)
    }
}