TomlDataAdapter

Standard data adapter class implementing the TOML format. Stores TOML files in folders.

This is a pretty simple implementation, so it's a good example to use when writing your own data adapters.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
open suspend override fun <R : Data> delete(unit: StorageUnit<R>): Boolean

Entirely removes the data represented by the given storage unit from the dataCache, the disk if this is an adapter that stores data in files, or from whatever relevant persistent storage is being used.

Link copied to clipboard
open suspend override fun <R : Data> get(unit: StorageUnit<R>): R?

Retrieve and return the data object represented by the given storage unit.

Link copied to clipboard
open suspend fun <R : Data> getOrSaveDefault(unit: StorageUnit<R>, data: suspend () -> R): R

Retrieve the data object represented by the given storage unit, or store the data object returned by the callback if no respective data could be found.

Link copied to clipboard
open suspend override fun <R : Data> reload(unit: StorageUnit<R>): R?

Retrieve the data represented by the given storage unit from persistent storage, storing it in the dataCache and returning it if it was found.

Link copied to clipboard
open suspend fun reloadAll()

Reload all data objects stored in dataCache by calling reload against each storage unit.

Link copied to clipboard
open suspend override fun <R : Data> save(unit: StorageUnit<R>): R?

Save the cached data represented by the given storage unit to persistent storage, creating any files and folders as needed.

open suspend override fun <R : Data> save(unit: StorageUnit<R>, data: R): R

Save the given data represented by the given storage unit to persistent storage, creating any files and folders as needed, and storing the given data object in the dataCache.

Link copied to clipboard
open suspend fun saveAll()

Save all data objects stored in dataCache to persistent storage by calling save against each.