mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
xmpp-rs: Use to_hex conversion from struct directly
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
6d1d441372
commit
a1489a6428
1 changed files with 1 additions and 11 deletions
|
@ -12,7 +12,6 @@ use std::io::{self, Write};
|
|||
use tokio_xmpp::Packet;
|
||||
use xmpp_parsers::{
|
||||
avatar::{Data, Metadata},
|
||||
hashes::Hash,
|
||||
iq::Iq,
|
||||
ns,
|
||||
pubsub::{
|
||||
|
@ -23,15 +22,6 @@ use xmpp_parsers::{
|
|||
Jid,
|
||||
};
|
||||
|
||||
// TODO: Update xmpp-parsers to get this function for free on Hash.
|
||||
fn hash_to_hex(hash: &Hash) -> String {
|
||||
let mut bytes = vec![];
|
||||
for byte in hash.hash.iter() {
|
||||
bytes.push(format!("{:02x}", byte));
|
||||
}
|
||||
bytes.join("")
|
||||
}
|
||||
|
||||
pub(crate) fn handle_metadata_pubsub_event(
|
||||
from: &Jid,
|
||||
tx: &mut mpsc::UnboundedSender<Packet>,
|
||||
|
@ -43,7 +33,7 @@ pub(crate) fn handle_metadata_pubsub_event(
|
|||
if payload.is("metadata", ns::AVATAR_METADATA) {
|
||||
let metadata = Metadata::try_from(payload).unwrap();
|
||||
for info in metadata.infos {
|
||||
let filename = format!("data/{}/{}", from, hash_to_hex(&*info.id));
|
||||
let filename = format!("data/{}/{}", from, &*info.id.to_hex());
|
||||
let file_length = match fs::metadata(filename.clone()) {
|
||||
Ok(metadata) => metadata.len(),
|
||||
Err(_) => 0,
|
||||
|
|
Loading…
Reference in a new issue