cbor_core/value/
string.rs1use super::*;
2
3impl From<&str> for Value {
4 fn from(value: &str) -> Self {
5 Self::TextString(value.into())
6 }
7}
8
9impl From<String> for Value {
10 fn from(value: String) -> Self {
11 Self::TextString(value)
12 }
13}
14
15impl From<&String> for Value {
16 fn from(value: &String) -> Self {
17 Self::TextString(value.clone())
18 }
19}
20
21impl From<Box<str>> for Value {
22 fn from(value: Box<str>) -> Self {
23 Self::TextString(value.into())
24 }
25}
26
27impl TryFrom<Value> for String {
28 type Error = Error;
29 fn try_from(value: Value) -> Result<Self> {
30 value.into_string()
31 }
32}
33
34impl<'a> TryFrom<&'a Value> for &'a str {
35 type Error = Error;
36 fn try_from(value: &'a Value) -> Result<Self> {
37 value.as_str()
38 }
39}
40
41impl<'a> TryFrom<&'a mut Value> for &'a mut String {
42 type Error = Error;
43 fn try_from(value: &'a mut Value) -> Result<Self> {
44 value.as_string_mut()
45 }
46}