Package-level declarations

Types

Link copied to clipboard

Abstract base class for types that can be serialized to a ByteArray.

Link copied to clipboard

Marks code elements that should be ignored by the reader.

Link copied to clipboard

An exception thrown when an element marked with Ignore is accessed or processed, indicating the reason.

Link copied to clipboard

Lists reasons for marking code elements to be ignored by the reader, as used by the Ignore annotation.

Link copied to clipboard
sealed interface Outcome<out T>

Represents the result of an operation that can either succeed with a value or fail with an error.

Properties

Link copied to clipboard
val fileSystem: FileSystem

The default FileSystem instance for file operations, using the system's native file system.

Functions

Link copied to clipboard
fun <T> String.deserialize(deserializer: KSerializer<T>, format: StringFormat = jsonForMachines): T

Deserializes this string to an object of type T using the specified deserializer and format.

Link copied to clipboard
fun failure(outcome: Outcome<*>? = null): Outcome.Failure

Creates a Failure with an optional nested outcome.

fun failure(throwable: Throwable, outcome: Outcome<*>? = null): Outcome.Failure

Creates a Failure with the specified throwable and optional nested outcome.

fun failure(message: String, throwable: Throwable? = null, outcome: Outcome<*>? = null): Outcome.Failure

Creates a Failure with the specified message, throwable, and optional nested outcome.

Link copied to clipboard
inline suspend fun <T, R> Outcome<T>.flatMap(transform: suspend (T) -> Outcome<R>): Outcome<R>

Flat-maps the value of a successful Outcome using the provided transform function.

Link copied to clipboard
inline suspend fun <T, R> Outcome<T>.fold(onSuccess: suspend (T) -> R, onFailure: suspend (String, Throwable?) -> R): R

Folds the Outcome into a single value by applying onSuccess for a Success or onFailure for a Failure.

Link copied to clipboard

Returns the specified IgnoreReason for use in code or annotations.

Link copied to clipboard

Throws an IgnoredException with the specified reason.

Link copied to clipboard
inline suspend fun <T, R> Outcome<T>.map(transform: suspend (T) -> R): Outcome<R>

Maps the value of a successful Outcome using the provided transform function.

Link copied to clipboard
inline suspend fun <T, R> Outcome<T>.mapCatching(transform: suspend (T) -> R): Outcome<R>

Maps the value of a successful Outcome using the provided transform function, catching any exceptions.

Link copied to clipboard
inline suspend fun <T> Outcome<T>.mapFailure(transform: suspend (Outcome.Failure) -> Outcome.Failure): Outcome<T>

Maps a Failure using the provided transform function, leaving Success unchanged.

Link copied to clipboard

Pads this ByteArray to the specified length with zeros if it is too short.

Link copied to clipboard

Prepends a prefix ByteArray to this ByteArray.

Link copied to clipboard
suspend fun <T> File.readAndDeserialize(deserializer: KSerializer<T>, format: StringFormat = jsonForMachines): Outcome<T>

Reads the content of the specified File and deserializes it to an object of type T.

suspend fun <T> Path.readAndDeserialize(deserializer: KSerializer<T>, format: StringFormat = jsonForMachines): Outcome<T>

Reads the content of the specified Path and deserializes it to an object of type T.

Link copied to clipboard
inline suspend fun <T> Outcome<T>.recover(recoverBlock: suspend (Outcome.Failure) -> T): Outcome<T>

Recovers from a Failure by applying the recoverBlock function to produce a new value.

Link copied to clipboard
inline suspend fun <T> Outcome<T>.recoverCatching(recoverBlock: suspend (Outcome.Failure) -> T): Outcome<T>

Recovers from a Failure by applying the recoverBlock function, catching any exceptions.

Link copied to clipboard
inline suspend fun <T> runCatchingOutcomeBlock(block: suspend () -> Outcome<T>): Outcome<T>

Executes the block that returns an Outcome, catching any exceptions.

Link copied to clipboard
inline suspend fun <T> T.runCatchingOutcomeBlock(block: suspend () -> Outcome<T>): Outcome<T>

Executes the block that returns an Outcome, using this value as context, catching any exceptions.

Link copied to clipboard
inline suspend fun <T> runCatchingOutcomeOf(block: suspend () -> T): Outcome<T>

Executes the block and wraps the result in an Outcome.

Link copied to clipboard
inline suspend fun <T> T.runCatchingOutcomeOf(block: suspend () -> T): Outcome<T>

Executes the block and wraps the result in an Outcome, using this value as context.

Link copied to clipboard
fun <T> T.serialize(serializer: KSerializer<T>, format: StringFormat = jsonForMachines): String

Serializes this object to a string using the specified serializer and format.

Link copied to clipboard
suspend fun <T> T.serializeAndWrite(serializer: KSerializer<T>, path: Path, append: Boolean = true, atomicMove: Boolean = false, format: StringFormat = jsonForMachines): Outcome<T>

Serializes this object and writes it to the specified path.

Link copied to clipboard
fun serializersModuleBuilder(serializersModuleBuilder: SerializersModuleBuilder.() -> Unit): SerializersModuleBuilder.() -> Unit

Wraps a SerializersModuleBuilder lambda for use in serialization configurations.

Link copied to clipboard
fun Path.sibling(name: String): Path

Creates a Path for a sibling file or directory with the specified name.

Link copied to clipboard

Creates a Success with a true value.

fun <T> success(value: T): Outcome.Success<T>

Creates a Success with the specified value.

inline suspend fun <T> success(block: suspend () -> T): Outcome.Success<T>

Executes the block and wraps the result in a Success.

Link copied to clipboard

Converts this Result to an Outcome.