use serde::{Deserialize, Serialize};
use std::{fmt, hash::Hash};
use xor_name::XorName;
#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub struct ChunkAddress(XorName);
impl ChunkAddress {
pub fn new(xor_name: XorName) -> Self {
Self(xor_name)
}
pub fn xorname(&self) -> &XorName {
&self.0
}
pub fn to_hex(&self) -> String {
hex::encode(self.0)
}
}
impl std::fmt::Debug for ChunkAddress {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "ChunkAddress({})", &self.to_hex()[0..6])
}
}