SnmpKit.SnmpMgr.Types (snmpkit v0.6.3)
SNMP data type handling and conversion.
Handles encoding and decoding of SNMP values, including automatic type inference and explicit type specification.
Summary
Functions
Decodes an SNMP value to an Elixir term.
Encodes a value for SNMP with optional type specification.
Automatically infers the SNMP type from an Elixir value.
Functions
Decodes an SNMP value to an Elixir term.
Examples
iex> SnmpKit.SnmpMgr.Types.decode_value({:string, "Hello"})
"Hello"
iex> SnmpKit.SnmpMgr.Types.decode_value({:integer, 42})
42
Encodes a value for SNMP with optional type specification.
Parameters
value
- The value to encodeopts
- Options including :type for explicit type specification
Examples
iex> SnmpKit.SnmpMgr.Types.encode_value("Hello World")
{:ok, {:string, "Hello World"}}
iex> SnmpKit.SnmpMgr.Types.encode_value(42)
{:ok, {:integer, 42}}
iex> SnmpKit.SnmpMgr.Types.encode_value("192.168.1.1", type: :ipAddress)
{:ok, {:ipAddress, {192, 168, 1, 1}}}
Automatically infers the SNMP type from an Elixir value.
Examples
iex> SnmpKit.SnmpMgr.Types.infer_type("hello")
:string
iex> SnmpKit.SnmpMgr.Types.infer_type(42)
:integer
iex> SnmpKit.SnmpMgr.Types.infer_type("192.168.1.1")
:string # Would need explicit :ipAddress type