This module is the interface module for the ASN.1 runtime support functions. To encode and decode ASN.1 types in runtime the functions in this module should be used.
encode(Module,Type,Value)-> {ok,BinOrList} | {error,Reason}
Module = Type = atom()
Value = term()
BinOrList = Bytes | binary()
Bytes = [Int|binary|Bytes] when integer(Int), Int >= 0, Int =< 255
Reason = term()
Encodes Value
of Type
defined in the ASN.1 module
Module
. Returns a possibly nested list of bytes and or binaries
if successful. If Module
was compiled with the options per_bin
and optimize
the result is a binary. To get as
fast execution as possible the
encode function only performs rudimentary tests that the input
Value
is a correct instance of Type
. The length of strings is for example
not always checked.
decode(Module,Type,Bytes) -> {ok,Value}|{error,Reason}
Module = Type = atom()
Value = Reason = term()
Bytes = binary | [Int] when integer(Int), Int >= 0, Int =< 255 | binary
Decodes Type
from Module
from the list of bytes or
binary Bytes
. If the module is compiled with ber_bin
or per_bin
option Bytes
must be a binary.
Returns {ok,Value}
if successful.
validate(Module,Type,Value) -> ok | {error,Reason}
Module = Type = atom()
Value = term()
Validates that Value
conforms to Type
from Module
. Not implemented in this version of the
ASN.1 application.
load_driver() -> ok | {error,Reason}
Reason = term()
This function loads the linked-in driver before the first call to encode. If this function is not called the driver will be loaded automatically at the first call to encode. If one doesn't want the performance cost of a driver load when the application is running, this function makes it possible to load the driver in an initialization.