mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
client: add new_with_jid() to reuse parsed Jid
Should fix Gitlab issue #2
This commit is contained in:
parent
8e9d826d4e
commit
49c0f6e7a6
1 changed files with 9 additions and 2 deletions
|
@ -45,12 +45,19 @@ impl Client {
|
|||
/// and yield events.
|
||||
pub fn new(jid: &str, password: &str) -> Result<Self, JidParseError> {
|
||||
let jid = Jid::from_str(jid)?;
|
||||
let client = Self::new_with_jid(jid, password);
|
||||
Ok(client)
|
||||
}
|
||||
|
||||
/// Start a new client given that the JID is already parsed.
|
||||
pub fn new_with_jid(jid: Jid, password: &str) -> Self {
|
||||
let password = password.to_owned();
|
||||
let connect = Self::make_connect(jid.clone(), password.clone());
|
||||
Ok(Client {
|
||||
let client = Client {
|
||||
jid,
|
||||
state: ClientState::Connecting(Box::new(connect)),
|
||||
})
|
||||
};
|
||||
client
|
||||
}
|
||||
|
||||
fn make_connect(jid: Jid, password: String) -> impl Future<Item = XMPPStream, Error = Error> {
|
||||
|
|
Loading…
Reference in a new issue