Skip to main content

parse_memory_range

Function parse_memory_range 

Source
pub fn parse_memory_range(range: &str) -> Result<(u16, u16), String>
Expand description

Parse a memory range string in format START-END or START:LENGTH.

Both START and END/LENGTH should be hexadecimal values (with or without 0x prefix).

§Errors

Returns an error if:

  • The format is invalid (not START-END or START:LENGTH)
  • The hex values cannot be parsed
  • The resulting range would be invalid (end < start)

§Examples

use monsoon_cli::cli::parse_memory_range;

assert_eq!(
    parse_memory_range("0x0000-0x07FF").unwrap(),
    (0x0000, 0x07FF)
);
assert_eq!(parse_memory_range("6000:100").unwrap(), (0x6000, 0x60FF));