Use bytes crate for zerocopy and memory re-use (#182)
* Use bytes. Not yet zerocopy everywhere but compiles * Actually zerocopy * Actually zerocopy * Not actually storing the torrent on disk now
This commit is contained in:
parent
3cc9e444b1
commit
c7ed475f54
20 changed files with 182 additions and 95 deletions
|
|
@ -35,6 +35,7 @@ clone_to_owned = { path = "../clone_to_owned", package = "librqbit-clone-to-owne
|
|||
librqbit-core = { path = "../librqbit_core", version = "3.9.0" }
|
||||
chrono = { version = "0.4.31", features = ["serde"] }
|
||||
tokio-util = "0.7.10"
|
||||
bytes = "1.7.1"
|
||||
|
||||
[dev-dependencies]
|
||||
tracing-subscriber = "0.3"
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ use std::{
|
|||
};
|
||||
|
||||
use bencode::{ByteBuf, ByteBufOwned};
|
||||
use bytes::Bytes;
|
||||
use clone_to_owned::CloneToOwned;
|
||||
use librqbit_core::hash_id::Id20;
|
||||
use serde::{
|
||||
|
|
@ -73,10 +74,10 @@ where
|
|||
{
|
||||
type Target = ErrorDescription<<BufT as CloneToOwned>::Target>;
|
||||
|
||||
fn clone_to_owned(&self) -> Self::Target {
|
||||
fn clone_to_owned(&self, within_buffer: Option<&Bytes>) -> Self::Target {
|
||||
ErrorDescription {
|
||||
code: self.code,
|
||||
description: self.description.clone_to_owned(),
|
||||
description: self.description.clone_to_owned(within_buffer),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue