Remove byte slice downcasts in CpuBinding All downcasts are to typed objects.
diff --git a/src/cpu_dispatch.rs b/src/cpu_dispatch.rs index fa1bbeb..2c3409c 100644 --- a/src/cpu_dispatch.rs +++ b/src/cpu_dispatch.rs
@@ -18,22 +18,6 @@ Texture(&'a CpuTexture), } -pub enum CpuBufGuard<'a> { - Slice(&'a [u8]), - Interior(RefMut<'a, Vec<u8>>), -} - -impl<'a> Deref for CpuBufGuard<'a> { - type Target = [u8]; - - fn deref(&self) -> &Self::Target { - match self { - CpuBufGuard::Slice(s) => s, - CpuBufGuard::Interior(r) => r, - } - } -} - pub enum TypedBufGuard<'a, T: ?Sized> { Slice(&'a T), Interior(Ref<'a, T>), @@ -75,27 +59,7 @@ } } -impl<'a> CpuBufGuard<'a> { - /// Get a mutable reference to the buffer. - /// - /// Panics if the underlying resource is read-only. - pub fn as_mut(&mut self) -> &mut [u8] { - match self { - CpuBufGuard::Interior(r) => &mut *r, - _ => panic!("tried to borrow immutable buffer as mutable"), - } - } -} - impl<'a> CpuBinding<'a> { - pub fn as_buf(&self) -> CpuBufGuard { - match self { - CpuBinding::Buffer(b) => CpuBufGuard::Slice(b), - CpuBinding::BufferRW(b) => CpuBufGuard::Interior(b.borrow_mut()), - _ => panic!("resource type mismatch"), - } - } - pub fn as_typed<T: Pod>(&self) -> TypedBufGuard<T> { match self { CpuBinding::Buffer(b) => TypedBufGuard::Slice(bytemuck::from_bytes(b)),