forked from lavina/lavina
68 lines
1.9 KiB
Rust
68 lines
1.9 KiB
Rust
use tokio::io::{AsyncWrite, AsyncWriteExt};
|
|
|
|
use crate::{prelude::Str, response::WriteResponse};
|
|
|
|
/// ErrNoSuchNick401
|
|
pub struct ErrNoSuchNick401 {
|
|
client: Str,
|
|
nick: Str,
|
|
}
|
|
|
|
impl ErrNoSuchNick401 {
|
|
pub fn new(client: Str, nick: Str) -> Self {
|
|
ErrNoSuchNick401 { client, nick }
|
|
}
|
|
}
|
|
|
|
/// ErrNoSuchServer402
|
|
struct ErrNoSuchServer402 {
|
|
client: Str,
|
|
/// target parameter in WHOIS
|
|
/// example: `/whois <target> <nick>`
|
|
server_name: Str,
|
|
}
|
|
|
|
/// ErrNoNicknameGiven431
|
|
pub struct ErrNoNicknameGiven431 {
|
|
client: Str,
|
|
}
|
|
impl ErrNoNicknameGiven431 {
|
|
pub fn new(client: Str) -> Self {
|
|
ErrNoNicknameGiven431 { client }
|
|
}
|
|
}
|
|
|
|
impl WriteResponse for ErrNoSuchNick401 {
|
|
async fn write_response(&self, writer: &mut (impl AsyncWrite + Unpin)) -> std::io::Result<()> {
|
|
writer.write_all(b"401 ").await?;
|
|
writer.write_all(self.client.as_bytes()).await?;
|
|
writer.write_all(b" ").await?;
|
|
writer.write_all(self.nick.as_bytes()).await?;
|
|
writer.write_all(b" :").await?;
|
|
writer.write_all("No such nick/channel".as_bytes()).await?;
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
impl WriteResponse for ErrNoNicknameGiven431 {
|
|
async fn write_response(&self, writer: &mut (impl AsyncWrite + Unpin)) -> std::io::Result<()> {
|
|
writer.write_all(b"431").await?;
|
|
writer.write_all(self.client.as_bytes()).await?;
|
|
writer.write_all(b" :").await?;
|
|
writer.write_all("No nickname given".as_bytes()).await?;
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
impl WriteResponse for ErrNoSuchServer402 {
|
|
async fn write_response(&self, writer: &mut (impl AsyncWrite + Unpin)) -> std::io::Result<()> {
|
|
writer.write_all(b"402 ").await?;
|
|
writer.write_all(self.client.as_bytes()).await?;
|
|
writer.write_all(b" ").await?;
|
|
writer.write_all(self.server_name.as_bytes()).await?;
|
|
writer.write_all(b" :").await?;
|
|
writer.write_all("No such server".as_bytes()).await?;
|
|
Ok(())
|
|
}
|
|
}
|