#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Srid(u32);
impl Srid {
pub const UNKNOWN: Srid = Srid(0);
#[must_use]
pub const fn new(code: u32) -> Self {
Self(code)
}
#[must_use]
pub const fn get(self) -> u32 {
self.0
}
}
impl core::fmt::Display for Srid {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.0)
}
}
#[cfg(test)]
mod tests {
use alloc::format;
use super::Srid;
#[test]
fn zero_is_unknown() {
assert_eq!(Srid::new(0), Srid::UNKNOWN);
assert_eq!(Srid::UNKNOWN.get(), 0);
}
#[test]
fn upper_bound_round_trips() {
assert_eq!(Srid::new(u32::MAX).get(), u32::MAX);
}
#[test]
fn display_is_the_bare_decimal() {
assert_eq!(format!("{}", Srid::new(4326)), "4326");
}
}