Writer

info.fingo.spata.io.Writer
See theWriter companion object
sealed trait Writer[F[_]]

Writer interface with writing operations to various destinations. The I/O operations are wrapped in effect F (e.g. cats.effect.IO), allowing deferred computation.

Processing I/O errors, manifested through java.io.IOException, should be handled with fs2.Stream.handleErrorWith. If not handled, they will propagate as exceptions.

Type parameters

F

the effect type

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Plain[F]
class Shifting[F]

Members list

Value members

Abstract methods

def write(fos: F[OutputStream])(using codec: Codec): (F, Char) => Unit

Writes CSV to destination OutputStream.

Writes CSV to destination OutputStream.

Value parameters

codec

codec used to convert bytes to characters, with default JVM charset as fallback

fos

input stream containing CSV content, wrapped in effect F to defer its creation

Attributes

Returns

pipe converting stream of characters to empty one

Note

This function does not close the output stream after use, which is different from default behavior of fs2-io functions taking OutputStream as parameter.

def write(os: OutputStream)(using codec: Codec): (F, Char) => Unit

Writes CSV to destination OutputStream.

Writes CSV to destination OutputStream.

Value parameters

codec

codec used to convert bytes to characters, with default JVM charset as fallback

os

input stream containing CSV content

Attributes

Returns

pipe converting stream of characters to empty one

Note

This function does not close the output stream after use, which is different from default behavior of fs2-io functions taking OutputStream as parameter.

def write(path: Path)(using codec: Codec): (F, Char) => Unit

Writes CSV to target path.

Writes CSV to target path.

Value parameters

codec

codec used to convert bytes to characters, with default JVM charset as fallback

path

the path to target file

Attributes

Returns

pipe converting stream of characters to empty one

Example
given codec = new Codec(Charset.forName("UTF-8"))
val path = Path.of("data.csv")
val stream: Stream[IO, Char] = ???
val handler: Stream[IO, Unit] = stream.through(Writer[IO].write(path))

Concrete methods

def apply[A : CSV](csv: A)(implicit evidence$1: CSV[A], codec: Codec): (F, Char) => Unit

Alias for various write methods.

Alias for various write methods.

Type parameters

A

type of target

Value parameters

codec

codec used to convert bytes to characters, with default JVM charset as fallback

csv

the CSV data destination

Attributes

Returns

pipe converting stream of characters to empty one

def apply(csv: F[OutputStream])(using codec: Codec): (F, Char) => Unit

Alias for write method.

Alias for write method.

Value parameters

codec

codec used to convert bytes to characters, with default JVM charset as fallback

csv

the CSV data destination

Attributes

Returns

pipe converting stream of characters to empty one