From e7abea7bfcc1480af805270b0b067ecbedc49d26 Mon Sep 17 00:00:00 2001 From: Thelie Date: Tue, 27 Apr 2021 23:38:21 +0200 Subject: [PATCH] Use irc-stream. --- src/main.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index efd072d..761ca37 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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 ReadWrite for T {} - let mut stream: &dyn ReadWrite; + trait IrcReadWrite: IrcRead + IrcWrite {} + impl 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,