Skip to main content

runar_serializer/
utils.rs

1// Utility functions for runar-serializer
2
3use super::ArcValue;
4
5/// Convert an error to a string value
6pub fn error_to_string_value(error: impl std::fmt::Display) -> ArcValue {
7    // Just use the error message as a string for simplicity
8    let error_message = error.to_string();
9
10    // Return as string value
11    ArcValue::new_primitive(error_message)
12}
13
14/// Create a null/empty ArcValue
15pub fn null_value() -> ArcValue {
16    ArcValue::null()
17}
18
19/// Create an ArcValue from a string
20pub fn string_value(s: impl Into<String>) -> ArcValue {
21    ArcValue::new_primitive(s.into())
22}
23
24/// Create an ArcValue from a number
25pub fn number_value(n: f64) -> ArcValue {
26    ArcValue::new_primitive(n)
27}
28
29/// Create an ArcValue from a boolean
30pub fn bool_value(b: bool) -> ArcValue {
31    ArcValue::new_primitive(b)
32}