replace try! with ? syntax
This commit is contained in:
parent
b929a3c71e
commit
b82237f422
4 changed files with 8 additions and 12 deletions
|
@ -60,7 +60,7 @@ impl<S: AsyncWrite> ClientAuth<S> {
|
|||
let name = mech.name().to_owned();
|
||||
if mech_names.iter().any(|name1| *name1 == name) {
|
||||
println!("SASL mechanism selected: {:?}", name);
|
||||
let initial = try!(mech.initial());
|
||||
let initial = mech.initial()?;
|
||||
let mut this = ClientAuth {
|
||||
state: ClientAuthState::Invalid,
|
||||
mechanism: mech,
|
||||
|
@ -111,7 +111,7 @@ impl<S: AsyncRead + AsyncWrite> Future for ClientAuth<S> {
|
|||
match stream.poll() {
|
||||
Ok(Async::Ready(Some(Packet::Stanza(stanza)))) => {
|
||||
if let Ok(challenge) = Challenge::try_from(stanza.clone()) {
|
||||
let response = try!(self.mechanism.response(&challenge.data));
|
||||
let response = self.mechanism.response(&challenge.data)?;
|
||||
self.send(stream, Response { data: response });
|
||||
self.poll()
|
||||
} else if let Ok(_) = Success::try_from(stanza.clone()) {
|
||||
|
|
|
@ -45,7 +45,7 @@ impl Client {
|
|||
/// Start polling the returned instance so that it will connect
|
||||
/// and yield events.
|
||||
pub fn new(jid: &str, password: &str, handle: Handle) -> Result<Self, JidParseError> {
|
||||
let jid = try!(Jid::from_str(jid));
|
||||
let jid = Jid::from_str(jid)?;
|
||||
let password = password.to_owned();
|
||||
let connect = Self::make_connect(jid.clone(), password.clone(), handle);
|
||||
Ok(Client {
|
||||
|
|
|
@ -42,7 +42,7 @@ impl Component {
|
|||
/// Start polling the returned instance so that it will connect
|
||||
/// and yield events.
|
||||
pub fn new(jid: &str, password: &str, server: &str, port: u16, handle: Handle) -> Result<Self, JidParseError> {
|
||||
let jid = try!(Jid::from_str(jid));
|
||||
let jid = Jid::from_str(jid)?;
|
||||
let password = password.to_owned();
|
||||
let connect = Self::make_connect(jid.clone(), password, server, port, handle);
|
||||
Ok(Component {
|
||||
|
|
|
@ -18,14 +18,10 @@ pub struct Connecter {
|
|||
|
||||
impl Connecter {
|
||||
pub fn from_lookup(handle: Handle, domain: &str, srv: &str, fallback_port: u16) -> Result<Connecter, String> {
|
||||
let domain = try!(
|
||||
DNameBuf::from_str(domain)
|
||||
.map_err(|e| format!("{}", e))
|
||||
);
|
||||
let srv = try!(
|
||||
DNameBuf::from_str(srv)
|
||||
.map_err(|e| format!("{}", e))
|
||||
);
|
||||
let domain = DNameBuf::from_str(domain)
|
||||
.map_err(|e| format!("{}", e))?;
|
||||
let srv = DNameBuf::from_str(srv)
|
||||
.map_err(|e| format!("{}", e))?;
|
||||
|
||||
let resolver = Resolver::new(&handle);
|
||||
let lookup = lookup_srv(resolver.clone(), srv, domain, fallback_port);
|
||||
|
|
Loading…
Reference in a new issue