Skip to main content

Module hints

Module hints 

Source
Expand description

Well-known formatting hints.

Hints tell formats how a value would like to be presented. They are not part of the data model and never change the value: formats which do not have a choice (or do not support a hint) ignore them. Hints are event data which is attached to the first event of a value. They are set by values (for instance through the adapters of this module) or by layers, which allows to set them by path. The last hint set wins, so hints set by layers take precedence over the ones of the values.

HintHonored by
LayoutTOML (inline tables and arrays of tables), YAML (flow style), JSON and XML (single line when indented)

Formats can define their own hints and adapters for them with Hint and Hinted.

use std::collections::BTreeMap;
use deser::Serialize;
use deser::hints::Compact;

#[derive(Serialize)]
struct Config {
    #[deser(as = Compact)]
    point: BTreeMap<String, u32>,
}

Structs§

CompactLayout
The Hint for Layout::Compact.
ExpandedLayout
The Hint for Layout::Expanded.
Hinted
An adapter which sets a Hint and serializes the value with another adapter.

Enums§

Layout
How a map or sequence is laid out by formats that have a choice.

Traits§

Hint
A hint that can be set by the Hinted adapter.

Type Aliases§

Compact
Serializes a value with Layout::Compact.
Expanded
Serializes a value with Layout::Expanded.