ephemeris_documents/
columns.rs1use std::num::NonZeroUsize;
4
5use crate::error::ColumnsError;
6
7#[derive(Debug, Clone, Copy, PartialEq, Eq)]
9pub(crate) struct Columns(NonZeroUsize);
10
11impl Columns {
12 pub(crate) const fn new(columns: usize) -> Option<Self> {
13 match NonZeroUsize::new(columns) {
14 Some(columns) => Some(Self(columns)),
15 None => None,
16 }
17 }
18
19 pub(crate) const fn get(self) -> usize {
20 self.0.get()
21 }
22}
23
24impl TryFrom<usize> for Columns {
25 type Error = ColumnsError;
26
27 fn try_from(columns: usize) -> Result<Self, Self::Error> {
28 Self::new(columns).ok_or(ColumnsError::Zero)
29 }
30}