1use std::{
5 fmt,
6 fmt::{Display, Formatter},
7 ops::Deref,
8};
9
10use serde::{Deserialize, Deserializer, Serialize, Serializer, de::Visitor};
11
12#[repr(transparent)]
13#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
14pub struct ColumnId(pub u64);
15
16impl ColumnId {
17 pub const REQUEST_HISTORY_TIMESTAMP: ColumnId = ColumnId(1);
19 pub const REQUEST_HISTORY_OPERATION: ColumnId = ColumnId(2);
20 pub const REQUEST_HISTORY_FINGERPRINT: ColumnId = ColumnId(3);
21 pub const REQUEST_HISTORY_TOTAL_DURATION: ColumnId = ColumnId(4);
22 pub const REQUEST_HISTORY_COMPUTE_DURATION: ColumnId = ColumnId(5);
23 pub const REQUEST_HISTORY_SUCCESS: ColumnId = ColumnId(6);
24 pub const REQUEST_HISTORY_STATEMENT_COUNT: ColumnId = ColumnId(7);
25 pub const REQUEST_HISTORY_NORMALIZED_RQL: ColumnId = ColumnId(8);
26
27 pub const STATEMENT_STATS_SNAPSHOT_TIMESTAMP: ColumnId = ColumnId(9);
29 pub const STATEMENT_STATS_FINGERPRINT: ColumnId = ColumnId(10);
30 pub const STATEMENT_STATS_NORMALIZED_RQL: ColumnId = ColumnId(11);
31 pub const STATEMENT_STATS_CALLS: ColumnId = ColumnId(12);
32 pub const STATEMENT_STATS_TOTAL_DURATION: ColumnId = ColumnId(13);
33 pub const STATEMENT_STATS_MEAN_DURATION: ColumnId = ColumnId(14);
34 pub const STATEMENT_STATS_MAX_DURATION: ColumnId = ColumnId(15);
35 pub const STATEMENT_STATS_MIN_DURATION: ColumnId = ColumnId(16);
36 pub const STATEMENT_STATS_TOTAL_ROWS: ColumnId = ColumnId(17);
37 pub const STATEMENT_STATS_ERRORS: ColumnId = ColumnId(18);
38}
39
40impl Deref for ColumnId {
41 type Target = u64;
42
43 fn deref(&self) -> &Self::Target {
44 &self.0
45 }
46}
47
48impl PartialEq<u64> for ColumnId {
49 fn eq(&self, other: &u64) -> bool {
50 self.0.eq(other)
51 }
52}
53
54impl From<ColumnId> for u64 {
55 fn from(value: ColumnId) -> Self {
56 value.0
57 }
58}
59
60impl Serialize for ColumnId {
61 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
62 where
63 S: Serializer,
64 {
65 serializer.serialize_u64(self.0)
66 }
67}
68
69impl<'de> Deserialize<'de> for ColumnId {
70 fn deserialize<D>(deserializer: D) -> Result<ColumnId, D::Error>
71 where
72 D: Deserializer<'de>,
73 {
74 struct U64Visitor;
75
76 impl Visitor<'_> for U64Visitor {
77 type Value = ColumnId;
78
79 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
80 formatter.write_str("an unsigned 64-bit number")
81 }
82
83 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
84 Ok(ColumnId(value))
85 }
86 }
87
88 deserializer.deserialize_u64(U64Visitor)
89 }
90}
91
92#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
93pub enum IndexId {
94 Primary(PrimaryKeyId),
95 }
97
98impl IndexId {
99 pub fn as_u64(&self) -> u64 {
100 match self {
101 IndexId::Primary(id) => id.0,
102 }
103 }
104
105 pub fn primary(id: impl Into<PrimaryKeyId>) -> Self {
106 IndexId::Primary(id.into())
107 }
108
109 pub fn next(&self) -> IndexId {
111 match self {
112 IndexId::Primary(primary) => IndexId::Primary(PrimaryKeyId(primary.0 + 1)), }
116 }
117
118 pub fn prev(&self) -> IndexId {
119 match self {
120 IndexId::Primary(primary) => IndexId::Primary(PrimaryKeyId(primary.0.wrapping_sub(1))),
121 }
122 }
123}
124
125impl Deref for IndexId {
126 type Target = u64;
127
128 fn deref(&self) -> &Self::Target {
129 match self {
130 IndexId::Primary(id) => &id.0,
131 }
132 }
133}
134
135impl PartialEq<u64> for IndexId {
136 fn eq(&self, other: &u64) -> bool {
137 self.as_u64().eq(other)
138 }
139}
140
141impl From<IndexId> for u64 {
142 fn from(value: IndexId) -> Self {
143 value.as_u64()
144 }
145}
146
147impl Serialize for IndexId {
148 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
149 where
150 S: Serializer,
151 {
152 serializer.serialize_u64(self.as_u64())
153 }
154}
155
156impl<'de> Deserialize<'de> for IndexId {
157 fn deserialize<D>(deserializer: D) -> Result<IndexId, D::Error>
158 where
159 D: Deserializer<'de>,
160 {
161 struct U64Visitor;
162
163 impl Visitor<'_> for U64Visitor {
164 type Value = IndexId;
165
166 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
167 formatter.write_str("an unsigned 64-bit number")
168 }
169
170 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
171 Ok(IndexId::Primary(PrimaryKeyId(value)))
173 }
174 }
175
176 deserializer.deserialize_u64(U64Visitor)
177 }
178}
179
180#[repr(transparent)]
181#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
182pub struct ColumnPropertyId(pub u64);
183
184impl Deref for ColumnPropertyId {
185 type Target = u64;
186
187 fn deref(&self) -> &Self::Target {
188 &self.0
189 }
190}
191
192impl PartialEq<u64> for ColumnPropertyId {
193 fn eq(&self, other: &u64) -> bool {
194 self.0.eq(other)
195 }
196}
197
198impl From<ColumnPropertyId> for u64 {
199 fn from(value: ColumnPropertyId) -> Self {
200 value.0
201 }
202}
203
204impl Serialize for ColumnPropertyId {
205 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
206 where
207 S: Serializer,
208 {
209 serializer.serialize_u64(self.0)
210 }
211}
212
213impl<'de> Deserialize<'de> for ColumnPropertyId {
214 fn deserialize<D>(deserializer: D) -> Result<ColumnPropertyId, D::Error>
215 where
216 D: Deserializer<'de>,
217 {
218 struct U64Visitor;
219
220 impl Visitor<'_> for U64Visitor {
221 type Value = ColumnPropertyId;
222
223 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
224 formatter.write_str("an unsigned 64-bit number")
225 }
226
227 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
228 Ok(ColumnPropertyId(value))
229 }
230 }
231
232 deserializer.deserialize_u64(U64Visitor)
233 }
234}
235
236#[repr(transparent)]
237#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
238pub struct NamespaceId(pub u64);
239
240impl Display for NamespaceId {
241 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
242 Display::fmt(&self.0, f)
243 }
244}
245
246impl Deref for NamespaceId {
247 type Target = u64;
248
249 fn deref(&self) -> &Self::Target {
250 &self.0
251 }
252}
253
254impl PartialEq<u64> for NamespaceId {
255 fn eq(&self, other: &u64) -> bool {
256 self.0.eq(other)
257 }
258}
259
260impl From<NamespaceId> for u64 {
261 fn from(value: NamespaceId) -> Self {
262 value.0
263 }
264}
265
266impl Serialize for NamespaceId {
267 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
268 where
269 S: Serializer,
270 {
271 serializer.serialize_u64(self.0)
272 }
273}
274
275impl<'de> Deserialize<'de> for NamespaceId {
276 fn deserialize<D>(deserializer: D) -> Result<NamespaceId, D::Error>
277 where
278 D: Deserializer<'de>,
279 {
280 struct U64Visitor;
281
282 impl Visitor<'_> for U64Visitor {
283 type Value = NamespaceId;
284
285 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
286 formatter.write_str("an unsigned 64-bit number")
287 }
288
289 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
290 Ok(NamespaceId(value))
291 }
292 }
293
294 deserializer.deserialize_u64(U64Visitor)
295 }
296}
297
298#[repr(transparent)]
299#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
300pub struct TableId(pub u64);
301
302impl Display for TableId {
303 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
304 Display::fmt(&self.0, f)
305 }
306}
307
308impl Deref for TableId {
309 type Target = u64;
310
311 fn deref(&self) -> &Self::Target {
312 &self.0
313 }
314}
315
316impl PartialEq<u64> for TableId {
317 fn eq(&self, other: &u64) -> bool {
318 self.0.eq(other)
319 }
320}
321
322impl From<TableId> for u64 {
323 fn from(value: TableId) -> Self {
324 value.0
325 }
326}
327
328impl TableId {
329 #[inline]
331 pub fn to_u64(self) -> u64 {
332 self.0
333 }
334}
335
336impl From<i32> for TableId {
337 fn from(value: i32) -> Self {
338 Self(value as u64)
339 }
340}
341
342impl From<u64> for TableId {
343 fn from(value: u64) -> Self {
344 Self(value)
345 }
346}
347
348impl Serialize for TableId {
349 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
350 where
351 S: Serializer,
352 {
353 serializer.serialize_u64(self.0)
354 }
355}
356
357impl<'de> Deserialize<'de> for TableId {
358 fn deserialize<D>(deserializer: D) -> Result<TableId, D::Error>
359 where
360 D: Deserializer<'de>,
361 {
362 struct U64Visitor;
363
364 impl Visitor<'_> for U64Visitor {
365 type Value = TableId;
366
367 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
368 formatter.write_str("an unsigned 64-bit number")
369 }
370
371 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
372 Ok(TableId(value))
373 }
374 }
375
376 deserializer.deserialize_u64(U64Visitor)
377 }
378}
379
380#[repr(transparent)]
381#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
382pub struct ViewId(pub u64);
383
384impl Display for ViewId {
385 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
386 Display::fmt(&self.0, f)
387 }
388}
389
390impl Deref for ViewId {
391 type Target = u64;
392
393 fn deref(&self) -> &Self::Target {
394 &self.0
395 }
396}
397
398impl PartialEq<u64> for ViewId {
399 fn eq(&self, other: &u64) -> bool {
400 self.0.eq(other)
401 }
402}
403
404impl From<ViewId> for u64 {
405 fn from(value: ViewId) -> Self {
406 value.0
407 }
408}
409
410impl ViewId {
411 #[inline]
413 pub fn to_u64(self) -> u64 {
414 self.0
415 }
416}
417
418impl From<i32> for ViewId {
419 fn from(value: i32) -> Self {
420 Self(value as u64)
421 }
422}
423
424impl From<u64> for ViewId {
425 fn from(value: u64) -> Self {
426 Self(value)
427 }
428}
429
430impl Serialize for ViewId {
431 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
432 where
433 S: Serializer,
434 {
435 serializer.serialize_u64(self.0)
436 }
437}
438
439impl<'de> Deserialize<'de> for ViewId {
440 fn deserialize<D>(deserializer: D) -> Result<ViewId, D::Error>
441 where
442 D: Deserializer<'de>,
443 {
444 struct U64Visitor;
445
446 impl Visitor<'_> for U64Visitor {
447 type Value = ViewId;
448
449 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
450 formatter.write_str("an unsigned 64-bit number")
451 }
452
453 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
454 Ok(ViewId(value))
455 }
456 }
457
458 deserializer.deserialize_u64(U64Visitor)
459 }
460}
461
462#[repr(transparent)]
463#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
464pub struct PrimaryKeyId(pub u64);
465
466impl Display for PrimaryKeyId {
467 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
468 Display::fmt(&self.0, f)
469 }
470}
471
472impl Deref for PrimaryKeyId {
473 type Target = u64;
474
475 fn deref(&self) -> &Self::Target {
476 &self.0
477 }
478}
479
480impl PartialEq<u64> for PrimaryKeyId {
481 fn eq(&self, other: &u64) -> bool {
482 self.0.eq(other)
483 }
484}
485
486impl From<PrimaryKeyId> for u64 {
487 fn from(value: PrimaryKeyId) -> Self {
488 value.0
489 }
490}
491
492impl From<i32> for PrimaryKeyId {
493 fn from(value: i32) -> Self {
494 Self(value as u64)
495 }
496}
497
498impl From<u64> for PrimaryKeyId {
499 fn from(value: u64) -> Self {
500 Self(value)
501 }
502}
503
504impl Serialize for PrimaryKeyId {
505 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
506 where
507 S: Serializer,
508 {
509 serializer.serialize_u64(self.0)
510 }
511}
512
513impl<'de> Deserialize<'de> for PrimaryKeyId {
514 fn deserialize<D>(deserializer: D) -> Result<PrimaryKeyId, D::Error>
515 where
516 D: Deserializer<'de>,
517 {
518 struct U64Visitor;
519
520 impl Visitor<'_> for U64Visitor {
521 type Value = PrimaryKeyId;
522
523 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
524 formatter.write_str("an unsigned 64-bit number")
525 }
526
527 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
528 Ok(PrimaryKeyId(value))
529 }
530 }
531
532 deserializer.deserialize_u64(U64Visitor)
533 }
534}
535
536#[repr(transparent)]
537#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
538pub struct RingBufferId(pub u64);
539
540impl RingBufferId {
541 pub const REQUEST_HISTORY: RingBufferId = RingBufferId(1);
542 pub const STATEMENT_STATS: RingBufferId = RingBufferId(2);
543}
544
545impl Display for RingBufferId {
546 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
547 Display::fmt(&self.0, f)
548 }
549}
550
551impl Deref for RingBufferId {
552 type Target = u64;
553
554 fn deref(&self) -> &Self::Target {
555 &self.0
556 }
557}
558
559impl PartialEq<u64> for RingBufferId {
560 fn eq(&self, other: &u64) -> bool {
561 self.0.eq(other)
562 }
563}
564
565impl From<RingBufferId> for u64 {
566 fn from(value: RingBufferId) -> Self {
567 value.0
568 }
569}
570
571impl RingBufferId {
572 #[inline]
574 pub fn to_u64(self) -> u64 {
575 self.0
576 }
577}
578
579impl From<i32> for RingBufferId {
580 fn from(value: i32) -> Self {
581 Self(value as u64)
582 }
583}
584
585impl From<u64> for RingBufferId {
586 fn from(value: u64) -> Self {
587 Self(value)
588 }
589}
590
591impl Serialize for RingBufferId {
592 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
593 where
594 S: Serializer,
595 {
596 serializer.serialize_u64(self.0)
597 }
598}
599
600impl<'de> Deserialize<'de> for RingBufferId {
601 fn deserialize<D>(deserializer: D) -> Result<RingBufferId, D::Error>
602 where
603 D: Deserializer<'de>,
604 {
605 struct U64Visitor;
606
607 impl Visitor<'_> for U64Visitor {
608 type Value = RingBufferId;
609
610 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
611 formatter.write_str("an unsigned 64-bit number")
612 }
613
614 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
615 Ok(RingBufferId(value))
616 }
617 }
618
619 deserializer.deserialize_u64(U64Visitor)
620 }
621}
622
623#[repr(transparent)]
624#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
625pub struct ProcedureId(u64);
626
627impl ProcedureId {
628 pub const SYSTEM_RESERVED_START: u64 = 1 << 48;
632
633 pub const SYSTEM_CONFIG_SET: ProcedureId = ProcedureId::persistent(1);
637
638 pub const fn persistent(id: u64) -> Self {
641 assert!(id < Self::SYSTEM_RESERVED_START, "persistent ProcedureId must be below SYSTEM_RESERVED_START");
642 Self(id)
643 }
644
645 pub const fn ephemeral(id: u64) -> Self {
648 assert!(
649 id >= Self::SYSTEM_RESERVED_START,
650 "ephemeral ProcedureId must be at or above SYSTEM_RESERVED_START"
651 );
652 Self(id)
653 }
654
655 pub const fn from_raw(id: u64) -> Self {
659 Self(id)
660 }
661
662 pub const fn is_ephemeral(&self) -> bool {
664 self.0 >= Self::SYSTEM_RESERVED_START
665 }
666}
667
668impl Display for ProcedureId {
669 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
670 Display::fmt(&self.0, f)
671 }
672}
673
674impl Deref for ProcedureId {
675 type Target = u64;
676
677 fn deref(&self) -> &Self::Target {
678 &self.0
679 }
680}
681
682impl PartialEq<u64> for ProcedureId {
683 fn eq(&self, other: &u64) -> bool {
684 self.0.eq(other)
685 }
686}
687
688impl From<ProcedureId> for u64 {
689 fn from(value: ProcedureId) -> Self {
690 value.0
691 }
692}
693
694impl Serialize for ProcedureId {
695 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
696 where
697 S: Serializer,
698 {
699 serializer.serialize_u64(self.0)
700 }
701}
702
703impl<'de> Deserialize<'de> for ProcedureId {
704 fn deserialize<D>(deserializer: D) -> Result<ProcedureId, D::Error>
705 where
706 D: Deserializer<'de>,
707 {
708 struct U64Visitor;
709
710 impl Visitor<'_> for U64Visitor {
711 type Value = ProcedureId;
712
713 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
714 formatter.write_str("an unsigned 64-bit number")
715 }
716
717 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
718 Ok(ProcedureId::from_raw(value))
719 }
720 }
721
722 deserializer.deserialize_u64(U64Visitor)
723 }
724}
725
726#[repr(transparent)]
727#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
728pub struct TestId(pub u64);
729
730impl Display for TestId {
731 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
732 Display::fmt(&self.0, f)
733 }
734}
735
736impl Deref for TestId {
737 type Target = u64;
738
739 fn deref(&self) -> &Self::Target {
740 &self.0
741 }
742}
743
744impl PartialEq<u64> for TestId {
745 fn eq(&self, other: &u64) -> bool {
746 self.0.eq(other)
747 }
748}
749
750impl From<TestId> for u64 {
751 fn from(value: TestId) -> Self {
752 value.0
753 }
754}
755
756impl From<i32> for TestId {
757 fn from(value: i32) -> Self {
758 Self(value as u64)
759 }
760}
761
762impl From<u64> for TestId {
763 fn from(value: u64) -> Self {
764 Self(value)
765 }
766}
767
768impl Serialize for TestId {
769 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
770 where
771 S: Serializer,
772 {
773 serializer.serialize_u64(self.0)
774 }
775}
776
777impl<'de> Deserialize<'de> for TestId {
778 fn deserialize<D>(deserializer: D) -> Result<TestId, D::Error>
779 where
780 D: Deserializer<'de>,
781 {
782 struct U64Visitor;
783
784 impl Visitor<'_> for U64Visitor {
785 type Value = TestId;
786
787 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
788 formatter.write_str("an unsigned 64-bit number")
789 }
790
791 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
792 Ok(TestId(value))
793 }
794 }
795
796 deserializer.deserialize_u64(U64Visitor)
797 }
798}
799
800#[repr(transparent)]
803#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
804pub struct SubscriptionId(pub u64);
805
806impl Display for SubscriptionId {
807 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
808 Display::fmt(&self.0, f)
809 }
810}
811
812impl Deref for SubscriptionId {
813 type Target = u64;
814
815 fn deref(&self) -> &Self::Target {
816 &self.0
817 }
818}
819
820impl PartialEq<u64> for SubscriptionId {
821 fn eq(&self, other: &u64) -> bool {
822 self.0.eq(other)
823 }
824}
825
826impl From<SubscriptionId> for u64 {
827 fn from(value: SubscriptionId) -> Self {
828 value.0
829 }
830}
831
832impl From<u64> for SubscriptionId {
833 fn from(value: u64) -> Self {
834 Self(value)
835 }
836}
837
838impl Serialize for SubscriptionId {
839 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
840 where
841 S: Serializer,
842 {
843 serializer.serialize_u64(self.0)
844 }
845}
846
847impl<'de> Deserialize<'de> for SubscriptionId {
848 fn deserialize<D>(deserializer: D) -> Result<SubscriptionId, D::Error>
849 where
850 D: Deserializer<'de>,
851 {
852 struct U64Visitor;
853
854 impl Visitor<'_> for U64Visitor {
855 type Value = SubscriptionId;
856
857 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
858 formatter.write_str("an unsigned 64-bit number")
859 }
860
861 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
862 Ok(SubscriptionId(value))
863 }
864 }
865
866 deserializer.deserialize_u64(U64Visitor)
867 }
868}
869
870#[repr(transparent)]
871#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
872pub struct SequenceId(pub u64);
873
874impl Deref for SequenceId {
875 type Target = u64;
876
877 fn deref(&self) -> &Self::Target {
878 &self.0
879 }
880}
881
882impl PartialEq<u64> for SequenceId {
883 fn eq(&self, other: &u64) -> bool {
884 self.0.eq(other)
885 }
886}
887
888impl Serialize for SequenceId {
889 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
890 where
891 S: Serializer,
892 {
893 serializer.serialize_u64(self.0)
894 }
895}
896
897impl<'de> Deserialize<'de> for SequenceId {
898 fn deserialize<D>(deserializer: D) -> Result<SequenceId, D::Error>
899 where
900 D: Deserializer<'de>,
901 {
902 struct U64Visitor;
903
904 impl Visitor<'_> for U64Visitor {
905 type Value = SequenceId;
906
907 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
908 formatter.write_str("an unsigned 64-bit number")
909 }
910
911 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
912 Ok(SequenceId(value))
913 }
914 }
915
916 deserializer.deserialize_u64(U64Visitor)
917 }
918}
919
920#[repr(transparent)]
921#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
922pub struct SubscriptionColumnId(pub u64);
923
924impl Display for SubscriptionColumnId {
925 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
926 Display::fmt(&self.0, f)
927 }
928}
929
930impl Deref for SubscriptionColumnId {
931 type Target = u64;
932
933 fn deref(&self) -> &Self::Target {
934 &self.0
935 }
936}
937
938impl PartialEq<u64> for SubscriptionColumnId {
939 fn eq(&self, other: &u64) -> bool {
940 self.0.eq(other)
941 }
942}
943
944impl From<SubscriptionColumnId> for u64 {
945 fn from(value: SubscriptionColumnId) -> Self {
946 value.0
947 }
948}
949
950impl From<i32> for SubscriptionColumnId {
951 fn from(value: i32) -> Self {
952 Self(value as u64)
953 }
954}
955
956impl From<u64> for SubscriptionColumnId {
957 fn from(value: u64) -> Self {
958 Self(value)
959 }
960}
961
962impl Serialize for SubscriptionColumnId {
963 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
964 where
965 S: Serializer,
966 {
967 serializer.serialize_u64(self.0)
968 }
969}
970
971impl<'de> Deserialize<'de> for SubscriptionColumnId {
972 fn deserialize<D>(deserializer: D) -> Result<SubscriptionColumnId, D::Error>
973 where
974 D: Deserializer<'de>,
975 {
976 struct U64Visitor;
977
978 impl Visitor<'_> for U64Visitor {
979 type Value = SubscriptionColumnId;
980
981 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
982 formatter.write_str("an unsigned 64-bit number")
983 }
984
985 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
986 Ok(SubscriptionColumnId(value))
987 }
988 }
989
990 deserializer.deserialize_u64(U64Visitor)
991 }
992}
993
994#[repr(transparent)]
995#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
996pub struct SeriesId(pub u64);
997
998impl Display for SeriesId {
999 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1000 Display::fmt(&self.0, f)
1001 }
1002}
1003
1004impl Deref for SeriesId {
1005 type Target = u64;
1006
1007 fn deref(&self) -> &Self::Target {
1008 &self.0
1009 }
1010}
1011
1012impl PartialEq<u64> for SeriesId {
1013 fn eq(&self, other: &u64) -> bool {
1014 self.0.eq(other)
1015 }
1016}
1017
1018impl From<SeriesId> for u64 {
1019 fn from(value: SeriesId) -> Self {
1020 value.0
1021 }
1022}
1023
1024impl SeriesId {
1025 #[inline]
1026 pub fn to_u64(self) -> u64 {
1027 self.0
1028 }
1029}
1030
1031impl From<i32> for SeriesId {
1032 fn from(value: i32) -> Self {
1033 Self(value as u64)
1034 }
1035}
1036
1037impl From<u64> for SeriesId {
1038 fn from(value: u64) -> Self {
1039 Self(value)
1040 }
1041}
1042
1043impl Serialize for SeriesId {
1044 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1045 where
1046 S: Serializer,
1047 {
1048 serializer.serialize_u64(self.0)
1049 }
1050}
1051
1052impl<'de> Deserialize<'de> for SeriesId {
1053 fn deserialize<D>(deserializer: D) -> Result<SeriesId, D::Error>
1054 where
1055 D: Deserializer<'de>,
1056 {
1057 struct U64Visitor;
1058
1059 impl Visitor<'_> for U64Visitor {
1060 type Value = SeriesId;
1061
1062 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1063 formatter.write_str("an unsigned 64-bit number")
1064 }
1065
1066 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1067 Ok(SeriesId(value))
1068 }
1069 }
1070
1071 deserializer.deserialize_u64(U64Visitor)
1072 }
1073}
1074
1075#[repr(transparent)]
1076#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
1077pub struct HandlerId(pub u64);
1078
1079impl Display for HandlerId {
1080 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1081 Display::fmt(&self.0, f)
1082 }
1083}
1084
1085impl Deref for HandlerId {
1086 type Target = u64;
1087
1088 fn deref(&self) -> &Self::Target {
1089 &self.0
1090 }
1091}
1092
1093impl PartialEq<u64> for HandlerId {
1094 fn eq(&self, other: &u64) -> bool {
1095 self.0.eq(other)
1096 }
1097}
1098
1099impl From<HandlerId> for u64 {
1100 fn from(value: HandlerId) -> Self {
1101 value.0
1102 }
1103}
1104
1105impl From<i32> for HandlerId {
1106 fn from(value: i32) -> Self {
1107 Self(value as u64)
1108 }
1109}
1110
1111impl From<u64> for HandlerId {
1112 fn from(value: u64) -> Self {
1113 Self(value)
1114 }
1115}
1116
1117impl Serialize for HandlerId {
1118 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1119 where
1120 S: Serializer,
1121 {
1122 serializer.serialize_u64(self.0)
1123 }
1124}
1125
1126impl<'de> Deserialize<'de> for HandlerId {
1127 fn deserialize<D>(deserializer: D) -> Result<HandlerId, D::Error>
1128 where
1129 D: Deserializer<'de>,
1130 {
1131 struct U64Visitor;
1132
1133 impl Visitor<'_> for U64Visitor {
1134 type Value = HandlerId;
1135
1136 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1137 formatter.write_str("an unsigned 64-bit number")
1138 }
1139
1140 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1141 Ok(HandlerId(value))
1142 }
1143 }
1144
1145 deserializer.deserialize_u64(U64Visitor)
1146 }
1147}
1148
1149#[repr(transparent)]
1150#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
1151pub struct MigrationId(pub u64);
1152
1153impl Display for MigrationId {
1154 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1155 Display::fmt(&self.0, f)
1156 }
1157}
1158
1159impl Deref for MigrationId {
1160 type Target = u64;
1161
1162 fn deref(&self) -> &Self::Target {
1163 &self.0
1164 }
1165}
1166
1167impl PartialEq<u64> for MigrationId {
1168 fn eq(&self, other: &u64) -> bool {
1169 self.0.eq(other)
1170 }
1171}
1172
1173impl From<MigrationId> for u64 {
1174 fn from(value: MigrationId) -> Self {
1175 value.0
1176 }
1177}
1178
1179impl From<i32> for MigrationId {
1180 fn from(value: i32) -> Self {
1181 Self(value as u64)
1182 }
1183}
1184
1185impl From<u64> for MigrationId {
1186 fn from(value: u64) -> Self {
1187 Self(value)
1188 }
1189}
1190
1191impl Serialize for MigrationId {
1192 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1193 where
1194 S: Serializer,
1195 {
1196 serializer.serialize_u64(self.0)
1197 }
1198}
1199
1200impl<'de> Deserialize<'de> for MigrationId {
1201 fn deserialize<D>(deserializer: D) -> Result<MigrationId, D::Error>
1202 where
1203 D: Deserializer<'de>,
1204 {
1205 struct U64Visitor;
1206
1207 impl Visitor<'_> for U64Visitor {
1208 type Value = MigrationId;
1209
1210 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1211 formatter.write_str("an unsigned 64-bit number")
1212 }
1213
1214 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1215 Ok(MigrationId(value))
1216 }
1217 }
1218
1219 deserializer.deserialize_u64(U64Visitor)
1220 }
1221}
1222
1223#[repr(transparent)]
1224#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
1225pub struct MigrationEventId(pub u64);
1226
1227impl Display for MigrationEventId {
1228 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1229 Display::fmt(&self.0, f)
1230 }
1231}
1232
1233impl Deref for MigrationEventId {
1234 type Target = u64;
1235
1236 fn deref(&self) -> &Self::Target {
1237 &self.0
1238 }
1239}
1240
1241impl PartialEq<u64> for MigrationEventId {
1242 fn eq(&self, other: &u64) -> bool {
1243 self.0.eq(other)
1244 }
1245}
1246
1247impl From<MigrationEventId> for u64 {
1248 fn from(value: MigrationEventId) -> Self {
1249 value.0
1250 }
1251}
1252
1253impl From<i32> for MigrationEventId {
1254 fn from(value: i32) -> Self {
1255 Self(value as u64)
1256 }
1257}
1258
1259impl From<u64> for MigrationEventId {
1260 fn from(value: u64) -> Self {
1261 Self(value)
1262 }
1263}
1264
1265impl Serialize for MigrationEventId {
1266 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1267 where
1268 S: Serializer,
1269 {
1270 serializer.serialize_u64(self.0)
1271 }
1272}
1273
1274impl<'de> Deserialize<'de> for MigrationEventId {
1275 fn deserialize<D>(deserializer: D) -> Result<MigrationEventId, D::Error>
1276 where
1277 D: Deserializer<'de>,
1278 {
1279 struct U64Visitor;
1280
1281 impl Visitor<'_> for U64Visitor {
1282 type Value = MigrationEventId;
1283
1284 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1285 formatter.write_str("an unsigned 64-bit number")
1286 }
1287
1288 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1289 Ok(MigrationEventId(value))
1290 }
1291 }
1292
1293 deserializer.deserialize_u64(U64Visitor)
1294 }
1295}
1296
1297#[repr(transparent)]
1298#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
1299pub struct SourceId(pub u64);
1300
1301impl Display for SourceId {
1302 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1303 Display::fmt(&self.0, f)
1304 }
1305}
1306
1307impl Deref for SourceId {
1308 type Target = u64;
1309
1310 fn deref(&self) -> &Self::Target {
1311 &self.0
1312 }
1313}
1314
1315impl PartialEq<u64> for SourceId {
1316 fn eq(&self, other: &u64) -> bool {
1317 self.0.eq(other)
1318 }
1319}
1320
1321impl From<SourceId> for u64 {
1322 fn from(value: SourceId) -> Self {
1323 value.0
1324 }
1325}
1326
1327impl From<u64> for SourceId {
1328 fn from(value: u64) -> Self {
1329 Self(value)
1330 }
1331}
1332
1333impl Serialize for SourceId {
1334 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1335 where
1336 S: Serializer,
1337 {
1338 serializer.serialize_u64(self.0)
1339 }
1340}
1341
1342impl<'de> Deserialize<'de> for SourceId {
1343 fn deserialize<D>(deserializer: D) -> Result<SourceId, D::Error>
1344 where
1345 D: Deserializer<'de>,
1346 {
1347 struct U64Visitor;
1348
1349 impl Visitor<'_> for U64Visitor {
1350 type Value = SourceId;
1351
1352 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1353 formatter.write_str("an unsigned 64-bit number")
1354 }
1355
1356 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1357 Ok(SourceId(value))
1358 }
1359 }
1360
1361 deserializer.deserialize_u64(U64Visitor)
1362 }
1363}
1364
1365#[repr(transparent)]
1366#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
1367pub struct BindingId(pub u64);
1368
1369impl Display for BindingId {
1370 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1371 Display::fmt(&self.0, f)
1372 }
1373}
1374
1375impl Deref for BindingId {
1376 type Target = u64;
1377
1378 fn deref(&self) -> &Self::Target {
1379 &self.0
1380 }
1381}
1382
1383impl PartialEq<u64> for BindingId {
1384 fn eq(&self, other: &u64) -> bool {
1385 self.0.eq(other)
1386 }
1387}
1388
1389impl From<BindingId> for u64 {
1390 fn from(value: BindingId) -> Self {
1391 value.0
1392 }
1393}
1394
1395impl From<u64> for BindingId {
1396 fn from(value: u64) -> Self {
1397 Self(value)
1398 }
1399}
1400
1401impl Serialize for BindingId {
1402 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1403 where
1404 S: Serializer,
1405 {
1406 serializer.serialize_u64(self.0)
1407 }
1408}
1409
1410impl<'de> Deserialize<'de> for BindingId {
1411 fn deserialize<D>(deserializer: D) -> Result<BindingId, D::Error>
1412 where
1413 D: Deserializer<'de>,
1414 {
1415 struct U64Visitor;
1416
1417 impl Visitor<'_> for U64Visitor {
1418 type Value = BindingId;
1419
1420 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1421 formatter.write_str("an unsigned 64-bit number")
1422 }
1423
1424 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1425 Ok(BindingId(value))
1426 }
1427 }
1428
1429 deserializer.deserialize_u64(U64Visitor)
1430 }
1431}
1432
1433#[repr(transparent)]
1434#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
1435pub struct SinkId(pub u64);
1436
1437impl Display for SinkId {
1438 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1439 Display::fmt(&self.0, f)
1440 }
1441}
1442
1443impl Deref for SinkId {
1444 type Target = u64;
1445
1446 fn deref(&self) -> &Self::Target {
1447 &self.0
1448 }
1449}
1450
1451impl PartialEq<u64> for SinkId {
1452 fn eq(&self, other: &u64) -> bool {
1453 self.0.eq(other)
1454 }
1455}
1456
1457impl From<SinkId> for u64 {
1458 fn from(value: SinkId) -> Self {
1459 value.0
1460 }
1461}
1462
1463impl From<u64> for SinkId {
1464 fn from(value: u64) -> Self {
1465 Self(value)
1466 }
1467}
1468
1469impl Serialize for SinkId {
1470 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1471 where
1472 S: Serializer,
1473 {
1474 serializer.serialize_u64(self.0)
1475 }
1476}
1477
1478impl<'de> Deserialize<'de> for SinkId {
1479 fn deserialize<D>(deserializer: D) -> Result<SinkId, D::Error>
1480 where
1481 D: Deserializer<'de>,
1482 {
1483 struct U64Visitor;
1484
1485 impl Visitor<'_> for U64Visitor {
1486 type Value = SinkId;
1487
1488 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1489 formatter.write_str("an unsigned 64-bit number")
1490 }
1491
1492 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1493 Ok(SinkId(value))
1494 }
1495 }
1496
1497 deserializer.deserialize_u64(U64Visitor)
1498 }
1499}