use std::fmt;
use crate::row_address::RowAddress;
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[non_exhaustive]
pub enum RowId {
Stored(RowAddress),
Added(u32),
}
impl RowId {
#[must_use]
pub const fn address(self) -> Option<RowAddress> {
match self {
Self::Stored(address) => Some(address),
Self::Added(_) => None,
}
}
}
impl From<RowAddress> for RowId {
fn from(address: RowAddress) -> Self {
Self::Stored(address)
}
}
impl fmt::Display for RowId {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Stored(address) => address.fmt(formatter),
Self::Added(number) => write!(formatter, "added row {number}"),
}
}
}