xmpp crate now supports ServerConnector
This commit is contained in:
parent
733d005f51
commit
38bfba4a18
20 changed files with 115 additions and 54 deletions
|
|
@ -10,6 +10,7 @@ use reqwest::{
|
|||
use std::path::PathBuf;
|
||||
use tokio::fs::File;
|
||||
use tokio_util::codec::{BytesCodec, FramedRead};
|
||||
use tokio_xmpp::connect::ServerConnector;
|
||||
use tokio_xmpp::{
|
||||
parsers::http_upload::{Header as HttpUploadHeader, SlotResult},
|
||||
Element, Jid,
|
||||
|
|
@ -17,11 +18,11 @@ use tokio_xmpp::{
|
|||
|
||||
use crate::{Agent, Event};
|
||||
|
||||
pub async fn handle_upload_result(
|
||||
pub async fn handle_upload_result<C: ServerConnector>(
|
||||
from: &Jid,
|
||||
iqid: String,
|
||||
elem: Element,
|
||||
agent: &mut Agent,
|
||||
agent: &mut Agent<C>,
|
||||
) -> impl IntoIterator<Item = Event> {
|
||||
let mut res: Option<(usize, PathBuf)> = None;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
use std::path::Path;
|
||||
use tokio::fs::File;
|
||||
use tokio_xmpp::connect::ServerConnector;
|
||||
use tokio_xmpp::{
|
||||
parsers::{http_upload::SlotRequest, iq::Iq},
|
||||
Jid,
|
||||
|
|
@ -13,7 +14,11 @@ use tokio_xmpp::{
|
|||
|
||||
use crate::Agent;
|
||||
|
||||
pub async fn upload_file_with(agent: &mut Agent, service: &str, path: &Path) {
|
||||
pub async fn upload_file_with<C: ServerConnector>(
|
||||
agent: &mut Agent<C>,
|
||||
service: &str,
|
||||
path: &Path,
|
||||
) {
|
||||
let name = path.file_name().unwrap().to_str().unwrap().to_string();
|
||||
let file = File::open(path).await.unwrap();
|
||||
let size = file.metadata().await.unwrap().len();
|
||||
|
|
|
|||
Loading…
Reference in a new issue