package resource
- Alphabetic
- By Inheritance
- resource
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
- type CloseResult = Either[CloseError, Unit]
-
trait
Closeable[A] extends AnyRef
Type class for all types that can be closed.
-
type
InputResource[A] = Resource[A, InputStream]
Resource specialised for
java.io.InputStream. - type OpenResult[A] = Either[OpenError, A]
-
type
OutputResource[A] = Resource[A, OutputStream]
Resource specialised for
java.io.OutputStream. -
trait
PlatformSpecificInstances extends AnyRef
JVM specific instances of Resource.
- type ProcessResult[A] = Either[ProcessError, A]
-
type
ReaderResource[A] = Resource[A, Reader]
Resource specialised for
java.io.Reader.Resource specialised for
java.io.Reader.Note that it's good practice not to declare explicit instances of ReaderResource for types that have an instance of InputResource. It's better to let the implicit resolution mechanism work out how to best turn an
InputStreaminto aReader- the JVM-specific kantan.codecs.resource.bom package, in particular, relies on this. -
trait
Resource[I, R] extends AnyRef
Represents a resource that can be opened and worked on.
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.iotypes -java.io.File, for example, has instances for both opening it for reading and for writing.- I
type of the resource itself (eg
java.io.File).- R
type of the opened resource (eg
java.io.InputStream)
- sealed trait ResourceError extends Product with Serializable
- trait ResourceIterable[A] extends AnyRef
-
trait
ResourceIterator[+A] extends TraversableOnce[A] with java.io.Closeable
Offers iterator-like access to IO resources.
Offers iterator-like access to IO resources.
For the most part, values of type ResourceIterator can be considered as iterators, with a few improvements.
First, they have a ResourceIterator.close()* method, which allows you to release the underlying resource when needed. This is fairly important and part of the reason why working with
Source.getLinescan be so aggravating.Second, ResourceIterator.close()* is mostly not needed: whenever an IO error occurs or the underlying resource is empty, it will be closed automatically. Provided you intend to read the whole resource, you never need to explicitly close it. This covers non-obvious cases such as filtering or dropping elements.
You should be able to express most common causes for not reading the entire stream through standard combinators. For example, "take the first
nelements" istake(n), or "take all odd elements" isfilter(_ % 2 == 0). This allows you to ignore the fact that the underlying resource needs to be closed. Should you ever find youself in a situation when you just want to stop, however, ResourceIterator.close()* is available.- Annotations
- @SuppressWarnings()
- type ResourceResult[A] = Either[ResourceError, A]
-
type
WriterResource[A] = Resource[A, Writer]
Resource specialised for
java.io.Writer.Resource specialised for
java.io.Writer.Note that it's good practice not to declare explicit instances of WriterResource for types that have an instance of OutputResource. It's better to let the implicit resolution mechanism work out how to best turn an
OutputStreaminto aWriter- the JVM-specific kantan.codecs.resource.bom package, in particular, relies on this.
Value Members
- object Closeable
-
object
InputResource
Provides instance summoning methods for InputResource.
-
object
OutputResource
Provides instance summoning methods for OutputResource.
-
object
ReaderResource
Provides instance summoning methods for ReaderResource.
- object Resource extends PlatformSpecificInstances
- object ResourceError extends Serializable
- object ResourceIterator
-
object
WriterResource
Provides instance summoning methods for WriterResource.