Shorten ByteBuf trait bounds everywhere

This commit is contained in:
Igor Katson 2024-08-25 13:29:28 +01:00
parent c7b7dc300f
commit 9d1ef5c35c
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
6 changed files with 35 additions and 27 deletions

View file

@ -3,8 +3,10 @@
//
// Not useful outside of librqbit.
use std::borrow::Borrow;
use bytes::Bytes;
use serde::{Deserialize, Deserializer};
use serde::{Deserialize, Deserializer, Serialize};
use clone_to_owned::CloneToOwned;
@ -15,7 +17,9 @@ pub struct ByteBufOwned(pub bytes::Bytes);
#[serde(transparent)]
pub struct ByteBuf<'a>(pub &'a [u8]);
pub trait ByteBufT {
pub trait ByteBufT:
AsRef<[u8]> + std::hash::Hash + Serialize + Eq + core::fmt::Debug + CloneToOwned + Borrow<[u8]>
{
fn as_slice(&self) -> &[u8];
}