/src/wasmer/lib/api/src/into_bytes.rs
Line | Count | Source (jump to first uncovered line) |
1 | | use bytes::Bytes; |
2 | | use std::borrow::Cow; |
3 | | |
4 | | /// Convert binary data into [`bytes::Bytes`]. |
5 | | pub trait IntoBytes { |
6 | | /// Convert binary data into [`bytes::Bytes`]. |
7 | | fn into_bytes(self) -> Bytes; |
8 | | } |
9 | | |
10 | | impl IntoBytes for Bytes { |
11 | 0 | fn into_bytes(self) -> Bytes { |
12 | 0 | self |
13 | 0 | } Unexecuted instantiation: <bytes::bytes::Bytes as wasmer::into_bytes::IntoBytes>::into_bytes Unexecuted instantiation: <bytes::bytes::Bytes as wasmer::into_bytes::IntoBytes>::into_bytes |
14 | | } |
15 | | |
16 | | impl IntoBytes for Vec<u8> { |
17 | 0 | fn into_bytes(self) -> Bytes { |
18 | 0 | Bytes::from(self) |
19 | 0 | } Unexecuted instantiation: <alloc::vec::Vec<u8> as wasmer::into_bytes::IntoBytes>::into_bytes Unexecuted instantiation: <alloc::vec::Vec<u8> as wasmer::into_bytes::IntoBytes>::into_bytes |
20 | | } |
21 | | |
22 | | impl IntoBytes for &Vec<u8> { |
23 | 0 | fn into_bytes(self) -> Bytes { |
24 | 0 | Bytes::from(self.clone()) |
25 | 0 | } Unexecuted instantiation: <&alloc::vec::Vec<u8> as wasmer::into_bytes::IntoBytes>::into_bytes Unexecuted instantiation: <&alloc::vec::Vec<u8> as wasmer::into_bytes::IntoBytes>::into_bytes |
26 | | } |
27 | | |
28 | | impl IntoBytes for &[u8] { |
29 | 0 | fn into_bytes(self) -> Bytes { |
30 | 0 | Bytes::from(self.to_vec()) |
31 | 0 | } Unexecuted instantiation: <&[u8] as wasmer::into_bytes::IntoBytes>::into_bytes Unexecuted instantiation: <&[u8] as wasmer::into_bytes::IntoBytes>::into_bytes |
32 | | } |
33 | | |
34 | | impl<const N: usize> IntoBytes for &[u8; N] { |
35 | 0 | fn into_bytes(self) -> Bytes { |
36 | 0 | Bytes::from(self.to_vec()) |
37 | 0 | } Unexecuted instantiation: <&[u8; _] as wasmer::into_bytes::IntoBytes>::into_bytes Unexecuted instantiation: <&[u8; _] as wasmer::into_bytes::IntoBytes>::into_bytes |
38 | | } |
39 | | |
40 | | impl IntoBytes for &str { |
41 | 0 | fn into_bytes(self) -> Bytes { |
42 | 0 | Bytes::from(self.as_bytes().to_vec()) |
43 | 0 | } Unexecuted instantiation: <&str as wasmer::into_bytes::IntoBytes>::into_bytes Unexecuted instantiation: <&str as wasmer::into_bytes::IntoBytes>::into_bytes |
44 | | } |
45 | | |
46 | | impl IntoBytes for Cow<'_, [u8]> { |
47 | 0 | fn into_bytes(self) -> Bytes { |
48 | 0 | Bytes::from(self.to_vec()) |
49 | 0 | } Unexecuted instantiation: <alloc::borrow::Cow<[u8]> as wasmer::into_bytes::IntoBytes>::into_bytes Unexecuted instantiation: <alloc::borrow::Cow<[u8]> as wasmer::into_bytes::IntoBytes>::into_bytes |
50 | | } |