mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-25 00:00:22 +02:00
@@ -25,7 +25,6 @@ std = []
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde = { version = "1.0", optional = true }
|
serde = { version = "1.0", optional = true }
|
||||||
either = { version = "1.5", default-features = false, optional = true }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
loom = "0.2.10"
|
loom = "0.2.10"
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ jobs:
|
|||||||
cross: true
|
cross: true
|
||||||
features:
|
features:
|
||||||
- serde
|
- serde
|
||||||
- either
|
|
||||||
|
|
||||||
# Nightly
|
# Nightly
|
||||||
- template: ci/azure-test-stable.yml
|
- template: ci/azure-test-stable.yml
|
||||||
|
|||||||
@@ -1,93 +0,0 @@
|
|||||||
use crate::{Buf, BufMut};
|
|
||||||
|
|
||||||
use either::Either;
|
|
||||||
use either::Either::*;
|
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
|
||||||
use std::io::IoSlice;
|
|
||||||
#[cfg(feature = "std")]
|
|
||||||
use crate::buf::IoSliceMut;
|
|
||||||
|
|
||||||
impl<L, R> Buf for Either<L, R>
|
|
||||||
where
|
|
||||||
L: Buf,
|
|
||||||
R: Buf,
|
|
||||||
{
|
|
||||||
fn remaining(&self) -> usize {
|
|
||||||
match *self {
|
|
||||||
Left(ref b) => b.remaining(),
|
|
||||||
Right(ref b) => b.remaining(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn bytes(&self) -> &[u8] {
|
|
||||||
match *self {
|
|
||||||
Left(ref b) => b.bytes(),
|
|
||||||
Right(ref b) => b.bytes(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
|
||||||
fn bytes_vectored<'a>(&'a self, dst: &mut [IoSlice<'a>]) -> usize {
|
|
||||||
match *self {
|
|
||||||
Left(ref b) => b.bytes_vectored(dst),
|
|
||||||
Right(ref b) => b.bytes_vectored(dst),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn advance(&mut self, cnt: usize) {
|
|
||||||
match *self {
|
|
||||||
Left(ref mut b) => b.advance(cnt),
|
|
||||||
Right(ref mut b) => b.advance(cnt),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn copy_to_slice(&mut self, dst: &mut [u8]) {
|
|
||||||
match *self {
|
|
||||||
Left(ref mut b) => b.copy_to_slice(dst),
|
|
||||||
Right(ref mut b) => b.copy_to_slice(dst),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<L, R> BufMut for Either<L, R>
|
|
||||||
where
|
|
||||||
L: BufMut,
|
|
||||||
R: BufMut,
|
|
||||||
{
|
|
||||||
fn remaining_mut(&self) -> usize {
|
|
||||||
match *self {
|
|
||||||
Left(ref b) => b.remaining_mut(),
|
|
||||||
Right(ref b) => b.remaining_mut(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn bytes_mut(&mut self) -> &mut [core::mem::MaybeUninit<u8>] {
|
|
||||||
match *self {
|
|
||||||
Left(ref mut b) => b.bytes_mut(),
|
|
||||||
Right(ref mut b) => b.bytes_mut(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
|
||||||
fn bytes_vectored_mut<'a>(&'a mut self, dst: &mut [IoSliceMut<'a>]) -> usize {
|
|
||||||
match *self {
|
|
||||||
Left(ref mut b) => b.bytes_vectored_mut(dst),
|
|
||||||
Right(ref mut b) => b.bytes_vectored_mut(dst),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe fn advance_mut(&mut self, cnt: usize) {
|
|
||||||
match *self {
|
|
||||||
Left(ref mut b) => b.advance_mut(cnt),
|
|
||||||
Right(ref mut b) => b.advance_mut(cnt),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn put_slice(&mut self, src: &[u8]) {
|
|
||||||
match *self {
|
|
||||||
Left(ref mut b) => b.put_slice(src),
|
|
||||||
Right(ref mut b) => b.put_slice(src),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -96,11 +96,6 @@ pub use crate::bytes::Bytes;
|
|||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
mod serde;
|
mod serde;
|
||||||
|
|
||||||
// Optional `Either` support
|
|
||||||
#[cfg(feature = "either")]
|
|
||||||
mod either;
|
|
||||||
|
|
||||||
|
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
#[cold]
|
#[cold]
|
||||||
fn abort() -> ! {
|
fn abort() -> ! {
|
||||||
|
|||||||
Reference in New Issue
Block a user