Resource

kantan.codecs.resource.Resource
See theResource companion object
trait Resource[I, R]

Represents a resource that can be opened and worked on.

The purpose of this trait is to abstract over the notion of "things that can be opened", such as files, URLs... Default instances are provided for java.io types - java.io.File, for example, has instances for both opening it for reading and for writing.

Type parameters

I

type of the resource itself (eg java.io.File).

R

type of the opened resource (eg java.io.InputStream)

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Resource[I, R]

Members list

Value members

Abstract methods

def open(input: I): OpenResult[R]

Opens the specified resource.

Opens the specified resource.

Attributes

Concrete methods

def contramap[II](f: II => I): Resource[II, R]
def econtramap[II](f: II => OpenResult[I]): Resource[II, R]
def emap[RR](f: R => OpenResult[RR]): Resource[I, RR]
def map[RR](f: R => RR): Resource[I, RR]
def withResource[O](input: I)(f: R => ProcessResult[O])(implicit c: Closeable[R]): ResourceResult[O]

Opens the specified resource and applies the specified function to its content.

Opens the specified resource and applies the specified function to its content.

The resource will be closed regardless of whether f fails. Note that f is expected to be safe - it cannot throw but should instead wrap all errors in a ProcessResult.

Attributes

Deprecated methods

def contramapResult[II](f: II => OpenResult[I]): Resource[II, R]

Attributes

Deprecated
true
def mapResult[RR](f: R => OpenResult[RR]): Resource[I, RR]

Attributes

Deprecated
true