mirror of https://gitlab.com/xmpp-rs/xmpp-rs.git
Added doc comment to upload_file_with
This commit is contained in:
parent
fde92f2aee
commit
b630ae44c5
|
@ -90,7 +90,7 @@ impl<C: ServerConnector> Agent<C> {
|
|||
event_loop::wait_for_events(self).await
|
||||
}
|
||||
|
||||
pub async fn upload_file_with(&mut self, service: &str, path: &Path) {
|
||||
pub async fn upload_file_with(&mut self, service: Jid, path: &Path) {
|
||||
upload::send::upload_file_with(self, service, path).await
|
||||
}
|
||||
|
||||
|
|
|
@ -14,21 +14,21 @@ use tokio_xmpp::{
|
|||
|
||||
use crate::Agent;
|
||||
|
||||
pub async fn upload_file_with<C: ServerConnector>(
|
||||
agent: &mut Agent<C>,
|
||||
service: &str,
|
||||
path: &Path,
|
||||
) {
|
||||
/// Upload a file to the HTTP server associated with a given Jid.
|
||||
///
|
||||
/// # Arguments
|
||||
/// - `agent`: The XMPP agent through which to negociate the request.
|
||||
/// - `service`: The Jid of the HTTP server to upload the file to.
|
||||
/// - `path`: The path to the file to upload.
|
||||
pub async fn upload_file_with<C: ServerConnector>(agent: &mut Agent<C>, service: Jid, path: &Path) {
|
||||
// Create the IQ request to upload the file.
|
||||
let request = Iq::from_get("upload1", slotslot_request_for_file(path).await)
|
||||
.with_to(service.parse::<Jid>().unwrap().clone());
|
||||
let request =
|
||||
Iq::from_get("upload1", slotslot_request_for_file(path).await).with_to(service.clone());
|
||||
|
||||
// Record the upload request so we can handle the response later.
|
||||
agent.uploads.push((
|
||||
String::from("upload1"),
|
||||
service.parse::<Jid>().unwrap(),
|
||||
path.to_path_buf(),
|
||||
));
|
||||
agent
|
||||
.uploads
|
||||
.push((String::from("upload1"), service, path.to_path_buf()));
|
||||
|
||||
// Send the request to the server.
|
||||
agent.client.send_stanza(request.into()).await.unwrap();
|
||||
|
|
Loading…
Reference in New Issue