majic/lib/gen_magic/result.ex
Evadne Wu 0bc39d9ad1 Initial Commit (v1.0.0)
- History for v0.20.83 and previous versions is moved to archive/v0.20.83
2020-05-04 05:04:38 +01:00

30 lines
877 B
Elixir

defmodule GenMagic.Result do
@moduledoc """
Represents the results obtained from libmagic.
Please note that this struct is only returned if the underlying check has succeeded.
"""
@typedoc """
Represents the result.
Contains the MIME type, Encoding and Content fields returned by libmagic, as per the flags:
- MIME Type: `MAGIC_FLAGS_COMMON|MAGIC_MIME_TYPE`
- Encoding: `MAGIC_FLAGS_COMMON|MAGIC_MIME_ENCODING`
- Type Name (Content): `MAGIC_FLAGS_COMMON|MAGIC_NONE`
"""
@type t :: %__MODULE__{
mime_type: String.t(),
encoding: String.t(),
content: String.t()
}
@enforce_keys ~w(mime_type encoding content)a
defstruct mime_type: nil, encoding: nil, content: nil
@doc false
def build(mime_type, encoding, content) do
%__MODULE__{mime_type: mime_type, encoding: encoding, content: content}
end
end