pub enum ExtensionValue {
Null,
Bool(bool),
Number(String),
String(String),
Object(Extensions),
Array(Vec<Self>),
Raw(String),
}Expand description
The value of an unmodelled field.
Variants§
Null
null.
Bool(bool)
true or false.
Number(String)
A number, kept as text so a large integer or a 1.0 survives exactly.
String(String)
A string.
Object(Extensions)
A nested object, as a bag in its own right.
Array(Vec<Self>)
An array, in order.
Raw(String)
Text that did not parse, kept so a parse failure cannot drop data.
Lowering emits it back verbatim. This is the escape hatch that makes lift total: there is no input for which the bridge has to throw data away, which is what “lossless” has to mean to be worth claiming.
Implementations§
Trait Implementations§
Source§impl Clone for ExtensionValue
impl Clone for ExtensionValue
Source§impl Debug for ExtensionValue
impl Debug for ExtensionValue
Source§impl From<&ExtensionValue> for Value
impl From<&ExtensionValue> for Value
Source§fn from(value: &ExtensionValue) -> Self
fn from(value: &ExtensionValue) -> Self
Converts back to JSON.
Number round-trips through the stored text, and Raw is parsed with
the raw text as a fallback so an unparseable value is still emitted
rather than dropped. A value that reached Raw was already text that
serde could not read as JSON, so the fallback is a string, which is what
it came from.
Source§impl From<Value> for ExtensionValue
impl From<Value> for ExtensionValue
Source§fn from(value: Value) -> Self
fn from(value: Value) -> Self
Converts a JSON value, total by construction.
Every serde_json::Value has a matching variant, so this cannot fail —
which is what makes Extensions::from_json_object infallible and lift
total. A number keeps its source text rather than being reparsed, so a
large integer or a 1.0 survives the crossing byte for byte.