trying to make tests work with new metadata

This commit is contained in:
Igor Katson 2024-08-14 10:25:05 +01:00
parent 55649e181a
commit c196c11860
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
6 changed files with 45 additions and 29 deletions

View file

@ -6,6 +6,7 @@ use std::path::Path;
use anyhow::Context;
use bencode::bencode_serialize_to_writer;
use buffers::ByteBufOwned;
use bytes::Bytes;
use librqbit_core::torrent_metainfo::{TorrentMetaV1File, TorrentMetaV1Info, TorrentMetaV1Owned};
use librqbit_core::Id20;
use sha1w::{ISha1, Sha1};
@ -185,10 +186,10 @@ impl CreateTorrentResult {
self.meta.info_hash
}
pub fn as_bytes(&self) -> anyhow::Result<Vec<u8>> {
pub fn as_bytes(&self) -> anyhow::Result<Bytes> {
let mut b = Vec::new();
bencode_serialize_to_writer(&self.meta, &mut b).context("error serializing torrent")?;
Ok(b)
Ok(b.into())
}
}