diff --git a/serde_v8/magic/buffer.rs b/serde_v8/magic/buffer.rs index 862264886e..d0f0909bc9 100644 --- a/serde_v8/magic/buffer.rs +++ b/serde_v8/magic/buffer.rs @@ -14,9 +14,6 @@ use crate::magic::transl8::impl_magic; pub enum ZeroCopyBuf { FromV8(V8Slice), ToV8(Option>), - // Variant of the ZeroCopyBuf than is never exposed to the JS. - // Generally used to pass Vec backed buffers to resource methods. - Temp(Vec), } impl_magic!(ZeroCopyBuf); @@ -31,25 +28,12 @@ impl ZeroCopyBuf { pub fn empty() -> Self { ZeroCopyBuf::ToV8(Some(vec![0_u8; 0].into_boxed_slice())) } - - pub fn new_temp(vec: Vec) -> Self { - ZeroCopyBuf::Temp(vec) - } - - // TODO(@littledivy): Temporary, this needs a refactor. - pub fn to_temp(self) -> Vec { - match self { - ZeroCopyBuf::Temp(vec) => vec, - _ => unreachable!(), - } - } } impl Clone for ZeroCopyBuf { fn clone(&self) -> Self { match self { Self::FromV8(zbuf) => Self::FromV8(zbuf.clone()), - Self::Temp(vec) => Self::Temp(vec.clone()), Self::ToV8(_) => panic!("Don't Clone a ZeroCopyBuf sent to v8"), } } @@ -72,7 +56,6 @@ impl Deref for ZeroCopyBuf { fn deref(&self) -> &[u8] { match self { Self::FromV8(buf) => buf, - Self::Temp(vec) => vec, Self::ToV8(_) => panic!("Don't Deref a ZeroCopyBuf sent to v8"), } } @@ -82,7 +65,6 @@ impl DerefMut for ZeroCopyBuf { fn deref_mut(&mut self) -> &mut [u8] { match self { Self::FromV8(buf) => &mut *buf, - Self::Temp(vec) => &mut *vec, Self::ToV8(_) => panic!("Don't Deref a ZeroCopyBuf sent to v8"), } } @@ -110,7 +92,6 @@ impl ToV8 for ZeroCopyBuf { let value: &[u8] = buf; value.into() } - Self::Temp(_) => unreachable!(), Self::ToV8(ref mut x) => x.take().expect("ZeroCopyBuf was empty"), }; @@ -151,7 +132,6 @@ impl From for bytes::Bytes { ZeroCopyBuf::ToV8(mut v) => { v.take().expect("ZeroCopyBuf was empty").into() } - ZeroCopyBuf::Temp(v) => v.into(), } } } diff --git a/serde_v8/magic/string_or_buffer.rs b/serde_v8/magic/string_or_buffer.rs index 8b1a06dbc2..02571f6693 100644 --- a/serde_v8/magic/string_or_buffer.rs +++ b/serde_v8/magic/string_or_buffer.rs @@ -47,7 +47,6 @@ impl ToV8 for StringOrBuffer { let value: &[u8] = buf; value.into() } - ZeroCopyBuf::Temp(_) => unreachable!(), ZeroCopyBuf::ToV8(ref mut x) => { x.take().expect("ZeroCopyBuf was empty") }