xmtp_proto/types/
cursor.rs1use serde::{Deserialize, Serialize};
3
4use super::SequenceId;
5use crate::backend_v1;
6
7#[derive(
9 Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize,
10)]
11pub struct Cursor(pub SequenceId);
12
13impl From<backend_v1::Cursor> for Cursor {
14 fn from(value: backend_v1::Cursor) -> Self {
15 Self(value.sequence_id)
16 }
17}
18
19impl From<Cursor> for backend_v1::Cursor {
20 fn from(value: Cursor) -> Self {
21 Self {
22 sequence_id: value.0,
23 }
24 }
25}
26
27impl std::fmt::Display for Cursor {
28 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
29 self.0.fmt(f)
30 }
31}
32
33#[cfg(any(test, feature = "test-utils"))]
34impl xmtp_common::Generate for Cursor {
35 fn generate() -> Self {
36 Self(xmtp_common::rand_u64())
37 }
38}