forked from lavina/lavina
65 lines
1.9 KiB
Rust
65 lines
1.9 KiB
Rust
|
|
use tokio::io::{AsyncWrite, AsyncWriteExt};
|
||
|
|
|
||
|
|
use lavina_core::prelude::Str;
|
||
|
|
use proto_irc::response::SendResponseBody;
|
||
|
|
|
||
|
|
pub struct ERR_NOSUCHNICK_401 {
|
||
|
|
client: Str,
|
||
|
|
nick: Str,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl ERR_NOSUCHNICK_401 {
|
||
|
|
pub fn new(client: Str, nick: Str) -> Self {
|
||
|
|
ERR_NOSUCHNICK_401 { client, nick }
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
struct ERR_NOSUCHSERVER_402 {
|
||
|
|
client: Str,
|
||
|
|
/// target parameter in WHOIS
|
||
|
|
/// example: `/whois <target> <nick>`
|
||
|
|
server_name: Str,
|
||
|
|
}
|
||
|
|
pub struct ERR_NONICKNAMEGIVEN_431 {
|
||
|
|
client: Str,
|
||
|
|
}
|
||
|
|
impl ERR_NONICKNAMEGIVEN_431 {
|
||
|
|
pub fn new(client: Str) -> Self {
|
||
|
|
ERR_NONICKNAMEGIVEN_431 { client }
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
impl SendResponseBody for ERR_NOSUCHNICK_401 {
|
||
|
|
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 SendResponseBody for ERR_NONICKNAMEGIVEN_431 {
|
||
|
|
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 SendResponseBody for ERR_NOSUCHSERVER_402 {
|
||
|
|
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(())
|
||
|
|
}
|
||
|
|
}
|