package net.sergeych.bintools /** * Abstraction of some file- or named_record- storage. It could be a filesystem * on native and JVM targets and indexed DB or session storage in the browser. */ interface DataProvider { open class Error(msg: String,cause: Throwable?=null): Exception(msg,cause) class NotFoundException(msg: String="record not found",cause: Throwable? = null): Error(msg, cause) class WriteFailedException(msg: String="can't write", cause: Throwable?=null): Error(msg,cause) /** * Read named record/file * @throws NotFoundException */ fun read(name: String,f: (DataSource)->T): T /** * Write to a named record / file. * @throws WriteFailedException */ fun write(name: String,f: (DataSink)->Unit) /** * Delete if exists, or do nothing. */ fun delete(name: String) /** * List all record names in this source */ fun list(): List }