icydb_core/db/response/
paged.rs1use crate::{
7 db::{
8 diagnostics::ExecutionTrace,
9 response::{EntityResponse, Row},
10 },
11 traits::EntityKind,
12};
13
14#[derive(Debug)]
21pub struct PagedLoadExecution<E: EntityKind> {
22 response: EntityResponse<E>,
23 continuation_cursor: Option<Vec<u8>>,
24}
25
26impl<E: EntityKind> PagedLoadExecution<E> {
27 #[must_use]
29 pub const fn new(response: EntityResponse<E>, continuation_cursor: Option<Vec<u8>>) -> Self {
30 Self {
31 response,
32 continuation_cursor,
33 }
34 }
35
36 #[must_use]
38 pub const fn response(&self) -> &EntityResponse<E> {
39 &self.response
40 }
41
42 pub fn iter(&self) -> std::slice::Iter<'_, Row<E>> {
44 self.response.iter()
45 }
46
47 #[must_use]
49 pub fn continuation_cursor(&self) -> Option<&[u8]> {
50 self.continuation_cursor.as_deref()
51 }
52
53 #[must_use]
55 pub fn into_parts(self) -> (EntityResponse<E>, Option<Vec<u8>>) {
56 (self.response, self.continuation_cursor)
57 }
58}
59
60impl<'a, E: EntityKind> IntoIterator for &'a PagedLoadExecution<E> {
61 type Item = &'a Row<E>;
62 type IntoIter = std::slice::Iter<'a, Row<E>>;
63
64 fn into_iter(self) -> Self::IntoIter {
65 self.iter()
66 }
67}
68
69#[derive(Debug)]
76pub struct PagedLoadExecutionWithTrace<E: EntityKind> {
77 response: EntityResponse<E>,
78 continuation_cursor: Option<Vec<u8>>,
79 execution_trace: Option<ExecutionTrace>,
80}
81
82impl<E: EntityKind> PagedLoadExecutionWithTrace<E> {
83 #[must_use]
85 pub const fn new(
86 response: EntityResponse<E>,
87 continuation_cursor: Option<Vec<u8>>,
88 execution_trace: Option<ExecutionTrace>,
89 ) -> Self {
90 Self {
91 response,
92 continuation_cursor,
93 execution_trace,
94 }
95 }
96
97 #[must_use]
99 pub const fn response(&self) -> &EntityResponse<E> {
100 &self.response
101 }
102
103 pub fn iter(&self) -> std::slice::Iter<'_, Row<E>> {
105 self.response.iter()
106 }
107
108 #[must_use]
110 pub fn continuation_cursor(&self) -> Option<&[u8]> {
111 self.continuation_cursor.as_deref()
112 }
113
114 #[must_use]
116 pub const fn execution_trace(&self) -> Option<&ExecutionTrace> {
117 self.execution_trace.as_ref()
118 }
119
120 #[must_use]
122 pub fn into_execution(self) -> PagedLoadExecution<E> {
123 PagedLoadExecution {
124 response: self.response,
125 continuation_cursor: self.continuation_cursor,
126 }
127 }
128
129 #[must_use]
131 pub fn into_parts(self) -> (EntityResponse<E>, Option<Vec<u8>>, Option<ExecutionTrace>) {
132 (
133 self.response,
134 self.continuation_cursor,
135 self.execution_trace,
136 )
137 }
138}
139
140impl<'a, E: EntityKind> IntoIterator for &'a PagedLoadExecutionWithTrace<E> {
141 type Item = &'a Row<E>;
142 type IntoIter = std::slice::Iter<'a, Row<E>>;
143
144 fn into_iter(self) -> Self::IntoIter {
145 self.iter()
146 }
147}