View Source Bzip2 (bzip2 v0.1.0)

Link to this section Summary

Functions

Compress a stream or a string

Decompress a stream or a string

Link to this section Types

@type compression_state() :: {Bzip2.Driver.compression_status(), reference()}
@type decompression_state() :: {Bzip2.Driver.decompression_status(), reference()}

Link to this section Functions

@spec compress!(binary() | Enumerable.t()) :: binary() | Enumerable.t()

Compress a stream or a string

Compressing a stream,

File.stream!("foo.txt", [], 100 * 1024)
|> Bzip2.compress!()
|> Stream.into(File.stream!("foo.txt.bz2"))
|> Stream.run()

Compressing a string,

Bzip2.compress!("foo")
|> Bzip2.decompress!()
# "foo"
@spec decompress!(binary() | Enumerable.t()) :: binary() | Enumerable.t()

Decompress a stream or a string

Decompressing a stream,

File.stream!("foo.txt.bz2", [], 100 * 1024)
|> Bzip2.decompress!()
|> Stream.into(File.stream!("foo.txt"))
|> Stream.run()

Decompressing a string,

Bzip2.compress!("foo")
|> Bzip2.decompress!()
# "foo"