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