1#![doc(html_logo_url = "https://codemp.dev/logo-round.png")]
7
8#[allow(non_snake_case)]
10pub mod common {
11 tonic::include_proto!("common");
12
13 impl From<uuid::Uuid> for Identity {
14 fn from(id: uuid::Uuid) -> Self {
15 let (hi, lo) = id.as_u64_pair();
16 Identity { hi, lo }
17 }
18 }
19
20 impl From<&uuid::Uuid> for Identity {
21 fn from(id: &uuid::Uuid) -> Self {
22 let (hi, lo) = id.as_u64_pair();
23 Identity { hi, lo }
24 }
25 }
26
27 impl From<Identity> for uuid::Uuid {
28 fn from(value: Identity) -> Self {
29 uuid::Uuid::from_u64_pair(value.hi, value.lo)
30 }
31 }
32
33 impl From<&Identity> for uuid::Uuid {
34 fn from(value: &Identity) -> Self {
35 uuid::Uuid::from_u64_pair(value.hi, value.lo)
36 }
37 }
38
39 impl Identity {
40 pub fn uuid(&self) -> uuid::Uuid {
41 uuid::Uuid::from(self)
42 }
43 }
44}
45
46pub mod files {
48 tonic::include_proto!("files");
49
50 impl From<String> for BufferNode {
51 fn from(value: String) -> Self {
52 BufferNode { path: value }
53 }
54 }
55
56 impl From<&str> for BufferNode {
57 fn from(value: &str) -> Self {
58 BufferNode {
59 path: value.to_string(),
60 }
61 }
62 }
63
64 impl From<BufferNode> for String {
65 fn from(value: BufferNode) -> Self {
66 value.path
67 }
68 }
69}
70
71pub mod buffer {
73 tonic::include_proto!("buffer");
74}
75
76pub mod cursor {
78 tonic::include_proto!("cursor");
79
80 impl From<RowCol> for (i32, i32) {
81 fn from(pos: RowCol) -> (i32, i32) {
82 (pos.row, pos.col)
83 }
84 }
85
86 impl From<(i32, i32)> for RowCol {
87 fn from((row, col): (i32, i32)) -> Self {
88 RowCol { row, col }
89 }
90 }
91
92 impl PartialOrd for RowCol {
93 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
94 match self.row.partial_cmp(&other.row) {
95 Some(core::cmp::Ordering::Equal) => {}
96 ord => return ord,
97 }
98 self.col.partial_cmp(&other.col)
99 }
100 }
101}
102
103pub mod workspace {
105 tonic::include_proto!("workspace");
106}
107
108pub mod session {
110 tonic::include_proto!("session");
111}
112
113pub mod auth {
115 tonic::include_proto!("auth");
116}