Box<[u8]> instead of Vec<u8> for ByteBufOwned
This commit is contained in:
parent
d9ec702f59
commit
deee41cd93
23 changed files with 106 additions and 124 deletions
|
|
@ -5,7 +5,7 @@ use std::path::Path;
|
|||
|
||||
use anyhow::Context;
|
||||
use bencode::bencode_serialize_to_writer;
|
||||
use buffers::ByteString;
|
||||
use buffers::ByteBufOwned;
|
||||
use librqbit_core::torrent_metainfo::{TorrentMetaV1File, TorrentMetaV1Info, TorrentMetaV1Owned};
|
||||
use librqbit_core::Id20;
|
||||
use sha1w::{ISha1, Sha1};
|
||||
|
|
@ -44,7 +44,7 @@ fn walk_dir_find_paths(dir: &Path, out: &mut Vec<Cow<'_, Path>>) -> anyhow::Resu
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn compute_info_hash(t: &TorrentMetaV1Info<ByteString>) -> anyhow::Result<Id20> {
|
||||
fn compute_info_hash(t: &TorrentMetaV1Info<ByteBufOwned>) -> anyhow::Result<Id20> {
|
||||
struct W {
|
||||
hash: sha1w::Sha1,
|
||||
}
|
||||
|
|
@ -79,7 +79,7 @@ fn osstr_to_bytes(o: &OsStr) -> Vec<u8> {
|
|||
async fn create_torrent_raw<'a>(
|
||||
path: &'a Path,
|
||||
options: CreateTorrentOptions<'a>,
|
||||
) -> anyhow::Result<TorrentMetaV1Info<ByteString>> {
|
||||
) -> anyhow::Result<TorrentMetaV1Info<ByteBufOwned>> {
|
||||
path.try_exists()
|
||||
.with_context(|| format!("path {:?} doesn't exist", path))?;
|
||||
let basename = path
|
||||
|
|
@ -87,7 +87,7 @@ async fn create_torrent_raw<'a>(
|
|||
.ok_or_else(|| anyhow::anyhow!("cannot determine basename of {:?}", path))?;
|
||||
let is_dir = path.is_dir();
|
||||
let single_file_mode = !is_dir;
|
||||
let name: ByteString = match options.name {
|
||||
let name: ByteBufOwned = match options.name {
|
||||
Some(name) => name.as_bytes().into(),
|
||||
None => osstr_to_bytes(basename).into(),
|
||||
};
|
||||
|
|
@ -112,7 +112,7 @@ async fn create_torrent_raw<'a>(
|
|||
let mut remaining_piece_length = piece_length;
|
||||
let mut piece_checksum = sha1w::Sha1::new();
|
||||
let mut piece_hashes = Vec::<u8>::new();
|
||||
let mut output_files: Vec<TorrentMetaV1File<ByteString>> = Vec::new();
|
||||
let mut output_files: Vec<TorrentMetaV1File<ByteBufOwned>> = Vec::new();
|
||||
|
||||
let spawner = BlockingSpawner::default();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue