pub struct JsonPath(/* private fields */);
Expand description
Type-safe JSON Path for addressing nodes in JSON structures
This is a pure domain object. Serialization should be handled in the application layer via DTOs, but serde is temporarily kept for compatibility with existing code.
TODO: Remove Serialize, Deserialize derives once all serialization uses DTOs
Implementations§
Source§impl JsonPath
impl JsonPath
Sourcepub fn new(path: impl Into<String>) -> DomainResult<Self>
pub fn new(path: impl Into<String>) -> DomainResult<Self>
Create new JSON path with validation
Sourcepub fn append_key(&self, key: &str) -> DomainResult<Self>
pub fn append_key(&self, key: &str) -> DomainResult<Self>
Append a key to the path
Sourcepub fn append_index(&self, index: usize) -> Self
pub fn append_index(&self, index: usize) -> Self
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<'de> Deserialize<'de> for JsonPath
impl<'de> Deserialize<'de> for JsonPath
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.