pub struct Options {Show 22 fields
pub name: Option<String>,
pub indent: Option<String>,
pub compact: bool,
pub sparse: bool,
pub fatal: bool,
pub maxnum: Option<usize>,
pub maxlevel: Option<usize>,
pub maxlength: Option<i64>,
pub nocode: bool,
pub nohuge: bool,
pub comment: Option<usize>,
pub sortkeys: bool,
pub sortfn: Option<SortFn>,
pub fixradix: bool,
pub metatostring: Option<bool>,
pub numformat: Option<String>,
pub valignore: Option<HashSet<Ident>>,
pub valignore_scalar: Option<Vec<Value>>,
pub keyallow: Option<Vec<Key>>,
pub keyignore: Option<Vec<Key>>,
pub valtypeignore: Option<HashSet<String>>,
pub custom: Option<CustomFn>,
}Expand description
Options controlling serialization.
Field names and defaults follow serpent. Booleans use Lua truthiness unless
a field notes an exact comparison. Set fields directly, or start from
Options::dump, Options::line, or Options::block.
Fields§
§name: Option<String>Variable name. When set, output is wrapped in a do ... return name end
block with a self-reference section. dump sets _.
indent: Option<String>Indentation unit. When set, output is multi-line. block sets two spaces.
compact: boolRemove spaces around separators. dump sets true.
sparse: boolForce sparse array encoding, skipping nil holes. dump sets true.
fatal: boolRaise an error on non-serializable values instead of emitting a fallback.
maxnum: Option<usize>Maximum number of array-part elements to emit.
maxlevel: Option<usize>Maximum table nesting depth to expand. Deeper tables emit {}.
maxlength: Option<i64>Maximum cumulative length of emitted element strings.
nocode: boolReplace functions with an empty-body stub instead of bytecode.
nohuge: boolDisable the special 1/0, -1/0, 0/0 forms for inf and nan.
comment: Option<usize>Append --[[...]] comments up to this depth. The gate is level < n, so
a table at level l gets a comment when l < n. Some(0) disables
comments, matching serpent’s numeric depth 0. Some(usize::MAX) comments
every level, standing in for serpent’s math.huge. line and block
set Some(usize::MAX).
sortkeys: boolSort non-array keys. line and block set the default sort on.
sortfn: Option<SortFn>Custom key sort. Overrides the default alphanumsort when set.
fixradix: boolForce a . decimal separator. A no-op in this implementation because
Rust float formatting is locale-independent.
metatostring: Option<bool>Use __tostring on tables. Only an explicit Some(false) disables it;
None and Some(true) enable it, matching serpent’s ~= false gate.
numformat: Option<String>printf-style number format. Defaults to %.17g.
valignore: Option<HashSet<Ident>>Values to skip, matched by identity or scalar value.
valignore_scalar: Option<Vec<Value>>Scalar values to skip.
keyallow: Option<Vec<Key>>Allowlist of keys to serialize. Keys not in the list are dropped. Keyed
by Key, so numeric and boolean keys work, not only strings.
keyignore: Option<Vec<Key>>Denylist of keys to skip. Keyed by Key, so numeric and boolean keys
work, not only strings.
valtypeignore: Option<HashSet<String>>Value type names to skip, such as function or table.
custom: Option<CustomFn>Custom table formatter.