pub struct AddressCanonicalizer {
default_space: String,
pointer_size: u8,
}Expand description
Parses lenient address forms and renders the strict-total canonical form.
Fields§
§default_space: String§pointer_size: u8Pointer size in bytes; offsets zero-pad to pointer_size * 2 hex digits.
Implementations§
Source§impl AddressCanonicalizer
impl AddressCanonicalizer
pub fn new(default_space: impl Into<String>, pointer_size: u8) -> Self
Sourcepub fn parse_str(&self, input: &str) -> Result<Address, AddressParseError>
pub fn parse_str(&self, input: &str) -> Result<Address, AddressParseError>
Parse a lenient string: 0x401230, 0X401230, bare hex 401230, or
space:offset; trailing L/l and surrounding whitespace tolerated.
Bare and 0x-prefixed offsets are HEX (Ghidra convention).
Sourcepub fn from_u64(&self, offset: u64) -> Address
pub fn from_u64(&self, offset: u64) -> Address
Build an address from a raw integer offset in the default space. This is
the JSON-integer input form; the MCP boundary dispatches a JSON number to
here and a JSON string to parse_str.
Sourcepub fn render(&self, addr: &Address) -> String
pub fn render(&self, addr: &Address) -> String
Render an address to its strict-total canonical string.
The zero-pad below is a MIN width, not a cap: an offset wider than the
space’s nominal pointer width (Ghidra never emits one) still renders in
full. This is deliberate — render must stay TOTAL over the whole u64
offset space per spec §13 (see the prop_totality_all_lenient_forms_agree
proptest). Hence no width assertion here: a total function must not panic
on a valid input, even in debug builds (M0-review finding #2, doc-note form).
Sourcepub fn canonicalize(&self, input: &str) -> Result<String, AddressParseError>
pub fn canonicalize(&self, input: &str) -> Result<String, AddressParseError>
Convenience: parse a lenient string and render the canonical form.
Trait Implementations§
Source§impl Clone for AddressCanonicalizer
impl Clone for AddressCanonicalizer
Source§fn clone(&self) -> AddressCanonicalizer
fn clone(&self) -> AddressCanonicalizer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more