IConfig.edit

Edit the value of this configuration using the provided editFunc, optionally saving if no exceptions are thrown, and optionally rolling back any changes in the case an exception is thrown.

Notes: Exceptions can be caught during either editFunc, or a call to save.

Functionally, "rolling back on success" simply means the configuration's value[set] property is never used.

This has a consequence - if your editFunc modifies the internal state of the value in a way that takes immediate effect on the original value (e.g. the value is a class type, so all changes will affect the original value), then "rolling back" won't be able to prevent any data changes.

Therefor, it's best to use structs for your configuration types if you're wanting to make use of "rolling back".

If an error occurs, then UserIO.verboseException is used to display the exception.

Ensure your lambda parameter is marked scope ref, otherwise you'll get a compiler error.

interface IConfig(T)
final
edit
if (
is(T == struct) ||
is(T == class)
)

Parameters

editFunc void delegate
(
scope ref T value
)

The function that will edit the configuration's value.

rollback RollbackOnFailure

If RollbackOnFailure.yes, then should an error occur, the configuration's value will be left unchanged.

save SaveOnSuccess

If SaveOnSuccess.yes, then if no errors occur, a call to save will be made.

Return Value

WasExceptionThrown to denote whether an error occured or not.

Meta