SnmpKit.MIB.DisplayHint (snmpkit v2.0.1)

Interprets SMIv2 DISPLAY-HINT strings (RFC 2579 section 3.1) for OCTET STRING and INTEGER values.

iex> SnmpKit.MIB.DisplayHint.format("1x:", <<0, 26, 43, 60, 77, 94>>)
"00:1a:2b:3c:4d:5e"

iex> SnmpKit.MIB.DisplayHint.format("2d-1d-1d,1d:1d:1d.1d,1a1d:1d", <<7, 232, 3, 5, 10, 3, 7, 0, ?+, 0, 0>>)
"2024-3-5,10:3:7.0,+0:0"

iex> SnmpKit.MIB.DisplayHint.format("d-2", 1234)
"12.34"

iex> SnmpKit.MIB.DisplayHint.format("255a", "hello")
"hello"

Summary

Functions

Formats value according to hint. Returns {:ok, string} or {:error, reason} when the hint does not parse or does not apply to the value; format/2 returns the string or nil.

Like apply/2 but returns the string or nil.

Types

hint()

@type hint() :: String.t()

Functions

apply(hint, value)

@spec apply(hint(), binary() | integer()) :: {:ok, String.t()} | {:error, term()}

Formats value according to hint. Returns {:ok, string} or {:error, reason} when the hint does not parse or does not apply to the value; format/2 returns the string or nil.

format(hint, value)

@spec format(hint(), binary() | integer()) :: String.t() | nil

Like apply/2 but returns the string or nil.