Use irc-stream.

This commit is contained in:
Thelie 2021-04-27 23:38:21 +02:00
parent eece7a1155
commit e7abea7bfc

View file

@ -23,6 +23,7 @@ use std::{
net::TcpStream,
};
use irc_proto;
use irc_stream::{IrcStream, IrcRead, IrcWrite};
use toml::Value;
use native_tls::{TlsConnector,TlsStream};
@ -86,16 +87,18 @@ fn main() {
// Weird workaround for multitrait dyn pointer
// https://github.com/rust-lang/rfcs/issues/2035
// would be a charm...
trait ReadWrite: Read + Write {}
impl<T: Read + Write> ReadWrite for T {}
let mut stream: &dyn ReadWrite;
trait IrcReadWrite: IrcRead + IrcWrite {}
impl<T: IrcRead + IrcWrite> IrcReadWrite for T {}
let mut stream: &dyn IrcReadWrite;
if config["tls"].as_bool().unwrap() == true {
stream = &connect_irc_tls(&config).unwrap();
stream = &IrcStream::new(connect_irc_tls(&config).unwrap());
} else {
stream = &connect_irc(&config).unwrap();
stream = &IrcStream::new(connect_irc(&config).unwrap());
}
//let irc_stream = IrcStream::new(stream);
// TODO: Identify with irc server
//stream.write(irc_proto.Message{
// tags: None,