spectra_binary_string (spectra v0.7.0)

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)

-spec from_binary_string(TypeInfo :: spectra:type_info(),
                         Type :: spectra:sp_type_or_ref(),
                         BinaryString :: binary()) ->
                            {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)

-spec to_binary_string(TypeInfo :: spectra:type_info(),
                       Type :: spectra:sp_type_or_ref(),
                       Data :: dynamic()) ->
                          {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