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::{Query, 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 {
    type Output: Query;

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

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

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