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 Deref for ColumnId {
17 type Target = u64;
18
19 fn deref(&self) -> &Self::Target {
20 &self.0
21 }
22}
23
24impl PartialEq<u64> for ColumnId {
25 fn eq(&self, other: &u64) -> bool {
26 self.0.eq(other)
27 }
28}
29
30impl From<ColumnId> for u64 {
31 fn from(value: ColumnId) -> Self {
32 value.0
33 }
34}
35
36impl Serialize for ColumnId {
37 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
38 where
39 S: Serializer,
40 {
41 serializer.serialize_u64(self.0)
42 }
43}
44
45impl<'de> Deserialize<'de> for ColumnId {
46 fn deserialize<D>(deserializer: D) -> Result<ColumnId, D::Error>
47 where
48 D: Deserializer<'de>,
49 {
50 struct U64Visitor;
51
52 impl Visitor<'_> for U64Visitor {
53 type Value = ColumnId;
54
55 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
56 formatter.write_str("an unsigned 64-bit number")
57 }
58
59 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
60 Ok(ColumnId(value))
61 }
62 }
63
64 deserializer.deserialize_u64(U64Visitor)
65 }
66}
67
68#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
69pub enum IndexId {
70 Primary(PrimaryKeyId),
71 }
73
74impl IndexId {
75 pub fn as_u64(&self) -> u64 {
76 match self {
77 IndexId::Primary(id) => id.0,
78 }
79 }
80
81 pub fn primary(id: impl Into<PrimaryKeyId>) -> Self {
82 IndexId::Primary(id.into())
83 }
84
85 pub fn next(&self) -> IndexId {
87 match self {
88 IndexId::Primary(primary) => IndexId::Primary(PrimaryKeyId(primary.0 + 1)), }
92 }
93
94 pub fn prev(&self) -> IndexId {
95 match self {
96 IndexId::Primary(primary) => IndexId::Primary(PrimaryKeyId(primary.0.wrapping_sub(1))),
97 }
98 }
99}
100
101impl Deref for IndexId {
102 type Target = u64;
103
104 fn deref(&self) -> &Self::Target {
105 match self {
106 IndexId::Primary(id) => &id.0,
107 }
108 }
109}
110
111impl PartialEq<u64> for IndexId {
112 fn eq(&self, other: &u64) -> bool {
113 self.as_u64().eq(other)
114 }
115}
116
117impl From<IndexId> for u64 {
118 fn from(value: IndexId) -> Self {
119 value.as_u64()
120 }
121}
122
123impl Serialize for IndexId {
124 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
125 where
126 S: Serializer,
127 {
128 serializer.serialize_u64(self.as_u64())
129 }
130}
131
132impl<'de> Deserialize<'de> for IndexId {
133 fn deserialize<D>(deserializer: D) -> Result<IndexId, D::Error>
134 where
135 D: Deserializer<'de>,
136 {
137 struct U64Visitor;
138
139 impl Visitor<'_> for U64Visitor {
140 type Value = IndexId;
141
142 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
143 formatter.write_str("an unsigned 64-bit number")
144 }
145
146 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
147 Ok(IndexId::Primary(PrimaryKeyId(value)))
149 }
150 }
151
152 deserializer.deserialize_u64(U64Visitor)
153 }
154}
155
156#[repr(transparent)]
157#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
158pub struct ColumnPropertyId(pub u64);
159
160impl Deref for ColumnPropertyId {
161 type Target = u64;
162
163 fn deref(&self) -> &Self::Target {
164 &self.0
165 }
166}
167
168impl PartialEq<u64> for ColumnPropertyId {
169 fn eq(&self, other: &u64) -> bool {
170 self.0.eq(other)
171 }
172}
173
174impl From<ColumnPropertyId> for u64 {
175 fn from(value: ColumnPropertyId) -> Self {
176 value.0
177 }
178}
179
180impl Serialize for ColumnPropertyId {
181 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
182 where
183 S: Serializer,
184 {
185 serializer.serialize_u64(self.0)
186 }
187}
188
189impl<'de> Deserialize<'de> for ColumnPropertyId {
190 fn deserialize<D>(deserializer: D) -> Result<ColumnPropertyId, D::Error>
191 where
192 D: Deserializer<'de>,
193 {
194 struct U64Visitor;
195
196 impl Visitor<'_> for U64Visitor {
197 type Value = ColumnPropertyId;
198
199 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
200 formatter.write_str("an unsigned 64-bit number")
201 }
202
203 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
204 Ok(ColumnPropertyId(value))
205 }
206 }
207
208 deserializer.deserialize_u64(U64Visitor)
209 }
210}
211
212#[repr(transparent)]
213#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
214pub struct NamespaceId(pub u64);
215
216impl Display for NamespaceId {
217 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
218 Display::fmt(&self.0, f)
219 }
220}
221
222impl Deref for NamespaceId {
223 type Target = u64;
224
225 fn deref(&self) -> &Self::Target {
226 &self.0
227 }
228}
229
230impl PartialEq<u64> for NamespaceId {
231 fn eq(&self, other: &u64) -> bool {
232 self.0.eq(other)
233 }
234}
235
236impl From<NamespaceId> for u64 {
237 fn from(value: NamespaceId) -> Self {
238 value.0
239 }
240}
241
242impl Serialize for NamespaceId {
243 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
244 where
245 S: Serializer,
246 {
247 serializer.serialize_u64(self.0)
248 }
249}
250
251impl<'de> Deserialize<'de> for NamespaceId {
252 fn deserialize<D>(deserializer: D) -> Result<NamespaceId, D::Error>
253 where
254 D: Deserializer<'de>,
255 {
256 struct U64Visitor;
257
258 impl Visitor<'_> for U64Visitor {
259 type Value = NamespaceId;
260
261 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
262 formatter.write_str("an unsigned 64-bit number")
263 }
264
265 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
266 Ok(NamespaceId(value))
267 }
268 }
269
270 deserializer.deserialize_u64(U64Visitor)
271 }
272}
273
274#[repr(transparent)]
275#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
276pub struct TableId(pub u64);
277
278impl Display for TableId {
279 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
280 Display::fmt(&self.0, f)
281 }
282}
283
284impl Deref for TableId {
285 type Target = u64;
286
287 fn deref(&self) -> &Self::Target {
288 &self.0
289 }
290}
291
292impl PartialEq<u64> for TableId {
293 fn eq(&self, other: &u64) -> bool {
294 self.0.eq(other)
295 }
296}
297
298impl From<TableId> for u64 {
299 fn from(value: TableId) -> Self {
300 value.0
301 }
302}
303
304impl TableId {
305 #[inline]
307 pub fn to_u64(self) -> u64 {
308 self.0
309 }
310}
311
312impl From<i32> for TableId {
313 fn from(value: i32) -> Self {
314 Self(value as u64)
315 }
316}
317
318impl From<u64> for TableId {
319 fn from(value: u64) -> Self {
320 Self(value)
321 }
322}
323
324impl Serialize for TableId {
325 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
326 where
327 S: Serializer,
328 {
329 serializer.serialize_u64(self.0)
330 }
331}
332
333impl<'de> Deserialize<'de> for TableId {
334 fn deserialize<D>(deserializer: D) -> Result<TableId, D::Error>
335 where
336 D: Deserializer<'de>,
337 {
338 struct U64Visitor;
339
340 impl Visitor<'_> for U64Visitor {
341 type Value = TableId;
342
343 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
344 formatter.write_str("an unsigned 64-bit number")
345 }
346
347 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
348 Ok(TableId(value))
349 }
350 }
351
352 deserializer.deserialize_u64(U64Visitor)
353 }
354}
355
356#[repr(transparent)]
357#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
358pub struct ViewId(pub u64);
359
360impl Display for ViewId {
361 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
362 Display::fmt(&self.0, f)
363 }
364}
365
366impl Deref for ViewId {
367 type Target = u64;
368
369 fn deref(&self) -> &Self::Target {
370 &self.0
371 }
372}
373
374impl PartialEq<u64> for ViewId {
375 fn eq(&self, other: &u64) -> bool {
376 self.0.eq(other)
377 }
378}
379
380impl From<ViewId> for u64 {
381 fn from(value: ViewId) -> Self {
382 value.0
383 }
384}
385
386impl ViewId {
387 #[inline]
389 pub fn to_u64(self) -> u64 {
390 self.0
391 }
392}
393
394impl From<i32> for ViewId {
395 fn from(value: i32) -> Self {
396 Self(value as u64)
397 }
398}
399
400impl From<u64> for ViewId {
401 fn from(value: u64) -> Self {
402 Self(value)
403 }
404}
405
406impl Serialize for ViewId {
407 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
408 where
409 S: Serializer,
410 {
411 serializer.serialize_u64(self.0)
412 }
413}
414
415impl<'de> Deserialize<'de> for ViewId {
416 fn deserialize<D>(deserializer: D) -> Result<ViewId, D::Error>
417 where
418 D: Deserializer<'de>,
419 {
420 struct U64Visitor;
421
422 impl Visitor<'_> for U64Visitor {
423 type Value = ViewId;
424
425 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
426 formatter.write_str("an unsigned 64-bit number")
427 }
428
429 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
430 Ok(ViewId(value))
431 }
432 }
433
434 deserializer.deserialize_u64(U64Visitor)
435 }
436}
437
438#[repr(transparent)]
439#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
440pub struct PrimaryKeyId(pub u64);
441
442impl Display for PrimaryKeyId {
443 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
444 Display::fmt(&self.0, f)
445 }
446}
447
448impl Deref for PrimaryKeyId {
449 type Target = u64;
450
451 fn deref(&self) -> &Self::Target {
452 &self.0
453 }
454}
455
456impl PartialEq<u64> for PrimaryKeyId {
457 fn eq(&self, other: &u64) -> bool {
458 self.0.eq(other)
459 }
460}
461
462impl From<PrimaryKeyId> for u64 {
463 fn from(value: PrimaryKeyId) -> Self {
464 value.0
465 }
466}
467
468impl From<i32> for PrimaryKeyId {
469 fn from(value: i32) -> Self {
470 Self(value as u64)
471 }
472}
473
474impl From<u64> for PrimaryKeyId {
475 fn from(value: u64) -> Self {
476 Self(value)
477 }
478}
479
480impl Serialize for PrimaryKeyId {
481 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
482 where
483 S: Serializer,
484 {
485 serializer.serialize_u64(self.0)
486 }
487}
488
489impl<'de> Deserialize<'de> for PrimaryKeyId {
490 fn deserialize<D>(deserializer: D) -> Result<PrimaryKeyId, D::Error>
491 where
492 D: Deserializer<'de>,
493 {
494 struct U64Visitor;
495
496 impl Visitor<'_> for U64Visitor {
497 type Value = PrimaryKeyId;
498
499 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
500 formatter.write_str("an unsigned 64-bit number")
501 }
502
503 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
504 Ok(PrimaryKeyId(value))
505 }
506 }
507
508 deserializer.deserialize_u64(U64Visitor)
509 }
510}
511
512#[repr(transparent)]
513#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
514pub struct RingBufferId(pub u64);
515
516impl Display for RingBufferId {
517 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
518 Display::fmt(&self.0, f)
519 }
520}
521
522impl Deref for RingBufferId {
523 type Target = u64;
524
525 fn deref(&self) -> &Self::Target {
526 &self.0
527 }
528}
529
530impl PartialEq<u64> for RingBufferId {
531 fn eq(&self, other: &u64) -> bool {
532 self.0.eq(other)
533 }
534}
535
536impl From<RingBufferId> for u64 {
537 fn from(value: RingBufferId) -> Self {
538 value.0
539 }
540}
541
542impl RingBufferId {
543 #[inline]
545 pub fn to_u64(self) -> u64 {
546 self.0
547 }
548}
549
550impl From<i32> for RingBufferId {
551 fn from(value: i32) -> Self {
552 Self(value as u64)
553 }
554}
555
556impl From<u64> for RingBufferId {
557 fn from(value: u64) -> Self {
558 Self(value)
559 }
560}
561
562impl Serialize for RingBufferId {
563 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
564 where
565 S: Serializer,
566 {
567 serializer.serialize_u64(self.0)
568 }
569}
570
571impl<'de> Deserialize<'de> for RingBufferId {
572 fn deserialize<D>(deserializer: D) -> Result<RingBufferId, D::Error>
573 where
574 D: Deserializer<'de>,
575 {
576 struct U64Visitor;
577
578 impl Visitor<'_> for U64Visitor {
579 type Value = RingBufferId;
580
581 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
582 formatter.write_str("an unsigned 64-bit number")
583 }
584
585 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
586 Ok(RingBufferId(value))
587 }
588 }
589
590 deserializer.deserialize_u64(U64Visitor)
591 }
592}
593
594#[repr(transparent)]
595#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
596pub struct ProcedureId(pub u64);
597
598impl Display for ProcedureId {
599 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
600 Display::fmt(&self.0, f)
601 }
602}
603
604impl Deref for ProcedureId {
605 type Target = u64;
606
607 fn deref(&self) -> &Self::Target {
608 &self.0
609 }
610}
611
612impl PartialEq<u64> for ProcedureId {
613 fn eq(&self, other: &u64) -> bool {
614 self.0.eq(other)
615 }
616}
617
618impl From<ProcedureId> for u64 {
619 fn from(value: ProcedureId) -> Self {
620 value.0
621 }
622}
623
624impl From<i32> for ProcedureId {
625 fn from(value: i32) -> Self {
626 Self(value as u64)
627 }
628}
629
630impl From<u64> for ProcedureId {
631 fn from(value: u64) -> Self {
632 Self(value)
633 }
634}
635
636impl Serialize for ProcedureId {
637 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
638 where
639 S: Serializer,
640 {
641 serializer.serialize_u64(self.0)
642 }
643}
644
645impl<'de> Deserialize<'de> for ProcedureId {
646 fn deserialize<D>(deserializer: D) -> Result<ProcedureId, D::Error>
647 where
648 D: Deserializer<'de>,
649 {
650 struct U64Visitor;
651
652 impl Visitor<'_> for U64Visitor {
653 type Value = ProcedureId;
654
655 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
656 formatter.write_str("an unsigned 64-bit number")
657 }
658
659 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
660 Ok(ProcedureId(value))
661 }
662 }
663
664 deserializer.deserialize_u64(U64Visitor)
665 }
666}
667
668#[repr(transparent)]
669#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
670pub struct TestId(pub u64);
671
672impl Display for TestId {
673 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
674 Display::fmt(&self.0, f)
675 }
676}
677
678impl Deref for TestId {
679 type Target = u64;
680
681 fn deref(&self) -> &Self::Target {
682 &self.0
683 }
684}
685
686impl PartialEq<u64> for TestId {
687 fn eq(&self, other: &u64) -> bool {
688 self.0.eq(other)
689 }
690}
691
692impl From<TestId> for u64 {
693 fn from(value: TestId) -> Self {
694 value.0
695 }
696}
697
698impl From<i32> for TestId {
699 fn from(value: i32) -> Self {
700 Self(value as u64)
701 }
702}
703
704impl From<u64> for TestId {
705 fn from(value: u64) -> Self {
706 Self(value)
707 }
708}
709
710impl Serialize for TestId {
711 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
712 where
713 S: Serializer,
714 {
715 serializer.serialize_u64(self.0)
716 }
717}
718
719impl<'de> Deserialize<'de> for TestId {
720 fn deserialize<D>(deserializer: D) -> Result<TestId, D::Error>
721 where
722 D: Deserializer<'de>,
723 {
724 struct U64Visitor;
725
726 impl Visitor<'_> for U64Visitor {
727 type Value = TestId;
728
729 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
730 formatter.write_str("an unsigned 64-bit number")
731 }
732
733 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
734 Ok(TestId(value))
735 }
736 }
737
738 deserializer.deserialize_u64(U64Visitor)
739 }
740}
741
742#[repr(transparent)]
745#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
746pub struct SubscriptionId(pub u64);
747
748impl Display for SubscriptionId {
749 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
750 Display::fmt(&self.0, f)
751 }
752}
753
754impl Deref for SubscriptionId {
755 type Target = u64;
756
757 fn deref(&self) -> &Self::Target {
758 &self.0
759 }
760}
761
762impl PartialEq<u64> for SubscriptionId {
763 fn eq(&self, other: &u64) -> bool {
764 self.0.eq(other)
765 }
766}
767
768impl From<SubscriptionId> for u64 {
769 fn from(value: SubscriptionId) -> Self {
770 value.0
771 }
772}
773
774impl From<u64> for SubscriptionId {
775 fn from(value: u64) -> Self {
776 Self(value)
777 }
778}
779
780impl Serialize for SubscriptionId {
781 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
782 where
783 S: Serializer,
784 {
785 serializer.serialize_u64(self.0)
786 }
787}
788
789impl<'de> Deserialize<'de> for SubscriptionId {
790 fn deserialize<D>(deserializer: D) -> Result<SubscriptionId, D::Error>
791 where
792 D: Deserializer<'de>,
793 {
794 struct U64Visitor;
795
796 impl Visitor<'_> for U64Visitor {
797 type Value = SubscriptionId;
798
799 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
800 formatter.write_str("an unsigned 64-bit number")
801 }
802
803 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
804 Ok(SubscriptionId(value))
805 }
806 }
807
808 deserializer.deserialize_u64(U64Visitor)
809 }
810}
811
812#[repr(transparent)]
813#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
814pub struct SequenceId(pub u64);
815
816impl Deref for SequenceId {
817 type Target = u64;
818
819 fn deref(&self) -> &Self::Target {
820 &self.0
821 }
822}
823
824impl PartialEq<u64> for SequenceId {
825 fn eq(&self, other: &u64) -> bool {
826 self.0.eq(other)
827 }
828}
829
830impl Serialize for SequenceId {
831 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
832 where
833 S: Serializer,
834 {
835 serializer.serialize_u64(self.0)
836 }
837}
838
839impl<'de> Deserialize<'de> for SequenceId {
840 fn deserialize<D>(deserializer: D) -> Result<SequenceId, D::Error>
841 where
842 D: Deserializer<'de>,
843 {
844 struct U64Visitor;
845
846 impl Visitor<'_> for U64Visitor {
847 type Value = SequenceId;
848
849 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
850 formatter.write_str("an unsigned 64-bit number")
851 }
852
853 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
854 Ok(SequenceId(value))
855 }
856 }
857
858 deserializer.deserialize_u64(U64Visitor)
859 }
860}
861
862#[repr(transparent)]
863#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
864pub struct SubscriptionColumnId(pub u64);
865
866impl Display for SubscriptionColumnId {
867 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
868 Display::fmt(&self.0, f)
869 }
870}
871
872impl Deref for SubscriptionColumnId {
873 type Target = u64;
874
875 fn deref(&self) -> &Self::Target {
876 &self.0
877 }
878}
879
880impl PartialEq<u64> for SubscriptionColumnId {
881 fn eq(&self, other: &u64) -> bool {
882 self.0.eq(other)
883 }
884}
885
886impl From<SubscriptionColumnId> for u64 {
887 fn from(value: SubscriptionColumnId) -> Self {
888 value.0
889 }
890}
891
892impl From<i32> for SubscriptionColumnId {
893 fn from(value: i32) -> Self {
894 Self(value as u64)
895 }
896}
897
898impl From<u64> for SubscriptionColumnId {
899 fn from(value: u64) -> Self {
900 Self(value)
901 }
902}
903
904impl Serialize for SubscriptionColumnId {
905 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
906 where
907 S: Serializer,
908 {
909 serializer.serialize_u64(self.0)
910 }
911}
912
913impl<'de> Deserialize<'de> for SubscriptionColumnId {
914 fn deserialize<D>(deserializer: D) -> Result<SubscriptionColumnId, D::Error>
915 where
916 D: Deserializer<'de>,
917 {
918 struct U64Visitor;
919
920 impl Visitor<'_> for U64Visitor {
921 type Value = SubscriptionColumnId;
922
923 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
924 formatter.write_str("an unsigned 64-bit number")
925 }
926
927 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
928 Ok(SubscriptionColumnId(value))
929 }
930 }
931
932 deserializer.deserialize_u64(U64Visitor)
933 }
934}
935
936#[repr(transparent)]
937#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
938pub struct SeriesId(pub u64);
939
940impl Display for SeriesId {
941 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
942 Display::fmt(&self.0, f)
943 }
944}
945
946impl Deref for SeriesId {
947 type Target = u64;
948
949 fn deref(&self) -> &Self::Target {
950 &self.0
951 }
952}
953
954impl PartialEq<u64> for SeriesId {
955 fn eq(&self, other: &u64) -> bool {
956 self.0.eq(other)
957 }
958}
959
960impl From<SeriesId> for u64 {
961 fn from(value: SeriesId) -> Self {
962 value.0
963 }
964}
965
966impl SeriesId {
967 #[inline]
968 pub fn to_u64(self) -> u64 {
969 self.0
970 }
971}
972
973impl From<i32> for SeriesId {
974 fn from(value: i32) -> Self {
975 Self(value as u64)
976 }
977}
978
979impl From<u64> for SeriesId {
980 fn from(value: u64) -> Self {
981 Self(value)
982 }
983}
984
985impl Serialize for SeriesId {
986 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
987 where
988 S: Serializer,
989 {
990 serializer.serialize_u64(self.0)
991 }
992}
993
994impl<'de> Deserialize<'de> for SeriesId {
995 fn deserialize<D>(deserializer: D) -> Result<SeriesId, D::Error>
996 where
997 D: Deserializer<'de>,
998 {
999 struct U64Visitor;
1000
1001 impl Visitor<'_> for U64Visitor {
1002 type Value = SeriesId;
1003
1004 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1005 formatter.write_str("an unsigned 64-bit number")
1006 }
1007
1008 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1009 Ok(SeriesId(value))
1010 }
1011 }
1012
1013 deserializer.deserialize_u64(U64Visitor)
1014 }
1015}
1016
1017#[repr(transparent)]
1018#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
1019pub struct HandlerId(pub u64);
1020
1021impl Display for HandlerId {
1022 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1023 Display::fmt(&self.0, f)
1024 }
1025}
1026
1027impl Deref for HandlerId {
1028 type Target = u64;
1029
1030 fn deref(&self) -> &Self::Target {
1031 &self.0
1032 }
1033}
1034
1035impl PartialEq<u64> for HandlerId {
1036 fn eq(&self, other: &u64) -> bool {
1037 self.0.eq(other)
1038 }
1039}
1040
1041impl From<HandlerId> for u64 {
1042 fn from(value: HandlerId) -> Self {
1043 value.0
1044 }
1045}
1046
1047impl From<i32> for HandlerId {
1048 fn from(value: i32) -> Self {
1049 Self(value as u64)
1050 }
1051}
1052
1053impl From<u64> for HandlerId {
1054 fn from(value: u64) -> Self {
1055 Self(value)
1056 }
1057}
1058
1059impl Serialize for HandlerId {
1060 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1061 where
1062 S: Serializer,
1063 {
1064 serializer.serialize_u64(self.0)
1065 }
1066}
1067
1068impl<'de> Deserialize<'de> for HandlerId {
1069 fn deserialize<D>(deserializer: D) -> Result<HandlerId, D::Error>
1070 where
1071 D: Deserializer<'de>,
1072 {
1073 struct U64Visitor;
1074
1075 impl Visitor<'_> for U64Visitor {
1076 type Value = HandlerId;
1077
1078 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1079 formatter.write_str("an unsigned 64-bit number")
1080 }
1081
1082 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1083 Ok(HandlerId(value))
1084 }
1085 }
1086
1087 deserializer.deserialize_u64(U64Visitor)
1088 }
1089}
1090
1091#[repr(transparent)]
1092#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
1093pub struct MigrationId(pub u64);
1094
1095impl Display for MigrationId {
1096 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1097 Display::fmt(&self.0, f)
1098 }
1099}
1100
1101impl Deref for MigrationId {
1102 type Target = u64;
1103
1104 fn deref(&self) -> &Self::Target {
1105 &self.0
1106 }
1107}
1108
1109impl PartialEq<u64> for MigrationId {
1110 fn eq(&self, other: &u64) -> bool {
1111 self.0.eq(other)
1112 }
1113}
1114
1115impl From<MigrationId> for u64 {
1116 fn from(value: MigrationId) -> Self {
1117 value.0
1118 }
1119}
1120
1121impl From<i32> for MigrationId {
1122 fn from(value: i32) -> Self {
1123 Self(value as u64)
1124 }
1125}
1126
1127impl From<u64> for MigrationId {
1128 fn from(value: u64) -> Self {
1129 Self(value)
1130 }
1131}
1132
1133impl Serialize for MigrationId {
1134 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1135 where
1136 S: Serializer,
1137 {
1138 serializer.serialize_u64(self.0)
1139 }
1140}
1141
1142impl<'de> Deserialize<'de> for MigrationId {
1143 fn deserialize<D>(deserializer: D) -> Result<MigrationId, D::Error>
1144 where
1145 D: Deserializer<'de>,
1146 {
1147 struct U64Visitor;
1148
1149 impl Visitor<'_> for U64Visitor {
1150 type Value = MigrationId;
1151
1152 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1153 formatter.write_str("an unsigned 64-bit number")
1154 }
1155
1156 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1157 Ok(MigrationId(value))
1158 }
1159 }
1160
1161 deserializer.deserialize_u64(U64Visitor)
1162 }
1163}
1164
1165#[repr(transparent)]
1166#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
1167pub struct MigrationEventId(pub u64);
1168
1169impl Display for MigrationEventId {
1170 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1171 Display::fmt(&self.0, f)
1172 }
1173}
1174
1175impl Deref for MigrationEventId {
1176 type Target = u64;
1177
1178 fn deref(&self) -> &Self::Target {
1179 &self.0
1180 }
1181}
1182
1183impl PartialEq<u64> for MigrationEventId {
1184 fn eq(&self, other: &u64) -> bool {
1185 self.0.eq(other)
1186 }
1187}
1188
1189impl From<MigrationEventId> for u64 {
1190 fn from(value: MigrationEventId) -> Self {
1191 value.0
1192 }
1193}
1194
1195impl From<i32> for MigrationEventId {
1196 fn from(value: i32) -> Self {
1197 Self(value as u64)
1198 }
1199}
1200
1201impl From<u64> for MigrationEventId {
1202 fn from(value: u64) -> Self {
1203 Self(value)
1204 }
1205}
1206
1207impl Serialize for MigrationEventId {
1208 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1209 where
1210 S: Serializer,
1211 {
1212 serializer.serialize_u64(self.0)
1213 }
1214}
1215
1216impl<'de> Deserialize<'de> for MigrationEventId {
1217 fn deserialize<D>(deserializer: D) -> Result<MigrationEventId, D::Error>
1218 where
1219 D: Deserializer<'de>,
1220 {
1221 struct U64Visitor;
1222
1223 impl Visitor<'_> for U64Visitor {
1224 type Value = MigrationEventId;
1225
1226 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1227 formatter.write_str("an unsigned 64-bit number")
1228 }
1229
1230 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1231 Ok(MigrationEventId(value))
1232 }
1233 }
1234
1235 deserializer.deserialize_u64(U64Visitor)
1236 }
1237}