vortex_layout/segments/
mod.rs1mod cache;
5mod shared;
6mod sink;
7mod source;
8
9#[cfg(any(test, feature = "test-harness"))]
10mod test;
11
12use std::fmt::Display;
13use std::ops::Deref;
14
15pub use cache::*;
16pub use shared::*;
17pub use sink::*;
18pub use source::*;
19#[cfg(any(test, feature = "test-harness"))]
20pub use test::*;
21use vortex_error::VortexError;
22
23#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
26pub struct SegmentId(u32);
27
28impl From<u32> for SegmentId {
29 fn from(value: u32) -> Self {
30 Self(value)
31 }
32}
33
34impl TryFrom<usize> for SegmentId {
35 type Error = VortexError;
36
37 fn try_from(value: usize) -> Result<Self, Self::Error> {
38 Ok(Self::from(u32::try_from(value)?))
39 }
40}
41
42impl Deref for SegmentId {
43 type Target = u32;
44
45 fn deref(&self) -> &Self::Target {
46 &self.0
47 }
48}
49
50impl Display for SegmentId {
51 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
52 write!(f, "SegmentId({})", self.0)
53 }
54}