pub struct JsonPath(/* private fields */);Expand description
Type-safe JSON Path for addressing nodes in JSON structures
This is a pure domain object with no serialization concerns.
For serialization, use JsonPathDto from the application layer.
Implementations§
Source§impl JsonPath
impl JsonPath
Sourcepub fn new(path: impl Into<String>) -> Result<JsonPath, DomainError>
pub fn new(path: impl Into<String>) -> Result<JsonPath, DomainError>
Create new JSON path with validation
Sourcepub fn append_key(&self, key: &str) -> Result<JsonPath, DomainError>
pub fn append_key(&self, key: &str) -> Result<JsonPath, DomainError>
Append a key to the path
Sourcepub fn append_index(&self, index: usize) -> JsonPath
pub fn append_index(&self, index: usize) -> JsonPath
Append an array index to the path
Sourcepub fn last_segment(&self) -> Option<PathSegment>
pub fn last_segment(&self) -> Option<PathSegment>
Get the last segment of the path
Sourcepub fn is_prefix_of(&self, other: &JsonPath) -> bool
pub fn is_prefix_of(&self, other: &JsonPath) -> bool
Check if this path is a prefix of another path
Trait Implementations§
Source§impl From<JsonPath> for JsonPathDto
impl From<JsonPath> for JsonPathDto
Source§impl FromDto<JsonPathDto> for JsonPath
Utility trait implementation for JsonPath
impl FromDto<JsonPathDto> for JsonPath
Utility trait implementation for JsonPath
type Error = DomainError
fn from_dto(dto: JsonPathDto) -> Result<Self, Self::Error>
Source§impl ToDto<JsonPathDto> for JsonPath
Utility trait implementation for JsonPath
impl ToDto<JsonPathDto> for JsonPath
Utility trait implementation for JsonPath
fn to_dto(self) -> JsonPathDto
Source§impl TryFrom<JsonPathDto> for JsonPath
impl TryFrom<JsonPathDto> for JsonPath
Source§type Error = DomainError
type Error = DomainError
The type returned in the event of a conversion error.
impl Eq for JsonPath
impl StructuralPartialEq for JsonPath
Auto Trait Implementations§
impl Freeze for JsonPath
impl RefUnwindSafe for JsonPath
impl Send for JsonPath
impl Sync for JsonPath
impl Unpin for JsonPath
impl UnwindSafe for JsonPath
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more