Crate iso8583_parser
source ·Expand description
§String Manipulation Module
This module provides utilities for string manipulation.
§Examples
use iso8583_parser::{StringManipulation, Mode};
let mut s = String::from("48656C6C6F2C576F726C64"); // "Hello, World" in hex
// Convert hex to ASCII
let ascii_result = s.hex_to_ascii();
assert_eq!(ascii_result.unwrap(), "Hello,World");
// Get a slice of the string until a specified length
let slice = s.get_slice_until(5);
assert_eq!(slice, "48656");
// Get another slice of the string until a specified length
let slice = s.get_slice_until(5);
assert_eq!(slice, "C6C6F");
let mode_instance = Mode { enabled_private_tlv: false, enabled_private_ltv: false };
// Process a field based on field number, length, and name
s.process_field(1, 12, "test", &mode_instance);
use iso8583_parser::positions_of_set_bits;
let bitmap: Vec<u32> = positions_of_set_bits(u64::from_str_radix("3038058020C19201", 16).unwrap());
assert_eq!(bitmap, vec![3, 4, 11, 12, 13, 22, 24, 25, 35, 41, 42, 48, 49, 52, 55, 64]);
let mut s = String::from("1101303830303539313535301002322E362E31352E3332020330022231021532"); // LTV format in hex
// Parse LTV (Length, Tag, Value) format
let ltvs = s.parse_private_ltv().unwrap();
for ltv in ltvs {
println!("{}", ltv);
}
Structs§
Traits§
- Trait for string manipulation operations.
Functions§
- Returns the positions of set bits in a binary number.