icydb_core/db/response/
paged.rs1use crate::{
7 db::{executor::ExecutionTrace, response::Response},
8 traits::EntityKind,
9};
10
11#[derive(Debug)]
18pub struct PagedLoadExecution<E: EntityKind> {
19 response: Response<E>,
20 continuation_cursor: Option<Vec<u8>>,
21}
22
23impl<E: EntityKind> PagedLoadExecution<E> {
24 #[must_use]
26 pub const fn new(response: Response<E>, continuation_cursor: Option<Vec<u8>>) -> Self {
27 Self {
28 response,
29 continuation_cursor,
30 }
31 }
32
33 #[must_use]
35 pub const fn response(&self) -> &Response<E> {
36 &self.response
37 }
38
39 #[must_use]
41 pub fn continuation_cursor(&self) -> Option<&[u8]> {
42 self.continuation_cursor.as_deref()
43 }
44
45 #[must_use]
47 pub fn into_parts(self) -> (Response<E>, Option<Vec<u8>>) {
48 (self.response, self.continuation_cursor)
49 }
50}
51
52impl<E: EntityKind> From<(Response<E>, Option<Vec<u8>>)> for PagedLoadExecution<E> {
53 fn from(value: (Response<E>, Option<Vec<u8>>)) -> Self {
54 let (response, continuation_cursor) = value;
55
56 Self::new(response, continuation_cursor)
57 }
58}
59
60impl<E: EntityKind> From<PagedLoadExecution<E>> for (Response<E>, Option<Vec<u8>>) {
61 fn from(value: PagedLoadExecution<E>) -> Self {
62 value.into_parts()
63 }
64}
65
66#[derive(Debug)]
73pub struct PagedLoadExecutionWithTrace<E: EntityKind> {
74 execution: PagedLoadExecution<E>,
75 execution_trace: Option<ExecutionTrace>,
76}
77
78impl<E: EntityKind> PagedLoadExecutionWithTrace<E> {
79 #[must_use]
81 pub const fn new(
82 response: Response<E>,
83 continuation_cursor: Option<Vec<u8>>,
84 execution_trace: Option<ExecutionTrace>,
85 ) -> Self {
86 Self {
87 execution: PagedLoadExecution::new(response, continuation_cursor),
88 execution_trace,
89 }
90 }
91
92 #[must_use]
94 pub const fn execution(&self) -> &PagedLoadExecution<E> {
95 &self.execution
96 }
97
98 #[must_use]
100 pub const fn response(&self) -> &Response<E> {
101 self.execution.response()
102 }
103
104 #[must_use]
106 pub fn continuation_cursor(&self) -> Option<&[u8]> {
107 self.execution.continuation_cursor()
108 }
109
110 #[must_use]
112 pub const fn execution_trace(&self) -> Option<&ExecutionTrace> {
113 self.execution_trace.as_ref()
114 }
115
116 #[must_use]
118 pub fn into_execution(self) -> PagedLoadExecution<E> {
119 self.execution
120 }
121
122 #[must_use]
124 pub fn into_parts(self) -> (Response<E>, Option<Vec<u8>>, Option<ExecutionTrace>) {
125 let (response, continuation_cursor) = self.execution.into_parts();
126
127 (response, continuation_cursor, self.execution_trace)
128 }
129}
130
131impl<E: EntityKind> From<(Response<E>, Option<Vec<u8>>, Option<ExecutionTrace>)>
132 for PagedLoadExecutionWithTrace<E>
133{
134 fn from(value: (Response<E>, Option<Vec<u8>>, Option<ExecutionTrace>)) -> Self {
135 let (response, continuation_cursor, execution_trace) = value;
136
137 Self::new(response, continuation_cursor, execution_trace)
138 }
139}
140
141impl<E: EntityKind> From<PagedLoadExecutionWithTrace<E>>
142 for (Response<E>, Option<Vec<u8>>, Option<ExecutionTrace>)
143{
144 fn from(value: PagedLoadExecutionWithTrace<E>) -> Self {
145 value.into_parts()
146 }
147}