Skip to content

Commit 924a3c4

Browse files
committedJun 6, 2022
Bump to Rust 2021 Edition
1 parent 26bf34c commit 924a3c4

11 files changed

+27
-28
lines changed
 

‎Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[package]
2-
32
name = "rust-xmpp"
43
version = "0.0.0"
54
authors = [ "florob@babelmonkeys.de" ]
5+
edition = "2021"
66

77
[lib]
88
name = "xmpp"

‎src/auth/scram.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl ScramAuth {
9696

9797

9898
let data = check!(str::from_utf8(data).ok(), "SCRAM: Server sent non-UTF-8 data");
99-
let (nonce, salt, iter) = try!(parse_server_first(data));
99+
let (nonce, salt, iter) = parse_server_first(data)?;
100100

101101
{
102102
let cnonce = match self.state {

‎src/lib.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ use std::io::{Write, BufReader};
1515
use std::net::TcpStream;
1616
use std::ops::Deref;
1717

18-
use auth::Authenticator;
19-
use auth::{PlainAuth, ScramAuth, AnonAuth};
20-
use non_stanzas::{AuthStart, AuthResponse, DefinedCondition, StreamStart, StreamEnd};
21-
use non_stanzas::{StreamError, StartTls};
22-
use read_str::ReadString;
23-
use stanzas::{AStanza, Stanza, IqType};
24-
use xmpp_send::XmppSend;
25-
use xmpp_socket::XmppSocket;
18+
use crate::auth::Authenticator;
19+
use crate::auth::{PlainAuth, ScramAuth, AnonAuth};
20+
use crate::non_stanzas::{AuthStart, AuthResponse, DefinedCondition, StreamStart, StreamEnd};
21+
use crate::non_stanzas::{StreamError, StartTls};
22+
use crate::read_str::ReadString;
23+
use crate::stanzas::{AStanza, Stanza, IqType};
24+
use crate::xmpp_send::XmppSend;
25+
use crate::xmpp_socket::XmppSocket;
2626

2727
mod auth;
2828
mod non_stanzas;
@@ -112,9 +112,9 @@ impl XmppStream {
112112
pub fn connect(&mut self) -> io::Result<()> {
113113
let stream = {
114114
let address = &self.handler.domain[..];
115-
try!(TcpStream::connect(&(address, 5222)))
115+
TcpStream::connect(&(address, 5222))?
116116
};
117-
let stream_read = try!(stream.try_clone());
117+
let stream_read = stream.try_clone()?;
118118

119119
self.handler.socket = XmppSocket::Tcp(BufReader::new(stream_read), stream);
120120
self.handler.start_stream()
@@ -226,7 +226,7 @@ impl XmppHandler {
226226
fn start_stream(&mut self) -> io::Result<()> {
227227
let stream_start = StreamStart { to: &self.domain };
228228
println!("Out: {}", stream_start);
229-
try!(stream_start.xmpp_send(&mut self.socket));
229+
stream_start.xmpp_send(&mut self.socket)?;
230230
self.socket.flush()
231231
}
232232

@@ -241,7 +241,7 @@ impl XmppHandler {
241241

242242
fn send<T: XmppSend>(&mut self, data: T) -> io::Result<()> {
243243
println!("Out: {}", data);
244-
try!(data.xmpp_send(&mut self.socket));
244+
data.xmpp_send(&mut self.socket)?;
245245
self.socket.flush()
246246
}
247247

@@ -275,7 +275,7 @@ impl XmppHandler {
275275

276276
fn handle_starttls(&mut self, starttls: xml::Element) -> io::Result<()> {
277277
if starttls.name == "proceed" {
278-
try!(self.socket.starttls(&self.domain));
278+
self.socket.starttls(&self.domain)?;
279279
return self.start_stream();
280280
}
281281
Ok(())

‎src/non_stanzas.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// Please see the COPYING file for more information.
66

77
use std::fmt;
8-
use ns;
9-
use xmpp_send::XmppSend;
8+
use crate::ns;
9+
use crate::xmpp_send::XmppSend;
1010

1111
#[derive(Debug)]
1212
pub struct StreamStart<'a> {
@@ -152,9 +152,9 @@ pub struct StreamError<'a> {
152152

153153
impl<'a> fmt::Display for StreamError<'a> {
154154
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
155-
try!(write!(f, "<stream:error>{}", self.cond));
155+
write!(f, "<stream:error>{}", self.cond)?;
156156
if let Some(text) = self.text {
157-
try!(write!(f, "<text xmlns='{}'>{}</text>", ns::STREAM_ERRORS, text));
157+
write!(f, "<text xmlns='{}'>{}</text>", ns::STREAM_ERRORS, text)?;
158158
}
159159
write!(f, "</stream:error>")
160160
}

‎src/read_str.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub trait ReadString {
4141
impl<T: BufRead> ReadString for T {
4242
fn read_str(&mut self) -> io::Result<String> {
4343
let (result, last) = {
44-
let available = try!(self.fill_buf());
44+
let available = self.fill_buf()?;
4545
let len = available.len();
4646
let mut last = if len < 3 { 0 } else { len - 3 };
4747
while last < len {

‎src/stanzas/iq.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Please see the COPYING file for more information.
66

77
use xml;
8-
use ns;
8+
use crate::ns;
99

1010
use super::{Stanza, StanzaType};
1111

‎src/stanzas/message.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Please see the COPYING file for more information.
66

77
use xml;
8-
use ns;
8+
use crate::ns;
99

1010
use super::{Stanza, StanzaType};
1111

‎src/stanzas/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Please see the COPYING file for more information.
66

77
use xml;
8-
use ns;
8+
use crate::ns;
99

1010
pub use self::iq::Iq;
1111
pub use self::iq::IqType;
@@ -200,7 +200,7 @@ macro_rules! impl_Stanza(
200200
}
201201
}
202202

203-
fn error_reply(&self, ty: ::stanzas::ErrorType, cond: ::stanzas::DefinedCondition,
203+
fn error_reply(&self, ty: crate::stanzas::ErrorType, cond: crate::stanzas::DefinedCondition,
204204
text: Option<String>) -> $kind
205205
{
206206
let to = self.from().map(|x| x.into());

‎src/stanzas/presence.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Please see the COPYING file for more information.
66

77
use xml;
8-
use ns;
8+
use crate::ns;
99

1010
use super::{Stanza, StanzaType};
1111

‎src/xmpp_send.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
// Please see the COPYING file for more information.
66

77
use std::{fmt, io};
8-
use xml;
98

10-
use stanzas;
9+
use crate::stanzas;
1110

1211
pub trait XmppSend: fmt::Display {
1312
fn xmpp_send<W: io::Write>(&self, w: &mut W) -> io::Result<()> {

‎src/xmpp_socket.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::mem;
1010
use std::net::TcpStream;
1111
use openssl::ssl::{SslConnector, SslStream, SslMethod};
1212

13-
use read_str::ReadString;
13+
use crate::read_str::ReadString;
1414

1515
pub enum XmppSocket {
1616
Tcp(BufReader<TcpStream>, TcpStream),

0 commit comments

Comments
 (0)
Please sign in to comment.