Defines the behavior of an identifier scheme.
Summary
Callbacks
Builds a URI from the canonical form.
Returns whether the given input is an identifier according to the scheme.
Normalizes the identifier to the scheme's canonical form.
Callbacks
@callback build_uri(canonical) :: {:ok, URI.t()} | {:error, reason} when canonical: binary(), reason: term()
Builds a URI from the canonical form.
Implementations expect the input to be an identifier in its canonical form. Not all schemes have a URI representation, this callback is only implemented by schemes that support it.
Returns whether the given input is an identifier according to the scheme.
Matching may be lenient by design: noisy input (e.g., a query string in an URL-representation
of an identifier) matches. It is assumed that the output of normalize/1 is always used for
storage and comparison.
@callback normalize(identifier) :: {:ok, canonical} | {:error, reason} when identifier: binary(), canonical: binary(), reason: term()
Normalizes the identifier to the scheme's canonical form.
Implementations expect the input to be an identifier that conforms to the scheme. They are not required to guarantee rejection of input that is not a valid identifier.