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