Skip to main content

ToValue

Trait ToValue 

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

Lossless conversion of validated schema outputs into Values.

Implemented for the realistic form-coercion targets; u64/usize are deliberately excluded because they do not fit the I64 fidelity rules (DV-1) without silent truncation.

The exclusion is enforced at compile time: coerced::<u64>() is a valid standalone schema, but it cannot back an object field because the crate::schema::ObjectChild impl requires T: ToValue.

ⓘ
use formars_core::prelude::*;

let _ = object().field("n", coerced::<u64>()); // u64 lacks ToValue

Required Methods§

Source

fn to_value(self) -> Value

Converts the value into its exact Value representation.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ToValue for String

Source§

impl ToValue for bool

Source§

impl ToValue for f32

Source§

impl ToValue for f64

Source§

impl ToValue for i8

Source§

impl ToValue for i16

Source§

impl ToValue for i32

Source§

impl ToValue for i64

Source§

impl ToValue for u8

Source§

impl ToValue for u16

Source§

impl ToValue for u32

Implementors§