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)]
671#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
672pub struct SubscriptionId(pub u64);
673
674impl Display for SubscriptionId {
675 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
676 Display::fmt(&self.0, f)
677 }
678}
679
680impl Deref for SubscriptionId {
681 type Target = u64;
682
683 fn deref(&self) -> &Self::Target {
684 &self.0
685 }
686}
687
688impl PartialEq<u64> for SubscriptionId {
689 fn eq(&self, other: &u64) -> bool {
690 self.0.eq(other)
691 }
692}
693
694impl From<SubscriptionId> for u64 {
695 fn from(value: SubscriptionId) -> Self {
696 value.0
697 }
698}
699
700impl From<u64> for SubscriptionId {
701 fn from(value: u64) -> Self {
702 Self(value)
703 }
704}
705
706impl Serialize for SubscriptionId {
707 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
708 where
709 S: Serializer,
710 {
711 serializer.serialize_u64(self.0)
712 }
713}
714
715impl<'de> Deserialize<'de> for SubscriptionId {
716 fn deserialize<D>(deserializer: D) -> Result<SubscriptionId, D::Error>
717 where
718 D: Deserializer<'de>,
719 {
720 struct U64Visitor;
721
722 impl Visitor<'_> for U64Visitor {
723 type Value = SubscriptionId;
724
725 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
726 formatter.write_str("an unsigned 64-bit number")
727 }
728
729 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
730 Ok(SubscriptionId(value))
731 }
732 }
733
734 deserializer.deserialize_u64(U64Visitor)
735 }
736}
737
738#[repr(transparent)]
739#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
740pub struct SequenceId(pub u64);
741
742impl Deref for SequenceId {
743 type Target = u64;
744
745 fn deref(&self) -> &Self::Target {
746 &self.0
747 }
748}
749
750impl PartialEq<u64> for SequenceId {
751 fn eq(&self, other: &u64) -> bool {
752 self.0.eq(other)
753 }
754}
755
756impl Serialize for SequenceId {
757 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
758 where
759 S: Serializer,
760 {
761 serializer.serialize_u64(self.0)
762 }
763}
764
765impl<'de> Deserialize<'de> for SequenceId {
766 fn deserialize<D>(deserializer: D) -> Result<SequenceId, D::Error>
767 where
768 D: Deserializer<'de>,
769 {
770 struct U64Visitor;
771
772 impl Visitor<'_> for U64Visitor {
773 type Value = SequenceId;
774
775 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
776 formatter.write_str("an unsigned 64-bit number")
777 }
778
779 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
780 Ok(SequenceId(value))
781 }
782 }
783
784 deserializer.deserialize_u64(U64Visitor)
785 }
786}
787
788#[repr(transparent)]
789#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
790pub struct SubscriptionColumnId(pub u64);
791
792impl Display for SubscriptionColumnId {
793 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
794 Display::fmt(&self.0, f)
795 }
796}
797
798impl Deref for SubscriptionColumnId {
799 type Target = u64;
800
801 fn deref(&self) -> &Self::Target {
802 &self.0
803 }
804}
805
806impl PartialEq<u64> for SubscriptionColumnId {
807 fn eq(&self, other: &u64) -> bool {
808 self.0.eq(other)
809 }
810}
811
812impl From<SubscriptionColumnId> for u64 {
813 fn from(value: SubscriptionColumnId) -> Self {
814 value.0
815 }
816}
817
818impl From<i32> for SubscriptionColumnId {
819 fn from(value: i32) -> Self {
820 Self(value as u64)
821 }
822}
823
824impl From<u64> for SubscriptionColumnId {
825 fn from(value: u64) -> Self {
826 Self(value)
827 }
828}
829
830impl Serialize for SubscriptionColumnId {
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 SubscriptionColumnId {
840 fn deserialize<D>(deserializer: D) -> Result<SubscriptionColumnId, D::Error>
841 where
842 D: Deserializer<'de>,
843 {
844 struct U64Visitor;
845
846 impl Visitor<'_> for U64Visitor {
847 type Value = SubscriptionColumnId;
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(SubscriptionColumnId(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 SeriesId(pub u64);
865
866impl Display for SeriesId {
867 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
868 Display::fmt(&self.0, f)
869 }
870}
871
872impl Deref for SeriesId {
873 type Target = u64;
874
875 fn deref(&self) -> &Self::Target {
876 &self.0
877 }
878}
879
880impl PartialEq<u64> for SeriesId {
881 fn eq(&self, other: &u64) -> bool {
882 self.0.eq(other)
883 }
884}
885
886impl From<SeriesId> for u64 {
887 fn from(value: SeriesId) -> Self {
888 value.0
889 }
890}
891
892impl SeriesId {
893 #[inline]
894 pub fn to_u64(self) -> u64 {
895 self.0
896 }
897}
898
899impl From<i32> for SeriesId {
900 fn from(value: i32) -> Self {
901 Self(value as u64)
902 }
903}
904
905impl From<u64> for SeriesId {
906 fn from(value: u64) -> Self {
907 Self(value)
908 }
909}
910
911impl Serialize for SeriesId {
912 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
913 where
914 S: Serializer,
915 {
916 serializer.serialize_u64(self.0)
917 }
918}
919
920impl<'de> Deserialize<'de> for SeriesId {
921 fn deserialize<D>(deserializer: D) -> Result<SeriesId, D::Error>
922 where
923 D: Deserializer<'de>,
924 {
925 struct U64Visitor;
926
927 impl Visitor<'_> for U64Visitor {
928 type Value = SeriesId;
929
930 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
931 formatter.write_str("an unsigned 64-bit number")
932 }
933
934 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
935 Ok(SeriesId(value))
936 }
937 }
938
939 deserializer.deserialize_u64(U64Visitor)
940 }
941}
942
943#[repr(transparent)]
944#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
945pub struct HandlerId(pub u64);
946
947impl Display for HandlerId {
948 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
949 Display::fmt(&self.0, f)
950 }
951}
952
953impl Deref for HandlerId {
954 type Target = u64;
955
956 fn deref(&self) -> &Self::Target {
957 &self.0
958 }
959}
960
961impl PartialEq<u64> for HandlerId {
962 fn eq(&self, other: &u64) -> bool {
963 self.0.eq(other)
964 }
965}
966
967impl From<HandlerId> for u64 {
968 fn from(value: HandlerId) -> Self {
969 value.0
970 }
971}
972
973impl From<i32> for HandlerId {
974 fn from(value: i32) -> Self {
975 Self(value as u64)
976 }
977}
978
979impl From<u64> for HandlerId {
980 fn from(value: u64) -> Self {
981 Self(value)
982 }
983}
984
985impl Serialize for HandlerId {
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 HandlerId {
995 fn deserialize<D>(deserializer: D) -> Result<HandlerId, D::Error>
996 where
997 D: Deserializer<'de>,
998 {
999 struct U64Visitor;
1000
1001 impl Visitor<'_> for U64Visitor {
1002 type Value = HandlerId;
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(HandlerId(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 MigrationId(pub u64);
1020
1021impl Display for MigrationId {
1022 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1023 Display::fmt(&self.0, f)
1024 }
1025}
1026
1027impl Deref for MigrationId {
1028 type Target = u64;
1029
1030 fn deref(&self) -> &Self::Target {
1031 &self.0
1032 }
1033}
1034
1035impl PartialEq<u64> for MigrationId {
1036 fn eq(&self, other: &u64) -> bool {
1037 self.0.eq(other)
1038 }
1039}
1040
1041impl From<MigrationId> for u64 {
1042 fn from(value: MigrationId) -> Self {
1043 value.0
1044 }
1045}
1046
1047impl From<i32> for MigrationId {
1048 fn from(value: i32) -> Self {
1049 Self(value as u64)
1050 }
1051}
1052
1053impl From<u64> for MigrationId {
1054 fn from(value: u64) -> Self {
1055 Self(value)
1056 }
1057}
1058
1059impl Serialize for MigrationId {
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 MigrationId {
1069 fn deserialize<D>(deserializer: D) -> Result<MigrationId, D::Error>
1070 where
1071 D: Deserializer<'de>,
1072 {
1073 struct U64Visitor;
1074
1075 impl Visitor<'_> for U64Visitor {
1076 type Value = MigrationId;
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(MigrationId(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 MigrationEventId(pub u64);
1094
1095impl Display for MigrationEventId {
1096 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1097 Display::fmt(&self.0, f)
1098 }
1099}
1100
1101impl Deref for MigrationEventId {
1102 type Target = u64;
1103
1104 fn deref(&self) -> &Self::Target {
1105 &self.0
1106 }
1107}
1108
1109impl PartialEq<u64> for MigrationEventId {
1110 fn eq(&self, other: &u64) -> bool {
1111 self.0.eq(other)
1112 }
1113}
1114
1115impl From<MigrationEventId> for u64 {
1116 fn from(value: MigrationEventId) -> Self {
1117 value.0
1118 }
1119}
1120
1121impl From<i32> for MigrationEventId {
1122 fn from(value: i32) -> Self {
1123 Self(value as u64)
1124 }
1125}
1126
1127impl From<u64> for MigrationEventId {
1128 fn from(value: u64) -> Self {
1129 Self(value)
1130 }
1131}
1132
1133impl Serialize for MigrationEventId {
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 MigrationEventId {
1143 fn deserialize<D>(deserializer: D) -> Result<MigrationEventId, D::Error>
1144 where
1145 D: Deserializer<'de>,
1146 {
1147 struct U64Visitor;
1148
1149 impl Visitor<'_> for U64Visitor {
1150 type Value = MigrationEventId;
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(MigrationEventId(value))
1158 }
1159 }
1160
1161 deserializer.deserialize_u64(U64Visitor)
1162 }
1163}