Skip to main content

cbor_core/value/
bytes.rs

1use super::*;
2
3impl From<Vec<u8>> for Value {
4    fn from(value: Vec<u8>) -> Self {
5        Self::ByteString(value)
6    }
7}
8
9impl From<&[u8]> for Value {
10    fn from(value: &[u8]) -> Self {
11        Self::ByteString(value.to_vec())
12    }
13}
14
15impl<const N: usize> From<[u8; N]> for Value {
16    fn from(value: [u8; N]) -> Self {
17        Self::ByteString(value.to_vec())
18    }
19}
20
21impl<const N: usize> From<&[u8; N]> for Value {
22    fn from(value: &[u8; N]) -> Self {
23        Self::ByteString(value.to_vec())
24    }
25}
26
27impl From<Box<[u8]>> for Value {
28    fn from(value: Box<[u8]>) -> Self {
29        Self::ByteString(Vec::from(value))
30    }
31}
32
33impl TryFrom<Value> for Vec<u8> {
34    type Error = Error;
35    fn try_from(value: Value) -> Result<Self> {
36        value.into_bytes()
37    }
38}