diff --git a/bytes-ext/Cargo.toml b/bytes-ext/Cargo.toml deleted file mode 100644 index de70045de6..0000000000 --- a/bytes-ext/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "bytes-ext" -version = "0.1.0" -edition = "2018" - -[dependencies] -error-chain = "0.11" -bytes = "0.4" diff --git a/bytes-ext/src/lib.rs b/bytes-ext/src/lib.rs deleted file mode 100644 index 8008c5a1e9..0000000000 --- a/bytes-ext/src/lib.rs +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This software may be used and distributed according to the terms of the - * GNU General Public License found in the LICENSE file in the root - * directory of this source tree. - */ - -//! Extensions for the bytes crate. - -#![deny(warnings)] - -mod sized; - -pub use crate::sized::SizeCounter; diff --git a/bytes-ext/src/sized.rs b/bytes-ext/src/sized.rs deleted file mode 100644 index 21a7a03c74..0000000000 --- a/bytes-ext/src/sized.rs +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This software may be used and distributed according to the terms of the - * GNU General Public License found in the LICENSE file in the root - * directory of this source tree. - */ - -use std::usize; - -use bytes::{Buf, BufMut, ByteOrder, IntoBuf}; -//use iovec::IoVec; - -/// Implementation of `BufMut` to count the size of a resulting buffer -/// -/// A "buffer" for counting the size of a resulting buffer. This effectively requires -/// the data to be serialized twice, but with luck inlining will result in most effort used -/// in generating actual data will be elided. -pub struct SizeCounter(usize); - -impl SizeCounter { - #[inline] - pub fn new() -> Self { - SizeCounter(0) - } - - #[inline] - pub fn size(&self) -> usize { - self.0 - } - - #[inline] - pub fn increment(&mut self, inc: usize) { - self.0 += inc; - } -} - -impl BufMut for SizeCounter { - #[inline] - fn remaining_mut(&self) -> usize { - usize::MAX - } - - unsafe fn advance_mut(&mut self, _cnt: usize) {} - - unsafe fn bytes_mut(&mut self) -> &mut [u8] { - unimplemented!("SizeCounter doesn't really have a buffer") - } - - #[inline] - fn has_remaining_mut(&self) -> bool { - true - } - - //unsafe fn bytes_vec_mut<'a>(&'a mut self, _dst: &mut [&'a mut IoVec]) -> usize { - // unimplemented!("SizeCounter doesn't really have a buffer") - //} - - #[inline] - fn put(&mut self, src: T) - where - Self: Sized, - { - let buf = src.into_buf(); - self.0 += buf.remaining(); - } - - #[inline] - fn put_slice(&mut self, src: &[u8]) { - self.0 += src.len() - } - - #[inline] - fn put_u8(&mut self, _n: u8) { - self.0 += 1 - } - #[inline] - fn put_i8(&mut self, _n: i8) { - self.0 += 1 - } - - #[inline] - fn put_u16(&mut self, _n: u16) { - self.0 += 2 - } - #[inline] - fn put_i16(&mut self, _n: i16) { - self.0 += 2 - } - - #[inline] - fn put_u32(&mut self, _n: u32) { - self.0 += 4 - } - #[inline] - fn put_i32(&mut self, _n: i32) { - self.0 += 4 - } - - #[inline] - fn put_u64(&mut self, _n: u64) { - self.0 += 8 - } - #[inline] - fn put_i64(&mut self, _n: i64) { - self.0 += 8 - } - - #[inline] - fn put_uint(&mut self, _n: u64, nbytes: usize) { - self.0 += nbytes - } - #[inline] - fn put_int(&mut self, _n: i64, nbytes: usize) { - self.0 += nbytes - } - - #[inline] - fn put_f32(&mut self, _n: f32) { - self.0 += 4 - } - #[inline] - fn put_f64(&mut self, _n: f64) { - self.0 += 8 - } -} diff --git a/mercurial/bundles/src/delta.rs b/mercurial/bundles/src/delta.rs index 66989f4425..0e3a7add9d 100644 --- a/mercurial/bundles/src/delta.rs +++ b/mercurial/bundles/src/delta.rs @@ -10,7 +10,7 @@ use bytes::{BufMut, BytesMut}; -use bytes_ext::SizeCounter; +use bufsize::SizeCounter; use failure_ext::bail_err; use mercurial_types::delta::{Delta, Fragment};