pub struct ZonOptions {
pub char_as_number: bool,
pub enum_tag: Option<String>,
}Expand description
Plugin options. Default is the canonical Zon.defaults: character
literals as one-character strings, enum literals as bare strings.
Fields§
§char_as_number: boolParse Zig character literals ('x') as numeric code points rather
than as one-character strings.
enum_tag: Option<String>When set, wrap an enum literal used as a value (.foo) in
{ "<enumTag>": "foo" } instead of producing the bare string
"foo". An empty string means unset, as in the Go port.
Implementations§
Source§impl ZonOptions
impl ZonOptions
Sourcepub fn from_value(value: &Value) -> Self
pub fn from_value(value: &Value) -> Self
The options read from a plugin option bag. A missing field is its
default and an unknown field is ignored, as the canonical plugin
reads options.charAsNumber and options.enumTag and nothing
else.
Each field is read ON ITS OWN, and by JavaScript truthiness, which
is what !!options.charAsNumber and options.enumTag || null
mean in ts/src/zon.ts. Deserializing the bag as a whole instead
let one ill-typed field discard a well-typed one: the bag
{"charAsNumber": true, "enumTag": false} failed to deserialize
at enumTag and fell back to the DEFAULTS, so 'A' parsed as
"A" where both other runtimes give 65.
The bag is read as the ENGINE value it is, never through
Value::to_json. That projection turns a non-finite number into
null, and null is falsy where Infinity is not: a
charAsNumber of Infinity is true in the canonical runtime and
would have read as false here, and an enumTag of Infinity
names the key Infinity there and would have read as unset here.
The conversion is LOSSLESS for a string, the empty one included,
so that from_value(&options.to_value()) returns the options it
was given. tag applies the canonical || null filter at the
point of use instead.
Trait Implementations§
Source§impl Clone for ZonOptions
impl Clone for ZonOptions
Source§impl Debug for ZonOptions
impl Debug for ZonOptions
Source§impl Default for ZonOptions
impl Default for ZonOptions
Source§impl<'de> Deserialize<'de> for ZonOptionswhere
ZonOptions: Default,
impl<'de> Deserialize<'de> for ZonOptionswhere
ZonOptions: Default,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ZonOptions
Source§impl PartialEq for ZonOptions
impl PartialEq for ZonOptions
Source§impl Serialize for ZonOptions
impl Serialize for ZonOptions
impl StructuralPartialEq for ZonOptions
Auto Trait Implementations§
impl Forget for ZonOptions
impl Freeze for ZonOptions
impl Move for ZonOptions
impl RefUnwindSafe for ZonOptions
impl Send for ZonOptions
impl Sync for ZonOptions
impl Unpin for ZonOptions
impl UnsafeUnpin for ZonOptions
impl UnwindSafe for ZonOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.