FailureResource

Creates a Resource that will always return the given error.

Constructors

Link copied to clipboard
constructor(error: ReadError)

Properties

Link copied to clipboard
open override val sourceUrl: AbsoluteUrl? = null

URL locating this resource, if any.

Functions

Link copied to clipboard
fun Readable.asInputStream(range: LongRange? = null, wrapError: (ReadError) -> IOException = { ReadException(it) }): InputStream

Wraps a Readable into an InputStream.

Link copied to clipboard

Returns a new Readable accessing the same data but not owning them.

Returns a new Resource accessing the same data but not owning them.

Link copied to clipboard
fun Readable.buffered(contentLength: Long? = null, bufferSize: Int = DEFAULT_BUFFER_SIZE): Readable

Wraps this resource into a buffer to improve reading performances.

fun Resource.buffered(resourceLength: Long? = null, bufferSize: Int = DEFAULT_BUFFER_SIZE): BufferingResource

Wraps this resource in a BufferingResource to improve reading performances.

Link copied to clipboard
open override fun close()

Closes this object and releases any resources associated with it. If the object is already closed then invoking this method has no effect.

Link copied to clipboard
fun Resource.fallback(fallbackResourceFactory: (ReadError) -> Resource?): Resource

Falls back to alternative resources when the receiver fails.

fun Resource.fallback(fallbackResource: Resource): Resource

Falls back to the given alternative Resource when the receiver fails.

Link copied to clipboard
fun <R : Resource> Resource.flatMap(transform: suspend (Resource) -> R): LazyResource
Link copied to clipboard
open suspend override fun length(): Try<Long, ReadError>

Returns data length from metadata if available, or calculated from reading the bytes otherwise.

Link copied to clipboard
fun Resource.map(transform: suspend (ByteArray) -> Try<ByteArray, ReadError>): Resource
Link copied to clipboard
open suspend override fun properties(): Try<Resource.Properties, ReadError>

Properties associated to the resource.

Link copied to clipboard
open suspend override fun read(range: LongRange?): Try<ByteArray, ReadError>

Reads the bytes at the given range.

Link copied to clipboard
inline suspend fun <R> Readable.readDecodeOrElse(decode: (value: ByteArray) -> Try<R, DecodeError>, recover: (ReadError) -> R): R
inline suspend fun <R> Readable.readDecodeOrElse(decode: (value: ByteArray) -> Try<R, DecodeError>, recoverRead: (ReadError) -> R, recoverDecode: (DecodeError.Decoding) -> R): R
Link copied to clipboard
inline suspend fun <R> Readable.readDecodeOrNull(decode: (value: ByteArray) -> Try<R, DecodeError>): R?
Link copied to clipboard
inline suspend fun Readable.readOrElse(recover: (ReadError) -> ByteArray): ByteArray
Link copied to clipboard

Wraps this resource in a SynchronizedResource to protect the access from multiple threads.

Link copied to clipboard
open override fun toString(): String