Skip to content

Commit

Permalink
fix impls for non-zerocopy case
Browse files Browse the repository at this point in the history
  • Loading branch information
somethingelseentirely committed Nov 24, 2024
1 parent ef7683c commit 7393301
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/owners.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand All @@ -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")]
Expand All @@ -79,9 +91,15 @@ where

#[cfg(not(feature = "zerocopy"))]
unsafe impl ByteSource for Vec<u8> {
type Owner = Self;

fn as_bytes(&self) -> &[u8] {
self.as_ref()
}

fn as_owner(self) -> Self::Owner {
todo!()
}
}

unsafe impl ByteSource for String {
Expand Down

0 comments on commit 7393301

Please sign in to comment.