# Module Structure And Features
Fun I/O has a modular structure.
Its artifacts are hosted on Maven Central with the common group ID
global.namespace.fun-io.
The following diagram shows the module structure:
# API Modules
API modules provide powerful abstractions for simple and safe synchronous I/O operations.
# Fun I/O API
TIP
This module is a transitive dependency of all other modules, so you don't need to add it directly.
The module
fun-io-api
provides essential abstractions like Codec, Source, Sink, Store, ArchiveSource, ArchiveSink, ArchiveStore,
Filter, Socket et al.
All other modules (transitively) depend on this module.
# Fun I/O Scala API
TIP
This module is completely optional: You should add it to Scala applications, however.
The module
fun-io-scala-api
extends the Java API with operators and implicit conversions to improve the development experience in Scala.
# Implementation Modules
Each implementation module provides a single facade class which contains many static factory methods for different
implementations of the abstractions provided by the fun-io-api module.
# Fun I/O AWS SDK1
The module
fun-io-aws-sdk1
depends on the AWS SDK for Java to provide implementations of the Fun I/O API:
- The
AWSclass is a facade which provides the followingArchiveStorefunctions:s3provides read/write access to an AWS S3 bucket or any sub-tree of it.
# Fun I/O AWS SDK2
The module
fun-io-aws-sdk2
depends on the AWS SDK for Java 2.0 to provide implementations of the Fun I/O API:
- The
AWSclass is a facade which provides the followingArchiveStorefunctions:s3provides read/write access to an AWS S3 bucket or any sub-tree of it.
# Fun I/O BIOS
TIP
This is the default implementation module: Most applications have a single dependency on this module. If you are not sure where to find a feature, look here first.
The module
fun-io-bios
provides basic implementations of the Fun I/O API (BIOS stands for "Basic Input/Output System" - pun intended):
- The
BIOSclass is a facade which provides the followingCodecfunctions:serializationserializes/deserializes objects usingObjectOutputStream/ObjectInputStream.xmlencodes/decodes objects usingXMLEncoder/XMLDecoder.
- It also provides the following
Filterfunctions:base64encodes/decodes data using Base64.bufferbuffers I/O operations.cipherencrypts/decrypts data using a function which provides initializedjavax.security.Cipherobjects.deflatecompresses/decompresses data using a ZIP deflater/inflater.gzipcompresses/decompresses data using the GZIP format.identityis a no-op, forming filters into a Monoid under the operationsFilter.andThenandFilter.compose.inflatedecompresses/compresses data using a ZIP inflater/deflater.
- It also provides the following
Sourcefunctions:resourcereads a resource from the class path.stdinreads the standard input.streamreads an arbitrary input stream without ever closing it.urlreads the content of a URL.
- It also provides the following
Sinkfunctions:stderrwrites to standard error.stdoutwrites to standard output.streamwrite to an arbitrary output stream without ever closing it.
- It also provides the following
Storefunctions:filestores data in a file, based onjava.io.File.memorystores data on the heap. This is primarily used for cloning objects or testing.pathstores data in a files or any other path, based onjava.nio.file.Path.preferencesstores data in a preferences node using a given key.systemPreferencesstores data in a system preferences nodes representing a given class.userPreferencesstores data in a user preferences nodes representing a given class.
- It also provides the following
ArchiveStorefunctions:directoryprovides read/write access to a directory as if it were an archive file.jarprovides read/write access to JAR files.zipprovides read/write access to ZIP files.
- It also provides the following utility functions:
copyis a high performance algorithm for copying data from aSourceto aSink, includingStore, or from anArchiveSourceto anArchiveSink, includingArchiveStore.cloneduplicates an object by serializing it to memory and decoding it again.
# Fun I/O Commons Compress
TIP
Use this module when processing archive files (JAR, 7zip, TAR, ZIP and derivatives).
It provides better performance and more accuracy than the module fun-io-bios.
The module
fun-io-commons-compress
depends on Apache Commons Compress to provide implementations of the Fun I/O API:
- The
CommonsCompressclass is a facade which provides the followingFilterfunctions:blockLZ4compresses/decompresses data using the LZ4 block format.bzip2compresses decompresses data using the BZIP2 format.deflatecompresses/decompresses data using a ZIP deflater/inflater.framedLZ4compresses/decompresses data using the LZ4 frame format.framedSnappycompresses/decompresses data using the Snappy frame format.gzipcompresses/decompresses data using the GZIP format.lzmacompresses/decompresses data using the LZMA format.lzma2compresses/decompresses data using the LZMA2 format.
- It also provides the following
ArchiveStorefunctions:jarprovides read/write access to JAR files.sevenzprovides copy-only access to 7zip files.tarprovides copy-only access to TAR files.zipprovides read/write access to ZIP files.
# Fun I/O Jackson
The module
fun-io-jackson
depends on Jackson Databind to provide implementations of the Fun I/O API:
- The
Jacksonclass is a facade which provides the followingCodecfunctions:jsonmarshals/unmarshals objects to/from JSON using Jackson Databind.
# Fun I/O JAXB
The module
fun-io-jaxb
depends on JAXB to provide implementations of the Fun I/O API:
- The
JAXBclass is a facade which provides the followingCodecfunctions:xmlmarshals/unmarshals objects to/from XML using the JAXB reference implementation.
# Fun I/O XZ
The module
fun-io-xz
depends on XZ for Java to provide implementations of the Fun I/O API:
- The
XZclass is a facade which provides the followingFilterfunctions:lzmacompresses/decompresses data using the LZMA format.lzma2compresses/decompresses data using the LZMA2 format.xzcompresses/decompresses data using the XZ format.
# Fun I/O Zstd
The module
fun-io-zstd
depends on Zstd-jni to provide implementations of the Fun I/O API:
- The
Zstdclass is a facade which provides the followingFilterfunctions:zstdcompresses/decompresses data using the Zstd format.
# Application Modules
Application modules depend on the API and expect some implementation to be injected for a particular task. Like implementation modules, they provide a single facade class containing static methods to solve their particular task.
# Fun I/O Delta
The module
fun-io-delta
provides utility functions for diffing and patching archive files or directories:
- The
Deltaclass is a facade which provides the following utility functions:diffcompares two archive files or directories to compute a delta archive file or directory or model.patchpatches an archive file or directory with a delta archive file or directory.