diff --git a/src/owners.rs b/src/owners.rs index 3d8ae3d..8f0cdc7 100644 --- a/src/owners.rs +++ b/src/owners.rs @@ -31,9 +31,15 @@ where #[cfg(not(feature = "zerocopy"))] unsafe impl ByteSource for &'static [u8] { + type Owner = Self; + fn as_bytes(&self) -> &[u8] { *self } + + fn as_owner(self) -> Self::Owner { + self + } } #[cfg(feature = "zerocopy")] @@ -55,9 +61,15 @@ where #[cfg(not(feature = "zerocopy"))] unsafe impl ByteSource for Box<[u8]> { + type Owner = Self; + fn as_bytes(&self) -> &[u8] { self.as_ref() } + + fn as_owner(self) -> Self::Owner { + self + } } #[cfg(feature = "zerocopy")] @@ -79,9 +91,15 @@ where #[cfg(not(feature = "zerocopy"))] unsafe impl ByteSource for Vec { + type Owner = Self; + fn as_bytes(&self) -> &[u8] { self.as_ref() } + + fn as_owner(self) -> Self::Owner { + todo!() + } } unsafe impl ByteSource for String {