1use std::fmt;
4
5use crate::row_address::RowAddress;
6
7#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
9#[non_exhaustive]
10pub enum RowId {
11 Stored(RowAddress),
13 Added(u32),
15}
16
17impl RowId {
18 #[must_use]
20 pub const fn address(self) -> Option<RowAddress> {
21 match self {
22 Self::Stored(address) => Some(address),
23 Self::Added(_) => None,
24 }
25 }
26}
27
28impl From<RowAddress> for RowId {
29 fn from(address: RowAddress) -> Self {
30 Self::Stored(address)
31 }
32}
33
34impl fmt::Display for RowId {
35 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
36 match self {
37 Self::Stored(address) => address.fmt(formatter),
38 Self::Added(number) => write!(formatter, "added row {number}"),
39 }
40 }
41}