use core::cmp::Ordering;
use crate::rr::{LowerName, RecordType};
#[derive(Eq, PartialEq, Debug, Hash, Clone)]
pub struct RrKey {
pub name: LowerName,
pub record_type: RecordType,
}
impl RrKey {
pub fn new(name: LowerName, record_type: RecordType) -> Self {
Self { name, record_type }
}
pub fn name(&self) -> &LowerName {
&self.name
}
}
impl PartialOrd for RrKey {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Ord for RrKey {
fn cmp(&self, other: &Self) -> Ordering {
let order = self.name.cmp(&other.name);
if order == Ordering::Equal {
self.record_type.cmp(&other.record_type)
} else {
order
}
}
}