pub enum PathElement<'a> {
Key(&'a str),
Index(usize),
IndexFromEnd(usize),
}Expand description
A path element for navigating into nested data structures.
Used with LookupResult::decode_path() to selectively decode
specific fields without parsing the entire record.
§Creating Path Elements
You can create path elements directly or use the path! macro
for a more convenient syntax:
use maxminddb::{path, PathElement};
// Direct construction
let path = [PathElement::Key("country"), PathElement::Key("iso_code")];
// Using the macro - string literals become Keys, integers become Indexes
let path = path!["country", "iso_code"];
let path = path!["subdivisions", 0, "names"]; // Mixed keys and indexes
let path = path!["array", -1]; // Negative indexes count from the endVariants§
Key(&'a str)
Navigate into a map by key.
Index(usize)
Navigate into an array by index (0-based from the start).
Index(0)- first elementIndex(1)- second element
IndexFromEnd(usize)
Navigate into an array by index from the end.
IndexFromEnd(0)- last elementIndexFromEnd(1)- second-to-last element
Trait Implementations§
Source§impl<'a> Clone for PathElement<'a>
impl<'a> Clone for PathElement<'a>
Source§fn clone(&self) -> PathElement<'a>
fn clone(&self) -> PathElement<'a>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'a> Debug for PathElement<'a>
impl<'a> Debug for PathElement<'a>
Source§impl<'a> From<&'a str> for PathElement<'a>
impl<'a> From<&'a str> for PathElement<'a>
Source§impl From<i32> for PathElement<'_>
impl From<i32> for PathElement<'_>
Source§impl From<isize> for PathElement<'_>
impl From<isize> for PathElement<'_>
Source§impl From<usize> for PathElement<'_>
impl From<usize> for PathElement<'_>
Source§impl<'a> PartialEq for PathElement<'a>
impl<'a> PartialEq for PathElement<'a>
impl<'a> Eq for PathElement<'a>
impl<'a> StructuralPartialEq for PathElement<'a>
Auto Trait Implementations§
impl<'a> Freeze for PathElement<'a>
impl<'a> RefUnwindSafe for PathElement<'a>
impl<'a> Send for PathElement<'a>
impl<'a> Sync for PathElement<'a>
impl<'a> Unpin for PathElement<'a>
impl<'a> UnwindSafe for PathElement<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more