-module(multipartkit@infer). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/multipartkit/infer.gleam"). -export([default_inferer/0, content_type_from_filename/1, content_type_from_bytes/1]). -export_type([inferer/0]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. -type inferer() :: {inferer, fun((binary()) -> gleam@option:option(binary())), fun((bitstring()) -> gleam@option:option(binary()))}. -file("src/multipartkit/infer.gleam", 58). -spec noop_filename(binary()) -> gleam@option:option(binary()). noop_filename(_) -> none. -file("src/multipartkit/infer.gleam", 62). -spec noop_bytes(bitstring()) -> gleam@option:option(binary()). noop_bytes(_) -> none. -file("src/multipartkit/infer.gleam", 54). ?DOC( " Inferer that always returns `None`.\n" "\n" " `add_file_auto` uses this and therefore always emits\n" " `application/octet-stream` unless the host swaps in a real inferer via\n" " `add_file_auto_with`.\n" ). -spec default_inferer() -> inferer(). default_inferer() -> {inferer, fun noop_filename/1, fun noop_bytes/1}. -file("src/multipartkit/infer.gleam", 71). ?DOC( " Optional content-type inference from a filename.\n" "\n" " The default v0.1.0 implementation always returns `None`. Wire `mimetype`\n" " (or another inferer) in via `form.add_file_auto_with` to enable\n" " inference.\n" ). -spec content_type_from_filename(binary()) -> gleam@option:option(binary()). content_type_from_filename(Filename) -> (erlang:element(2, default_inferer()))(Filename). -file("src/multipartkit/infer.gleam", 78). ?DOC( " Optional content-type inference from a body byte sequence.\n" "\n" " Same default-`None` policy as `content_type_from_filename`.\n" ). -spec content_type_from_bytes(bitstring()) -> gleam@option:option(binary()). content_type_from_bytes(Body) -> (erlang:element(3, default_inferer()))(Body).