Skip to main content

coerce

Function coerce 

Source
pub fn coerce<T: DeserializeOwned>(value: &Value) -> Result<T, Error>
Expand description

Reads a browser-sent value into a field’s type, accepting the strings form inputs send.

wire:model sends "4" for a number field and "" for an emptied one; a snapshot this crate wrote carries real JSON types. Both reach here, so a value that is already the field’s type is read as it is, and a string is read as JSON text, with the empty string as null.

§Errors

Returns the decoder’s error when neither reading fits the type.