Skip to main content

diesel/query_builder/
limit_offset_clause.rs

1use super::QueryFragment;
2use crate::query_builder::QueryId;
3use alloc::boxed::Box;
4use alloc::sync::Arc;
5
6/// A helper query node that contains both limit and offset clauses
7///
8/// This type is only relevant for implementing custom backends
9#[derive(#[automatically_derived]
impl<Limit: ::core::fmt::Debug, Offset: ::core::fmt::Debug> ::core::fmt::Debug
    for LimitOffsetClause<Limit, Offset> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "LimitOffsetClause", "limit_clause", &self.limit_clause,
            "offset_clause", &&self.offset_clause)
    }
}Debug, #[automatically_derived]
impl<Limit: ::core::clone::Clone, Offset: ::core::clone::Clone>
    ::core::clone::Clone for LimitOffsetClause<Limit, Offset> {
    #[inline]
    fn clone(&self) -> LimitOffsetClause<Limit, Offset> {
        LimitOffsetClause {
            limit_clause: ::core::clone::Clone::clone(&self.limit_clause),
            offset_clause: ::core::clone::Clone::clone(&self.offset_clause),
        }
    }
}Clone, #[automatically_derived]
impl<Limit: ::core::marker::Copy, Offset: ::core::marker::Copy>
    ::core::marker::Copy for LimitOffsetClause<Limit, Offset> {
}Copy, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl<Limit: diesel::query_builder::QueryId,
            Offset: diesel::query_builder::QueryId>
            diesel::query_builder::QueryId for
            LimitOffsetClause<Limit, Offset> {
            type QueryId =
                LimitOffsetClause<<Limit as
                diesel::query_builder::QueryId>::QueryId,
                <Offset as diesel::query_builder::QueryId>::QueryId>;
            const HAS_STATIC_QUERY_ID: bool =
                <Limit as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID
                        &&
                        <Offset as
                            diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                    true;
            const IS_WINDOW_FUNCTION: bool =
                <Limit as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION
                        ||
                        <Offset as
                            diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                    false;
        }
    };QueryId)]
10#[cfg_attr(
11    diesel_docsrs,
12    doc(cfg(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"))
13)]
14pub struct LimitOffsetClause<Limit, Offset> {
15    /// The limit clause
16    pub limit_clause: Limit,
17    /// The offset clause
18    pub offset_clause: Offset,
19}
20
21/// A boxed variant of [`LimitOffsetClause`](LimitOffsetClause)
22///
23/// This type is only relevant for implementing custom backends
24#[allow(missing_debug_implementations)]
25#[cfg_attr(
26    diesel_docsrs,
27    doc(cfg(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"))
28)]
29pub struct BoxedLimitOffsetClause<'a, DB> {
30    /// The limit clause
31    pub limit: Option<Box<dyn QueryFragment<DB> + Send + 'a>>,
32    /// The offset clause
33    pub offset: Option<Box<dyn QueryFragment<DB> + Send + 'a>>,
34}
35
36/// A cloneable boxed variant of [`LimitOffsetClause`](LimitOffsetClause)
37///
38/// This type is only relevant for implementing custom backends
39#[allow(missing_debug_implementations)]
40#[cfg_attr(
41    diesel_docsrs,
42    doc(cfg(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"))
43)]
44pub struct BoxedCloneLimitOffsetClause<'a, DB> {
45    /// The limit clause
46    pub limit: Option<Arc<dyn QueryFragment<DB> + Send + Sync + 'a>>,
47    /// The offset clause
48    pub offset: Option<Arc<dyn QueryFragment<DB> + Send + Sync + 'a>>,
49}
50
51impl<DB> Clone for BoxedCloneLimitOffsetClause<'_, DB> {
52    fn clone(&self) -> Self {
53        Self {
54            limit: self.limit.as_ref().map(Arc::clone),
55            offset: self.offset.as_ref().map(Arc::clone),
56        }
57    }
58}