diesel/pg/query_builder/
limit_offset.rs1use crate::pg::Pg;
2use crate::query_builder::limit_offset_clause::{BoxedLimitOffsetClause, LimitOffsetClause};
3use crate::query_builder::{AstPass, IntoBoxedClause, QueryFragment};
4use crate::result::QueryResult;
5
6impl<'a, L, O> IntoBoxedClause<'a, Pg> for LimitOffsetClause<L, O>
7where
8 L: QueryFragment<Pg> + Send + 'a,
9 O: QueryFragment<Pg> + Send + 'a,
10{
11 type BoxedClause = BoxedLimitOffsetClause<'a, Pg>;
12
13 fn into_boxed(self) -> Self::BoxedClause {
14 BoxedLimitOffsetClause {
15 limit: Some(Box::new(self.limit_clause)),
16 offset: Some(Box::new(self.offset_clause)),
17 }
18 }
19}
20
21impl QueryFragment<Pg> for BoxedLimitOffsetClause<'_, Pg> {
22 fn walk_ast<'b>(&'b self, mut out: AstPass<'_, 'b, Pg>) -> QueryResult<()> {
23 if let Some(ref limit) = self.limit {
24 limit.walk_ast(out.reborrow())?;
25 }
26 if let Some(ref offset) = self.offset {
27 offset.walk_ast(out.reborrow())?;
28 }
29 Ok(())
30 }
31}
32
33impl<L, O> QueryFragment<Pg> for LimitOffsetClause<L, O>
34where
35 L: QueryFragment<Pg>,
36 O: QueryFragment<Pg>,
37{
38 fn walk_ast<'b>(&'b self, mut out: AstPass<'_, 'b, Pg>) -> QueryResult<()> {
39 self.limit_clause.walk_ast(out.reborrow())?;
40 self.offset_clause.walk_ast(out.reborrow())?;
41 Ok(())
42 }
43}