Skip to main content

ToValue

Trait ToValue 

Source
pub trait ToValue {
    // Required method
    fn to_value(&self) -> Value;
}

Required Methods§

Source

fn to_value(&self) -> Value

Implementations on Foreign Types§

Source§

impl ToValue for &String

Source§

fn to_value(&self) -> Value

Source§

impl ToValue for Value

Source§

fn to_value(&self) -> Value

Source§

impl ToValue for bool

Source§

fn to_value(&self) -> Value

Source§

impl ToValue for f64

Source§

fn to_value(&self) -> Value

Source§

impl ToValue for i32

Source§

fn to_value(&self) -> Value

Source§

impl ToValue for i64

Source§

fn to_value(&self) -> Value

Source§

impl ToValue for DateTime<Utc>

Source§

fn to_value(&self) -> Value

Converts a timestamp to a JSON string value in RFC3339 format

§Examples

let timestamp = Utc.with_ymd_and_hms(2024, 10, 13, 19, 0, 0).unwrap();
let value = timestamp.to_value();

assert_eq!(value, json!("2024-10-13T19:00:00+00:00"));
Source§

impl<A: ToValue> ToValue for Vec<A>

Source§

fn to_value(&self) -> Value

Source§

impl<T: ToValue> ToValue for Box<T>

Source§

fn to_value(&self) -> Value

Source§

impl<T: ToValue> ToValue for BTreeMap<String, T>

Source§

fn to_value(&self) -> Value

Implementors§