Package-level declarations

Types

Link copied to clipboard
class BufferingResource(resource: Resource, resourceLength: Long? = null, bufferSize: Int = DEFAULT_BUFFER_SIZE) : Resource

Wraps a Resource and buffers its content.

Link copied to clipboard

A composite ResourceFactory which tries several factories until it finds one which supports the url scheme.

Link copied to clipboard

Implements the transformation of a Resource. It can be used, for example, to decrypt, deobfuscate, inject CSS or JavaScript, correct content – e.g. adding a missing dir="rtl" in an HTML document, pre-process – e.g. before indexing a publication's content, etc.

Link copied to clipboard

Creates a Resource that will always return the given error.

Link copied to clipboard
class FallbackResource(originalResource: Resource, fallbackResourceFactory: (ReadError) -> Resource?) : Resource

Resource that will act as a proxy to a fallback resource if the originalResource errors out.

Link copied to clipboard
class InMemoryResource(val sourceUrl: AbsoluteUrl?, properties: Resource.Properties, bytes: suspend () -> Try<ByteArray, ReadError>) : Resource

Creates a Resource serving a ByteArray.

Link copied to clipboard
open class LazyResource(val sourceUrl: AbsoluteUrl? = null, factory: suspend () -> Resource) : Resource

Wraps a Resource which will be created only when first accessing one of its members.

Link copied to clipboard
interface Resource : Readable

Acts as a proxy to an actual resource by handling read access.

Link copied to clipboard
interface ResourceFactory

A factory to read Resources from Urls.

Link copied to clipboard
class SingleResourceContainer(entryUrl: Url, resource: Resource) : Container<Resource>

A Container for a single Resource.

Link copied to clipboard

Creates a Resource serving a String.

Link copied to clipboard

Protects the access to a wrapped resource with a mutex to make it thread-safe.

Link copied to clipboard

Transforms the resources' content of a child fetcher using a list of EntryTransformer functions.

Link copied to clipboard
abstract class TransformingResource(resource: Resource, cacheBytes: Boolean = true) : Resource

Transforms the bytes of resource on-the-fly.

Functions

Link copied to clipboard

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

Link copied to clipboard
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
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
fun Resource.map(transform: suspend (ByteArray) -> Try<ByteArray, ReadError>): Resource
Link copied to clipboard

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