Box<[u8]> instead of Vec<u8> for ByteBufOwned

This commit is contained in:
Igor Katson 2024-03-29 11:00:58 +00:00
parent 3cdf6d4cfc
commit fa05fe8376
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
24 changed files with 118 additions and 109 deletions

View file

@ -18,16 +18,16 @@ sha1-rust = ["bencode/sha1-rust"]
[dependencies]
tracing = "0.1.40"
tokio = {version = "1", features = ["rt-multi-thread", "macros", "time"]}
tokio = { version = "1", features = ["rt-multi-thread", "macros", "time"] }
hex = "0.4"
anyhow = "1"
url = "2"
uuid = {version = "1", features = ["v4"]}
uuid = { version = "1", features = ["v4"] }
parking_lot = "0.12"
serde = {version = "1", features=["derive"]}
buffers = {path="../buffers", package="librqbit-buffers", version = "2.2.1"}
bencode = {path = "../bencode", default-features=false, package="librqbit-bencode", version="2.2.1"}
clone_to_owned = {path="../clone_to_owned", package="librqbit-clone-to-owned", version = "2.2.1"}
serde = { version = "1", features = ["derive"] }
buffers = { path = "../buffers", package = "librqbit-buffers", version = "2.2.1" }
bencode = { path = "../bencode", default-features = false, package = "librqbit-bencode", version = "2.2.2" }
clone_to_owned = { path = "../clone_to_owned", package = "librqbit-clone-to-owned", version = "2.2.1" }
itertools = "0.12"
directories = "5"
tokio-util = "0.7.10"

View file

@ -2,7 +2,7 @@ use std::{iter::once, path::PathBuf};
use anyhow::Context;
use bencode::BencodeDeserializer;
use buffers::{ByteBuf, ByteString};
use buffers::{ByteBuf, ByteBufOwned};
use clone_to_owned::CloneToOwned;
use itertools::Either;
use serde::{Deserialize, Serialize};
@ -10,7 +10,7 @@ use serde::{Deserialize, Serialize};
use crate::hash_id::Id20;
pub type TorrentMetaV1Borrowed<'a> = TorrentMetaV1<ByteBuf<'a>>;
pub type TorrentMetaV1Owned = TorrentMetaV1<ByteString>;
pub type TorrentMetaV1Owned = TorrentMetaV1<ByteBufOwned>;
/// Parse torrent metainfo from bytes.
pub fn torrent_from_bytes<'de, ByteBuf: Deserialize<'de>>(