Skip to content

Commit 7d09f28

Browse files
committed
adds a bit more documentation
1 parent 85e4785 commit 7d09f28

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "jsonptr"
3-
version = "0.0.6"
3+
version = "0.0.7"
44
edition = "2021"
55
description = "Data structures and logic for resolving, assigning, and deleting by JSON Pointers (RFC 6901)"
66
documentation = "https://docs.rs/jsonptr"

src/error.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ impl Display for UnresolvableError {
124124
)
125125
}
126126
}
127+
128+
/// Indicates an error occurred while parsing a `usize` (`ParseError`) or the
129+
/// parsed value was out of bounds for the targeted array.
127130
#[derive(PartialEq, Eq)]
128131
pub enum IndexError {
129132
Parse(ParseError),
@@ -150,6 +153,7 @@ impl From<OutOfBoundsError> for IndexError {
150153
}
151154
}
152155

156+
/// ParseError represents an that an error occurred when parsing an index.
153157
#[derive(PartialEq, Eq)]
154158
pub struct ParseError {
155159
pub source: ParseIntError,

src/resolve.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
use crate::{Error, Pointer};
22
use serde_json::Value;
3-
/// Resolve is implemented by types
3+
/// Resolve is implemented by types which can resolve a reference to a
4+
/// `serde_json::Value` from the path in a JSON Pointer.
45
pub trait Resolve {
56
type Error: std::error::Error + Send + Sync + 'static;
7+
/// Resolve a reference to a `serde_json::Value` based on the path in a JSON
8+
/// Pointer.
69
fn resolve(&self, ptr: &Pointer) -> Result<&Value, Error>;
710
}
811
impl Resolve for Value {
912
type Error = Error;
10-
/// Resolve a value based on the path provided by a JSON Pointer.
1113
fn resolve(&self, ptr: &Pointer) -> Result<&Value, Self::Error> {
1214
ptr.resolve(self)
1315
}
1416
}
1517

18+
/// ResolveMut is implemented by types which can resolve a mutable reference to
19+
/// a `serde_json::Value` from the path in a JSON Pointer.
1620
pub trait ResolveMut {
21+
/// Resolve a mutable reference to a `serde_json::Value` based on the path
22+
/// in a JSON Pointer.
1723
fn resolve_mut(&mut self, ptr: &Pointer) -> Result<&mut Value, Error>;
1824
}
1925
impl ResolveMut for Value {
20-
/// Resolve a mutable value based on the path provided by a JSON Pointer.
2126
fn resolve_mut(&mut self, ptr: &Pointer) -> Result<&mut Value, Error> {
2227
ptr.resolve_mut(self)
2328
}

0 commit comments

Comments
 (0)