Skip to main content

reifydb_core/interface/catalog/
id.rs

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