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