Crate macro_state

Source

Macros§

append_state
Like write_state!, but instead appends the specified value (newline-delimited) to the state file. Newlines contained in the value are automatically escaped so you can think of this as appending to a [Vec<String>] for all intents and purposes. Calling append_state! is also more efficient than re-writing an entire state file via write_state! since the low level append IO option is not used by write_state!.
clear_state
Clears the value for the specified key, if it exists.
has_state
Checks if an existing state value can be found for the specified key.
init_state
Returns the value for the specified key, if it exists. If it does not exist, the key is created and set to the specified default_value, and then the default_value is returned.
read_state
Reads the state value for the specified key. Since macro_state functions as a compile-time key-value store, read_state! attempts to read the state value associaed with the specified key.
read_state_vec
Reads the state value for the specified key and parses it as a [Vec<String>] where each new line is treated as a separate element in the [Vec]. Should be used in conjunction with append_state! to read and write lists of values from macro state storage.
write_state
Writes the specified value as the state for the specified state key. macro_state itself functions as a compile-time key-value store, and this is how you write a value to a specific key.

Constants§

STATE_DIR
A constant that will always resolve to the directory macro_state will use to store state files. This is typically some sub-directory of the target directory for the specified build environment. You should never use this directly unless you know what you’re doing.

Functions§

proc_append_state
An analogue for append_state! that should only be used within proc macros.
proc_clear_state
An analogue for clear_state! that should only be used within proc macros.
proc_has_state
An analogue for has_state! that should only be used within proc macros.
proc_init_state
An analogue for clear_state! that should only be used within proc macros.
proc_read_state
An analogue for read_state! that should only be used within proc macros.
proc_read_state_vec
An analogue for read_state_vec! that should only be used within proc macros.
proc_write_state
An analogue for write_state! that should only be used within proc macros.
state_file_path
Returns the path of the internal file that would be used to store state for the specified key, as a PathBuf. You should never use this directly unless you know what you’re doing.