Storehouse.Archive.Format behaviour (Storehouse v0.2.0)

Copy Markdown View Source

A format of archive (Storehouse.Archive): zip (Storehouse.Archive.Zip, the default), tar (Storehouse.Archive.Tar), or one of the app's.

config :storehouse, archive_format: MyApp.SevenZip

Storehouse.Archive reads the files, checks their names, decides which to compress, splits and stores the archive: a format only lays out bytes. It is given each file as a Storehouse.Archive.Entry, and the options of the call (:compression, :password, :modified_at, its own).

Summary

Callbacks

The most bytes a file of known size takes in the archive, its headers with it: how :max_bytes splits.

The archive's content type.

The most bytes the end of an archive of count files takes.

Its size before it is made: {:ok, bytes} exact, {:about, bytes} near enough (compressed), or :unknown (a file's size is not known).

The archive, as a stream of iodata, made as it is taken.

Callbacks

bound(t, opts)

@callback bound(Storehouse.Archive.Entry.t(), opts :: keyword()) :: non_neg_integer()

The most bytes a file of known size takes in the archive, its headers with it: how :max_bytes splits.

content_type(list, opts)

@callback content_type([Storehouse.Archive.Entry.t()], opts :: keyword()) :: String.t()

The archive's content type.

end_bound(count, opts)

@callback end_bound(count :: non_neg_integer(), opts :: keyword()) :: non_neg_integer()

The most bytes the end of an archive of count files takes.

size(list, opts)

@callback size([Storehouse.Archive.Entry.t()], opts :: keyword()) ::
  {:ok, non_neg_integer()} | {:about, non_neg_integer()} | :unknown

Its size before it is made: {:ok, bytes} exact, {:about, bytes} near enough (compressed), or :unknown (a file's size is not known).

stream(list, opts)

@callback stream([Storehouse.Archive.Entry.t()], opts :: keyword()) :: Enumerable.t()

The archive, as a stream of iodata, made as it is taken.