format_parser v0.6.1 FormatParser

The Format Parser

Link to this section Summary

Functions

Parses the format of a given file. Or returs an error if unknown

Link to this section Functions

Link to this function parse(file)
parse(binary()) :: struct()

Parses the format of a given file. Or returs an error if unknown.

Examples

iex> {:ok, file} = File.read("priv/test.jpg")
iex> FormatParser.parse(file)
%FormatParser.Image{format: :jpg, height_px: nil, nature: :image, width_px: nil}

iex> {:ok, file} = File.read("priv/test.html")
iex> FormatParser.parse(file)
{:error, "Unknown"}