Skip to main content

cbor_core/value/
array.rs

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