hash-addressed-0.2.0.1: Hash-addressed file storage
Safe HaskellSafe-Inferred
LanguageGHC2021

HashAddressed.Directory

Synopsis

Type

data Directory Source #

Specification of a hash-addressed directory

Note that the utilities in HashAddressed.Directory do not create the directory; ensure that it already exists before attempting to write.

See HashAddressed.HashFunction for examples of hash functions.

Constructors

Directory 

Fields

Write operations

writeLazy Source #

Arguments

:: forall m. MonadIO m 
=> Directory

Where to write

-> ByteString

What to write

-> m WriteResult 

Write a lazy ByteString to a hash-addressed directory

This is a simplified variant of writeStream.

writeStream Source #

Arguments

:: forall commit m. MonadIO m 
=> Directory

Where to write

-> Producer ByteString IO commit

What to write

-> m (commit, WriteResult) 

Write a stream of strict ByteStrings to a hash-addressed directory

If the producer throws an exception, nothing will be written and the exception will be re-thrown.

This is a simplified variant of writeExcept.

writeExcept Source #

Arguments

:: forall abort commit m. (MonadIO m, MonadError abort m) 
=> Directory

Where to write

-> Producer ByteString IO (Either abort commit)

What to write

-> m (commit, WriteResult) 

Write a stream of strict ByteStrings to a hash-addressed directory, possibly aborting mid-stream with an error value instead

If the producer throws abort or an IO exception, nothing will be written. An abort thrown via ExceptT will be re-thrown via MonadError, and an exception thrown via IO will be re-thrown via IO.

data WriteResult Source #

Constructors

WriteResult 

Fields

data WriteType Source #

Constructors

AlreadyPresent

No action was taken because the content is already present in the directory

NewContent

A new file was written into the directory