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