pub struct JsonPointer { /* private fields */ }Expand description
A JSON Pointer (RFC 6901): identifies a value within a JSON document.
Stored as decoded segments; the pointer string is produced by encoding when needed. Root has zero segments.
Implementations§
Source§impl JsonPointer
impl JsonPointer
Sourcepub fn push(&self, segment: &str) -> Self
pub fn push(&self, segment: &str) -> Self
Returns a new pointer with one more segment. The segment is stored decoded; encoding is applied when producing the pointer string.
Sourcepub fn truncate(&self, len: usize) -> Self
pub fn truncate(&self, len: usize) -> Self
Returns a new pointer with only the first len segments.
Sourcepub fn segments(&self) -> impl Iterator<Item = &str>
pub fn segments(&self) -> impl Iterator<Item = &str>
Returns an iterator over the decoded segments.
Sourcepub fn segment_at(&self, index: usize) -> Option<&str>
pub fn segment_at(&self, index: usize) -> Option<&str>
Returns the segment at index, or None if out of bounds.
Sourcepub fn remove(&self, index: usize) -> Self
pub fn remove(&self, index: usize) -> Self
Returns a new pointer with the segment at index removed.
Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Returns the pointer as a string (“” for root, “/a/b” for children).
Sourcepub fn display_root_or_path(&self) -> &str
pub fn display_root_or_path(&self) -> &str
Returns a display-friendly location: “root” when empty, otherwise the pointer string.
Trait Implementations§
Source§impl Clone for JsonPointer
impl Clone for JsonPointer
Source§fn clone(&self) -> JsonPointer
fn clone(&self) -> JsonPointer
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 Debug for JsonPointer
impl Debug for JsonPointer
Source§impl Display for JsonPointer
impl Display for JsonPointer
Source§impl From<JsonPointer> for String
impl From<JsonPointer> for String
Source§fn from(p: JsonPointer) -> Self
fn from(p: JsonPointer) -> Self
Converts to this type from the input type.
Source§impl PartialEq for JsonPointer
impl PartialEq for JsonPointer
Source§impl TryFrom<&[u8]> for JsonPointer
impl TryFrom<&[u8]> for JsonPointer
Source§impl TryFrom<&str> for JsonPointer
impl TryFrom<&str> for JsonPointer
Source§impl TryFrom<String> for JsonPointer
impl TryFrom<String> for JsonPointer
impl Eq for JsonPointer
impl StructuralPartialEq for JsonPointer
Auto Trait Implementations§
impl Freeze for JsonPointer
impl RefUnwindSafe for JsonPointer
impl Send for JsonPointer
impl Sync for JsonPointer
impl Unpin for JsonPointer
impl UnsafeUnpin for JsonPointer
impl UnwindSafe for JsonPointer
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