async_snmp/format/mod.rs
1//! Formatting utilities for SNMP values.
2//!
3//! This module provides formatting functions for converting raw SNMP data
4//! into human-readable strings.
5//!
6//! ## Display Hints
7//!
8//! The [`display_hint`] module implements RFC 2579 DISPLAY-HINT formatting
9//! for OCTET STRING values. This is commonly used to format MAC addresses,
10//! IP addresses, and other structured binary data.
11//!
12//! ```
13//! use async_snmp::format::display_hint;
14//!
15//! // Format a MAC address
16//! let mac = display_hint::apply("1x:", &[0x00, 0x1a, 0x2b, 0x3c, 0x4d, 0x5e]);
17//! assert_eq!(mac, "00:1a:2b:3c:4d:5e");
18//!
19//! // Format an IPv4 address
20//! let ip = display_hint::apply("1d.1d.1d.1d", &[192, 168, 1, 1]);
21//! assert_eq!(ip, "192.168.1.1");
22//! ```
23//!
24//! ## Hex Encoding
25//!
26//! The [`hex`] module provides hexadecimal encoding and decoding utilities.
27//!
28//! ```
29//! use async_snmp::format::hex;
30//!
31//! // Encode bytes to hex string
32//! assert_eq!(hex::encode(&[0xde, 0xad, 0xbe, 0xef]), "deadbeef");
33//!
34//! // Lazy formatting for logging
35//! let data = [0x00, 0xff];
36//! println!("{}", hex::Bytes(&data)); // prints: 00ff
37//! ```
38
39pub mod display_hint;
40pub mod hex;
41pub mod hints;