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	// request_history columns (IDs 1–8)
18	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	// statement_stats columns (IDs 9–18)
28	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	// Future: Secondary, Unique, etc.
96}
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	/// Creates a next index id for range operations (numerically next)
110	pub fn next(&self) -> IndexId {
111		match self {
112			IndexId::Primary(primary) => IndexId::Primary(PrimaryKeyId(primary.0 + 1)), /* Future: handle
113			                                                                             * other index
114			                                                                             * types */
115		}
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				// Deserialize as primary key ID for now
172				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	/// Get the inner u64 value.
330	#[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	/// Get the inner u64 value.
412	#[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	/// Get the inner u64 value.
573	#[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(pub u64);
626
627impl ProcedureId {
628	pub const SYSTEM_CONFIG_SET: ProcedureId = ProcedureId(1);
629}
630
631impl Display for ProcedureId {
632	fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
633		Display::fmt(&self.0, f)
634	}
635}
636
637impl Deref for ProcedureId {
638	type Target = u64;
639
640	fn deref(&self) -> &Self::Target {
641		&self.0
642	}
643}
644
645impl PartialEq<u64> for ProcedureId {
646	fn eq(&self, other: &u64) -> bool {
647		self.0.eq(other)
648	}
649}
650
651impl From<ProcedureId> for u64 {
652	fn from(value: ProcedureId) -> Self {
653		value.0
654	}
655}
656
657impl From<i32> for ProcedureId {
658	fn from(value: i32) -> Self {
659		Self(value as u64)
660	}
661}
662
663impl From<u64> for ProcedureId {
664	fn from(value: u64) -> Self {
665		Self(value)
666	}
667}
668
669impl Serialize for ProcedureId {
670	fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
671	where
672		S: Serializer,
673	{
674		serializer.serialize_u64(self.0)
675	}
676}
677
678impl<'de> Deserialize<'de> for ProcedureId {
679	fn deserialize<D>(deserializer: D) -> Result<ProcedureId, D::Error>
680	where
681		D: Deserializer<'de>,
682	{
683		struct U64Visitor;
684
685		impl Visitor<'_> for U64Visitor {
686			type Value = ProcedureId;
687
688			fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
689				formatter.write_str("an unsigned 64-bit number")
690			}
691
692			fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
693				Ok(ProcedureId(value))
694			}
695		}
696
697		deserializer.deserialize_u64(U64Visitor)
698	}
699}
700
701#[repr(transparent)]
702#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
703pub struct TestId(pub u64);
704
705impl Display for TestId {
706	fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
707		Display::fmt(&self.0, f)
708	}
709}
710
711impl Deref for TestId {
712	type Target = u64;
713
714	fn deref(&self) -> &Self::Target {
715		&self.0
716	}
717}
718
719impl PartialEq<u64> for TestId {
720	fn eq(&self, other: &u64) -> bool {
721		self.0.eq(other)
722	}
723}
724
725impl From<TestId> for u64 {
726	fn from(value: TestId) -> Self {
727		value.0
728	}
729}
730
731impl From<i32> for TestId {
732	fn from(value: i32) -> Self {
733		Self(value as u64)
734	}
735}
736
737impl From<u64> for TestId {
738	fn from(value: u64) -> Self {
739		Self(value)
740	}
741}
742
743impl Serialize for TestId {
744	fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
745	where
746		S: Serializer,
747	{
748		serializer.serialize_u64(self.0)
749	}
750}
751
752impl<'de> Deserialize<'de> for TestId {
753	fn deserialize<D>(deserializer: D) -> Result<TestId, D::Error>
754	where
755		D: Deserializer<'de>,
756	{
757		struct U64Visitor;
758
759		impl Visitor<'_> for U64Visitor {
760			type Value = TestId;
761
762			fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
763				formatter.write_str("an unsigned 64-bit number")
764			}
765
766			fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
767				Ok(TestId(value))
768			}
769		}
770
771		deserializer.deserialize_u64(U64Visitor)
772	}
773}
774
775/// A unique identifier for a subscription.
776/// Uses u64 for efficient storage and to unify with FlowId (FlowId == SubscriptionId for subscription flows).
777#[repr(transparent)]
778#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
779pub struct SubscriptionId(pub u64);
780
781impl Display for SubscriptionId {
782	fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
783		Display::fmt(&self.0, f)
784	}
785}
786
787impl Deref for SubscriptionId {
788	type Target = u64;
789
790	fn deref(&self) -> &Self::Target {
791		&self.0
792	}
793}
794
795impl PartialEq<u64> for SubscriptionId {
796	fn eq(&self, other: &u64) -> bool {
797		self.0.eq(other)
798	}
799}
800
801impl From<SubscriptionId> for u64 {
802	fn from(value: SubscriptionId) -> Self {
803		value.0
804	}
805}
806
807impl From<u64> for SubscriptionId {
808	fn from(value: u64) -> Self {
809		Self(value)
810	}
811}
812
813impl Serialize for SubscriptionId {
814	fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
815	where
816		S: Serializer,
817	{
818		serializer.serialize_u64(self.0)
819	}
820}
821
822impl<'de> Deserialize<'de> for SubscriptionId {
823	fn deserialize<D>(deserializer: D) -> Result<SubscriptionId, D::Error>
824	where
825		D: Deserializer<'de>,
826	{
827		struct U64Visitor;
828
829		impl Visitor<'_> for U64Visitor {
830			type Value = SubscriptionId;
831
832			fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
833				formatter.write_str("an unsigned 64-bit number")
834			}
835
836			fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
837				Ok(SubscriptionId(value))
838			}
839		}
840
841		deserializer.deserialize_u64(U64Visitor)
842	}
843}
844
845#[repr(transparent)]
846#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
847pub struct SequenceId(pub u64);
848
849impl Deref for SequenceId {
850	type Target = u64;
851
852	fn deref(&self) -> &Self::Target {
853		&self.0
854	}
855}
856
857impl PartialEq<u64> for SequenceId {
858	fn eq(&self, other: &u64) -> bool {
859		self.0.eq(other)
860	}
861}
862
863impl Serialize for SequenceId {
864	fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
865	where
866		S: Serializer,
867	{
868		serializer.serialize_u64(self.0)
869	}
870}
871
872impl<'de> Deserialize<'de> for SequenceId {
873	fn deserialize<D>(deserializer: D) -> Result<SequenceId, D::Error>
874	where
875		D: Deserializer<'de>,
876	{
877		struct U64Visitor;
878
879		impl Visitor<'_> for U64Visitor {
880			type Value = SequenceId;
881
882			fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
883				formatter.write_str("an unsigned 64-bit number")
884			}
885
886			fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
887				Ok(SequenceId(value))
888			}
889		}
890
891		deserializer.deserialize_u64(U64Visitor)
892	}
893}
894
895#[repr(transparent)]
896#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
897pub struct SubscriptionColumnId(pub u64);
898
899impl Display for SubscriptionColumnId {
900	fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
901		Display::fmt(&self.0, f)
902	}
903}
904
905impl Deref for SubscriptionColumnId {
906	type Target = u64;
907
908	fn deref(&self) -> &Self::Target {
909		&self.0
910	}
911}
912
913impl PartialEq<u64> for SubscriptionColumnId {
914	fn eq(&self, other: &u64) -> bool {
915		self.0.eq(other)
916	}
917}
918
919impl From<SubscriptionColumnId> for u64 {
920	fn from(value: SubscriptionColumnId) -> Self {
921		value.0
922	}
923}
924
925impl From<i32> for SubscriptionColumnId {
926	fn from(value: i32) -> Self {
927		Self(value as u64)
928	}
929}
930
931impl From<u64> for SubscriptionColumnId {
932	fn from(value: u64) -> Self {
933		Self(value)
934	}
935}
936
937impl Serialize for SubscriptionColumnId {
938	fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
939	where
940		S: Serializer,
941	{
942		serializer.serialize_u64(self.0)
943	}
944}
945
946impl<'de> Deserialize<'de> for SubscriptionColumnId {
947	fn deserialize<D>(deserializer: D) -> Result<SubscriptionColumnId, D::Error>
948	where
949		D: Deserializer<'de>,
950	{
951		struct U64Visitor;
952
953		impl Visitor<'_> for U64Visitor {
954			type Value = SubscriptionColumnId;
955
956			fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
957				formatter.write_str("an unsigned 64-bit number")
958			}
959
960			fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
961				Ok(SubscriptionColumnId(value))
962			}
963		}
964
965		deserializer.deserialize_u64(U64Visitor)
966	}
967}
968
969#[repr(transparent)]
970#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
971pub struct SeriesId(pub u64);
972
973impl Display for SeriesId {
974	fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
975		Display::fmt(&self.0, f)
976	}
977}
978
979impl Deref for SeriesId {
980	type Target = u64;
981
982	fn deref(&self) -> &Self::Target {
983		&self.0
984	}
985}
986
987impl PartialEq<u64> for SeriesId {
988	fn eq(&self, other: &u64) -> bool {
989		self.0.eq(other)
990	}
991}
992
993impl From<SeriesId> for u64 {
994	fn from(value: SeriesId) -> Self {
995		value.0
996	}
997}
998
999impl SeriesId {
1000	#[inline]
1001	pub fn to_u64(self) -> u64 {
1002		self.0
1003	}
1004}
1005
1006impl From<i32> for SeriesId {
1007	fn from(value: i32) -> Self {
1008		Self(value as u64)
1009	}
1010}
1011
1012impl From<u64> for SeriesId {
1013	fn from(value: u64) -> Self {
1014		Self(value)
1015	}
1016}
1017
1018impl Serialize for SeriesId {
1019	fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1020	where
1021		S: Serializer,
1022	{
1023		serializer.serialize_u64(self.0)
1024	}
1025}
1026
1027impl<'de> Deserialize<'de> for SeriesId {
1028	fn deserialize<D>(deserializer: D) -> Result<SeriesId, D::Error>
1029	where
1030		D: Deserializer<'de>,
1031	{
1032		struct U64Visitor;
1033
1034		impl Visitor<'_> for U64Visitor {
1035			type Value = SeriesId;
1036
1037			fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1038				formatter.write_str("an unsigned 64-bit number")
1039			}
1040
1041			fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1042				Ok(SeriesId(value))
1043			}
1044		}
1045
1046		deserializer.deserialize_u64(U64Visitor)
1047	}
1048}
1049
1050#[repr(transparent)]
1051#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
1052pub struct HandlerId(pub u64);
1053
1054impl Display for HandlerId {
1055	fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1056		Display::fmt(&self.0, f)
1057	}
1058}
1059
1060impl Deref for HandlerId {
1061	type Target = u64;
1062
1063	fn deref(&self) -> &Self::Target {
1064		&self.0
1065	}
1066}
1067
1068impl PartialEq<u64> for HandlerId {
1069	fn eq(&self, other: &u64) -> bool {
1070		self.0.eq(other)
1071	}
1072}
1073
1074impl From<HandlerId> for u64 {
1075	fn from(value: HandlerId) -> Self {
1076		value.0
1077	}
1078}
1079
1080impl From<i32> for HandlerId {
1081	fn from(value: i32) -> Self {
1082		Self(value as u64)
1083	}
1084}
1085
1086impl From<u64> for HandlerId {
1087	fn from(value: u64) -> Self {
1088		Self(value)
1089	}
1090}
1091
1092impl Serialize for HandlerId {
1093	fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1094	where
1095		S: Serializer,
1096	{
1097		serializer.serialize_u64(self.0)
1098	}
1099}
1100
1101impl<'de> Deserialize<'de> for HandlerId {
1102	fn deserialize<D>(deserializer: D) -> Result<HandlerId, D::Error>
1103	where
1104		D: Deserializer<'de>,
1105	{
1106		struct U64Visitor;
1107
1108		impl Visitor<'_> for U64Visitor {
1109			type Value = HandlerId;
1110
1111			fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1112				formatter.write_str("an unsigned 64-bit number")
1113			}
1114
1115			fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1116				Ok(HandlerId(value))
1117			}
1118		}
1119
1120		deserializer.deserialize_u64(U64Visitor)
1121	}
1122}
1123
1124#[repr(transparent)]
1125#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
1126pub struct MigrationId(pub u64);
1127
1128impl Display for MigrationId {
1129	fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1130		Display::fmt(&self.0, f)
1131	}
1132}
1133
1134impl Deref for MigrationId {
1135	type Target = u64;
1136
1137	fn deref(&self) -> &Self::Target {
1138		&self.0
1139	}
1140}
1141
1142impl PartialEq<u64> for MigrationId {
1143	fn eq(&self, other: &u64) -> bool {
1144		self.0.eq(other)
1145	}
1146}
1147
1148impl From<MigrationId> for u64 {
1149	fn from(value: MigrationId) -> Self {
1150		value.0
1151	}
1152}
1153
1154impl From<i32> for MigrationId {
1155	fn from(value: i32) -> Self {
1156		Self(value as u64)
1157	}
1158}
1159
1160impl From<u64> for MigrationId {
1161	fn from(value: u64) -> Self {
1162		Self(value)
1163	}
1164}
1165
1166impl Serialize for MigrationId {
1167	fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1168	where
1169		S: Serializer,
1170	{
1171		serializer.serialize_u64(self.0)
1172	}
1173}
1174
1175impl<'de> Deserialize<'de> for MigrationId {
1176	fn deserialize<D>(deserializer: D) -> Result<MigrationId, D::Error>
1177	where
1178		D: Deserializer<'de>,
1179	{
1180		struct U64Visitor;
1181
1182		impl Visitor<'_> for U64Visitor {
1183			type Value = MigrationId;
1184
1185			fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1186				formatter.write_str("an unsigned 64-bit number")
1187			}
1188
1189			fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1190				Ok(MigrationId(value))
1191			}
1192		}
1193
1194		deserializer.deserialize_u64(U64Visitor)
1195	}
1196}
1197
1198#[repr(transparent)]
1199#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
1200pub struct MigrationEventId(pub u64);
1201
1202impl Display for MigrationEventId {
1203	fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1204		Display::fmt(&self.0, f)
1205	}
1206}
1207
1208impl Deref for MigrationEventId {
1209	type Target = u64;
1210
1211	fn deref(&self) -> &Self::Target {
1212		&self.0
1213	}
1214}
1215
1216impl PartialEq<u64> for MigrationEventId {
1217	fn eq(&self, other: &u64) -> bool {
1218		self.0.eq(other)
1219	}
1220}
1221
1222impl From<MigrationEventId> for u64 {
1223	fn from(value: MigrationEventId) -> Self {
1224		value.0
1225	}
1226}
1227
1228impl From<i32> for MigrationEventId {
1229	fn from(value: i32) -> Self {
1230		Self(value as u64)
1231	}
1232}
1233
1234impl From<u64> for MigrationEventId {
1235	fn from(value: u64) -> Self {
1236		Self(value)
1237	}
1238}
1239
1240impl Serialize for MigrationEventId {
1241	fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1242	where
1243		S: Serializer,
1244	{
1245		serializer.serialize_u64(self.0)
1246	}
1247}
1248
1249impl<'de> Deserialize<'de> for MigrationEventId {
1250	fn deserialize<D>(deserializer: D) -> Result<MigrationEventId, D::Error>
1251	where
1252		D: Deserializer<'de>,
1253	{
1254		struct U64Visitor;
1255
1256		impl Visitor<'_> for U64Visitor {
1257			type Value = MigrationEventId;
1258
1259			fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1260				formatter.write_str("an unsigned 64-bit number")
1261			}
1262
1263			fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1264				Ok(MigrationEventId(value))
1265			}
1266		}
1267
1268		deserializer.deserialize_u64(U64Visitor)
1269	}
1270}
1271
1272#[repr(transparent)]
1273#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
1274pub struct SourceId(pub u64);
1275
1276impl Display for SourceId {
1277	fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1278		Display::fmt(&self.0, f)
1279	}
1280}
1281
1282impl Deref for SourceId {
1283	type Target = u64;
1284
1285	fn deref(&self) -> &Self::Target {
1286		&self.0
1287	}
1288}
1289
1290impl PartialEq<u64> for SourceId {
1291	fn eq(&self, other: &u64) -> bool {
1292		self.0.eq(other)
1293	}
1294}
1295
1296impl From<SourceId> for u64 {
1297	fn from(value: SourceId) -> Self {
1298		value.0
1299	}
1300}
1301
1302impl From<u64> for SourceId {
1303	fn from(value: u64) -> Self {
1304		Self(value)
1305	}
1306}
1307
1308impl Serialize for SourceId {
1309	fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1310	where
1311		S: Serializer,
1312	{
1313		serializer.serialize_u64(self.0)
1314	}
1315}
1316
1317impl<'de> Deserialize<'de> for SourceId {
1318	fn deserialize<D>(deserializer: D) -> Result<SourceId, D::Error>
1319	where
1320		D: Deserializer<'de>,
1321	{
1322		struct U64Visitor;
1323
1324		impl Visitor<'_> for U64Visitor {
1325			type Value = SourceId;
1326
1327			fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1328				formatter.write_str("an unsigned 64-bit number")
1329			}
1330
1331			fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1332				Ok(SourceId(value))
1333			}
1334		}
1335
1336		deserializer.deserialize_u64(U64Visitor)
1337	}
1338}
1339
1340#[repr(transparent)]
1341#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
1342pub struct SinkId(pub u64);
1343
1344impl Display for SinkId {
1345	fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1346		Display::fmt(&self.0, f)
1347	}
1348}
1349
1350impl Deref for SinkId {
1351	type Target = u64;
1352
1353	fn deref(&self) -> &Self::Target {
1354		&self.0
1355	}
1356}
1357
1358impl PartialEq<u64> for SinkId {
1359	fn eq(&self, other: &u64) -> bool {
1360		self.0.eq(other)
1361	}
1362}
1363
1364impl From<SinkId> for u64 {
1365	fn from(value: SinkId) -> Self {
1366		value.0
1367	}
1368}
1369
1370impl From<u64> for SinkId {
1371	fn from(value: u64) -> Self {
1372		Self(value)
1373	}
1374}
1375
1376impl Serialize for SinkId {
1377	fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1378	where
1379		S: Serializer,
1380	{
1381		serializer.serialize_u64(self.0)
1382	}
1383}
1384
1385impl<'de> Deserialize<'de> for SinkId {
1386	fn deserialize<D>(deserializer: D) -> Result<SinkId, D::Error>
1387	where
1388		D: Deserializer<'de>,
1389	{
1390		struct U64Visitor;
1391
1392		impl Visitor<'_> for U64Visitor {
1393			type Value = SinkId;
1394
1395			fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1396				formatter.write_str("an unsigned 64-bit number")
1397			}
1398
1399			fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1400				Ok(SinkId(value))
1401			}
1402		}
1403
1404		deserializer.deserialize_u64(U64Visitor)
1405	}
1406}