#![deny(clippy::pedantic)]
#![allow(clippy::missing_errors_doc)]
use std::{hash::Hash, sync::Arc};
use bytes::Bytes;
pub mod protocol;
#[derive(Debug, Clone)]
pub struct UserIdent {
nick: RegisteredNick,
username: Arc<String>,
host: Arc<String>,
}
#[derive(Debug, Clone)]
#[allow(clippy::clippy::module_name_repetitions)]
pub struct RegisteredNick(Arc<arc_swap::ArcSwapOption<Bytes>>);
impl RegisteredNick {
#[must_use]
#[allow(clippy::new_without_default)]
pub fn new() -> Self {
Self(Arc::new(arc_swap::ArcSwapOption::empty()))
}
#[must_use]
pub fn load(&self) -> Option<Arc<Bytes>> {
self.0.load().clone()
}
pub fn set(&self, nick: Arc<Bytes>) {
self.0.store(Some(nick))
}
}
impl Hash for RegisteredNick {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
Arc::as_ptr(&self.0).hash(state)
}
}
impl PartialEq for RegisteredNick {
fn eq(&self, other: &Self) -> bool {
Arc::ptr_eq(&self.0, &other.0)
}
}
impl Eq for RegisteredNick {}