iota_graphql_rpc/
consistency.rs1use async_graphql::connection::CursorType;
6use serde::{Deserialize, Serialize};
7
8use crate::types::{
9 cursor::{JsonCursor, ScanLimited},
10 uint53::{MAX_UINT53, UInt53},
11};
12
13pub(crate) const UNAVAILABLE_CHECKPOINT_SEQUENCE_NUMBER: u64 = MAX_UINT53;
15
16#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
19pub(crate) struct ConsistentIndexCursor {
20 #[serde(rename = "i")]
21 pub ix: usize,
22 pub c: UInt53,
25}
26
27#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
31pub(crate) struct ConsistentNamedCursor {
32 #[serde(rename = "n")]
33 pub name: String,
34 pub c: UInt53,
37}
38
39pub(crate) trait Checkpointed: CursorType {
42 fn checkpoint_viewed_at(&self) -> u64;
43}
44
45impl Checkpointed for JsonCursor<ConsistentIndexCursor> {
46 fn checkpoint_viewed_at(&self) -> u64 {
47 self.c.into()
48 }
49}
50
51impl Checkpointed for JsonCursor<ConsistentNamedCursor> {
52 fn checkpoint_viewed_at(&self) -> u64 {
53 self.c.into()
54 }
55}
56
57impl ScanLimited for JsonCursor<ConsistentIndexCursor> {}
58
59impl ScanLimited for JsonCursor<ConsistentNamedCursor> {}