bytestring-progress-1.2: A library for tracking the consumption of a lazy ByteString

Safe HaskellNone
LanguageHaskell98

Data.ByteString.Lazy.Progress

Description

This module defines core functions for tracking the consumption of a ByteString, as well as several helper functions for making tracking ByteStrings easier.

Synopsis

Documentation

trackProgress :: (Word64 -> Word64 -> IO ()) -> ByteString -> IO ByteString Source #

Given a function, return a bytestring that will call that function when it is partially consumed. The Words provided to the function will be the number of bytes that were just consumed and the total bytes consumed thus far.

trackProgressWithChunkSize :: Word64 -> (Word64 -> Word64 -> IO ()) -> ByteString -> IO ByteString Source #

Works like trackProgress, except uses fixed-size chunks of the given size. Thus, for this function, the first number passed to your function will always be the given size *except* for the last call to the function, which will be less then or equal to the final size.

trackProgressString :: String -> Maybe Word64 -> (String -> IO ()) -> IO (ByteString -> IO ByteString) Source #

Given a format string (described below), track the progress of a function. The argument to the callback will be the string expanded with the given progress information.

Format string items:

  • %b is the number of bytes read
  • %B is the number of bytes read, formatted into a human-readable string
  • %c is the size of the last chunk read
  • %C is the size of the last chunk read, formatted human-readably
  • %r is the rate in bytes per second
  • %R is the rate, formatted human-readably
  • %% is the character %

If you provide a total size (the maybe argument, in bytes), then you may also use the following items:

  • %t is the estimated time to completion in seconds
  • %T is the estimated time to completion, formatted as HH:MM:SS
  • %p is the percentage complete

trackProgressStringWithChunkSize Source #

Arguments

:: String

the format string

-> Word64

the chunk size

-> Maybe Word64

total size (opt.)

-> (String -> IO ())

the action

-> IO (ByteString -> IO ByteString) 

Exactly as trackProgressString, but use the given chunkSize instead of the default chunk size.

bytesToUnittedStr :: Word64 -> String Source #

Convert a number of bytes to a string represenation that uses a reasonable unit to make the number human-readable.