spectra_binary_string (spectra v0.11.2)

View Source

Summary

Functions

Converts a binary string value to an Erlang value based on a type specification.

Converts an Erlang value to a binary string based on a type specification.

Functions

from_binary_string(TypeInfo, Type, BinaryString, Opts, Config)

-spec from_binary_string(TypeInfo :: spectra:type_info(),
                         Type :: spectra:sp_type(),
                         BinaryString :: binary(),
                         Opts :: spectra:binary_string_decode_opts(),
                         Config :: spectra:sp_config()) ->
                            {ok, dynamic()} | {error, [spectra:error()]}.

Converts a binary string value to an Erlang value based on a type specification.

This function validates the given binary string value against the specified type definition and converts it to the corresponding Erlang value.

Returns

{ok, ErlangValue} if conversion succeeds, or {error, Errors} if validation fails

to_binary_string(TypeInfo, Type, Data, Opts, Config)

-spec to_binary_string(TypeInfo :: spectra:type_info(),
                       Type :: spectra:sp_type(),
                       Data :: dynamic(),
                       Opts :: spectra:binary_string_encode_opts(),
                       Config :: spectra:sp_config()) ->
                          {ok, binary()} | {error, [spectra:error()]}.

Converts an Erlang value to a binary string based on a type specification.

This function validates the given Erlang value against the specified type definition and converts it to a binary string representation.

Returns

{ok, BinaryString} if conversion succeeds, or {error, Errors} if validation fails