use core::cmp::Ordering;
use core::fmt;
use core::hash::{Hash, Hasher};
pub struct AvailableSpace {
available_bytes: u64,
}
impl AvailableSpace {
#[must_use]
pub fn new(available_bytes: u64) -> Self {
Self { available_bytes }
}
#[must_use]
pub fn available_bytes(&self) -> u64 {
self.available_bytes
}
}
impl Clone for AvailableSpace {
fn clone(&self) -> Self {
Self::new(self.available_bytes)
}
}
impl fmt::Debug for AvailableSpace {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter
.debug_struct("AvailableSpace")
.field("available_bytes", &self.available_bytes)
.finish()
}
}
impl fmt::Display for AvailableSpace {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(formatter, "{} bytes available", self.available_bytes)
}
}
impl PartialEq for AvailableSpace {
fn eq(&self, other: &Self) -> bool {
self.available_bytes == other.available_bytes
}
}
impl Eq for AvailableSpace {}
impl PartialOrd for AvailableSpace {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Ord for AvailableSpace {
fn cmp(&self, other: &Self) -> Ordering {
self.available_bytes.cmp(&other.available_bytes)
}
}
impl Hash for AvailableSpace {
fn hash<H>(&self, state: &mut H)
where
H: Hasher,
{
self.available_bytes.hash(state);
}
}