Offer {Resource,Node,Domain}Ref on Jid API
This provides a non-copying API, which is generally favourable. The other accessors were removed, because the intent was to provide this "most sensible" API via the "default" (i.e. shortest, most concisely named) functions.
This commit is contained in:
parent
45f1567ff2
commit
7fce1146e0
10 changed files with 86 additions and 133 deletions
|
|
@ -15,8 +15,8 @@ pub async fn bind<S: AsyncRead + AsyncWrite + Unpin>(
|
|||
if stream.stream_features.can_bind() {
|
||||
let resource = stream
|
||||
.jid
|
||||
.resource_str()
|
||||
.and_then(|resource| Some(resource.to_owned()));
|
||||
.resource()
|
||||
.and_then(|resource| Some(resource.to_string()));
|
||||
let iq = Iq::from_set(BIND_REQ_ID, BindQuery::new(resource));
|
||||
stream.send_stanza(iq).await?;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ pub async fn client_login<C: ServerConnector>(
|
|||
jid: Jid,
|
||||
password: String,
|
||||
) -> Result<XMPPStream<C::Stream>, Error> {
|
||||
let username = jid.node_str().unwrap();
|
||||
let username = jid.node().unwrap().as_str();
|
||||
let password = password;
|
||||
|
||||
let xmpp_stream = server.connect(&jid, ns::JABBER_CLIENT).await?;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ impl ServerConnector for ServerConfig {
|
|||
// TCP connection
|
||||
let tcp_stream = match self {
|
||||
ServerConfig::UseSrv => {
|
||||
connect_with_srv(jid.domain_str(), "_xmpp-client._tcp", 5222).await?
|
||||
connect_with_srv(jid.domain().as_str(), "_xmpp-client._tcp", 5222).await?
|
||||
}
|
||||
ServerConfig::Manual { host, port } => connect_to_host(host.as_str(), *port).await?,
|
||||
};
|
||||
|
|
@ -126,7 +126,7 @@ async fn get_tls_stream<S: AsyncRead + AsyncWrite + Unpin>(
|
|||
async fn get_tls_stream<S: AsyncRead + AsyncWrite + Unpin>(
|
||||
xmpp_stream: XMPPStream<S>,
|
||||
) -> Result<TlsStream<S>, Error> {
|
||||
let domain = xmpp_stream.jid.domain_str().to_owned();
|
||||
let domain = xmpp_stream.jid.domain().to_string();
|
||||
let domain = ServerName::try_from(domain.as_str())?;
|
||||
let stream = xmpp_stream.into_inner();
|
||||
let mut root_store = RootCertStore::empty();
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ pub async fn start<S: AsyncRead + AsyncWrite + Unpin>(
|
|||
ns: String,
|
||||
) -> Result<XMPPStream<S>, Error> {
|
||||
let attrs = [
|
||||
("to".to_owned(), jid.domain_str().to_owned()),
|
||||
("to".to_owned(), jid.domain().to_string()),
|
||||
("version".to_owned(), "1.0".to_owned()),
|
||||
("xmlns".to_owned(), ns.clone()),
|
||||
("xmlns:stream".to_owned(), ns::STREAM.to_owned()),
|
||||
|
|
|
|||
Loading…
Reference in a new issue