FileStorage



The Java IO File version of the Storage interface. Is able to read and write T to a given file location.

Summary

Public constructors

<T : Any?> FileStorage(
    serializer: Serializer<T>,
    coordinatorProducer: (File) -> InterProcessCoordinator,
    produceFile: () -> File
)
android

Public functions

open StorageConnection<T>

Creates a storage connection which allows reading and writing to the underlying storage.

android

Public constructors

FileStorage

<T : Any?> FileStorage(
    serializer: Serializer<T>,
    coordinatorProducer: (File) -> InterProcessCoordinator = { createSingleProcessCoordinator(it) },
    produceFile: () -> File
)
Parameters
serializer: Serializer<T>

The serializer that can write T to and from a byte array.

coordinatorProducer: (File) -> InterProcessCoordinator = { createSingleProcessCoordinator(it) }

The producer to provide InterProcessCoordinator that coordinates IO operations across processes if needed. By default it provides single process coordinator, which doesn't support cross process use cases.

produceFile: () -> File

The file producer that returns the file that will be read and written.

Public functions

createConnection

open fun createConnection(): StorageConnection<T>

Creates a storage connection which allows reading and writing to the underlying storage.

Should be closed after usage.

Throws
java.io.IOException

Unrecoverable IO exception when trying to access the underlying storage.