Skip to content

Commit c0201c7

Browse files
authored
removes acidentally enabled default features miette and toml (#102)
1 parent 561224b commit c0201c7

File tree

6 files changed

+55
-19
lines changed

6 files changed

+55
-19
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [Unreleased]
8+
## [0.7.1] 2025-02-16
9+
10+
### Changed
11+
12+
- Removes accidentally enabled default features `"miette"` and `"toml"`
13+
14+
## [0.7.0] 2025-02-13
915

1016
### Added
1117

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: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ license = "MIT OR Apache-2.0"
1313
name = "jsonptr"
1414
repository = "https://github.com/chanced/jsonptr"
1515
rust-version = "1.79.0"
16-
version = "0.7.0"
16+
version = "0.7.1"
1717

1818
[dependencies]
1919
miette = { version = "7.4.0", optional = true, features = ["fancy"] }
@@ -31,20 +31,11 @@ quickcheck_macros = "1.0.0"
3131
syn = { version = "1.0.109", optional = true }
3232

3333
[features]
34-
assign = []
35-
default = [
36-
"std",
37-
"serde",
38-
"json",
39-
"toml", # TODO: remove
40-
"resolve",
41-
"assign",
42-
"delete",
43-
"miette", # TODO: remove
44-
]
45-
delete = ["resolve"]
46-
json = ["dep:serde_json", "serde"]
47-
miette = ["dep:miette", "std"]
34+
assign = []
35+
default = ["std", "serde", "json", "resolve", "assign", "delete"]
36+
delete = ["resolve"]
37+
json = ["dep:serde_json", "serde"]
38+
miette = ["dep:miette", "std"]
4839
resolve = []
49-
std = ["serde/std", "serde_json?/std"]
50-
toml = ["dep:toml", "serde", "std"]
40+
std = ["serde/std", "serde_json?/std"]
41+
toml = ["dep:toml", "serde", "std"]

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ flags](#feature-flags).
3535

3636
## Usage
3737

38+
### Parsing and General Usage
39+
3840
To parse a [`Pointer`] from a string, use either [`Pointer::parse`], for
3941
potentially fallible parsing, or the `const fn` `from_static` to produce a
4042
`&'static Pointer` from a string that is known to be valid.
@@ -46,6 +48,8 @@ let ptr = Pointer::parse("/examples/0/name").unwrap();
4648
let static_ptr = Pointer::from_static("/examples/0/name");
4749
assert_eq!(ptr, static_ptr);
4850

51+
assert_eq!(ptr.get(1..).unwrap(), Pointer::parse("/0/name").unwrap());
52+
4953
let parent = ptr.parent().unwrap();
5054
assert_eq!(parent, Pointer::parse("/examples/0").unwrap());
5155

@@ -70,6 +74,8 @@ buf.push_back("/");
7074
assert_eq!(buf.as_str(), "/~0/pointer/examples/0/name/~1");
7175
```
7276

77+
### Token Iteration
78+
7379
Iterating over the tokens or components of a pointer:
7480

7581
```rust
@@ -88,6 +94,8 @@ assert_eq!(components.next(), Some(Component::Token(Token::new("to"))));
8894
assert_eq!(components.next(), Some(Component::Token(Token::new("value"))));
8995
```
9096

97+
### Resolving Values
98+
9199
To get a value at the location of a pointer, use either the [`Resolve`] and
92100
[`ResolveMut`] traits or [`Pointer::resolve`] and [`Pointer::resolve_mut`]
93101
methods. See the [`resolve`] mod for more information.
@@ -102,6 +110,8 @@ let bar = ptr.resolve(&data).unwrap();
102110
assert_eq!(bar, &json!(34));
103111
```
104112

113+
### Assigning Values
114+
105115
Values can be set, with path expansion, using the either the [`Assign`] trait or
106116
[`Pointer::assign`]. See [`assign`] for more information.
107117

@@ -116,6 +126,8 @@ assert_eq!(replaced, Some(json!(42)));
116126
assert_eq!(data, json!({"secret": { "universe": 34 }}));
117127
```
118128

129+
### Deleting Values
130+
119131
Values can be removed with the either the [`Delete`] trait or
120132
[`Pointer::delete`]. See [`delete`] for more information.
121133

@@ -130,6 +142,30 @@ assert_eq!(replaced, Some(json!(42)));
130142
assert_eq!(data, json!({"secret": { "universe": 34 }}));
131143
```
132144

145+
### Error Reporting
146+
147+
Any error produced by function calls into methods of traits or types of this
148+
crate can be converted into a [`Report`] which contains the original error
149+
and the [`String`] which failed to parse or the [`PointerBuf`] which failed to
150+
resolve or assign.
151+
152+
```rust
153+
use jsonptr::{Pointer, Diagnose};
154+
let ptr_str = "foo/bar";
155+
let err /* Result<&Pointer, Report<ParseError>> */ = Pointer::parse(ptr_str).diagnose(ptr_str).unwrap_err();
156+
assert!(err.original().is_no_leading_slash());
157+
```
158+
159+
In the case of [`PointerBuf::parse`], the [`ParseError`] is always wrapped in a
160+
[`Report`] so that the input `String` is not dropped.
161+
162+
```rust
163+
use jsonptr::{PointerBuf};
164+
let ptr_str = "foo/bar";
165+
let err /* Result<&PointerBuf, Report<ParseError>> */ = PointerBuf::parse(ptr_str).unwrap_err();
166+
assert!(err.original().is_no_leading_slash());
167+
```
168+
133169
## Feature Flags
134170

135171
| Flag | Description | Enables | Default |
@@ -141,6 +177,7 @@ assert_eq!(data, json!({"secret": { "universe": 34 }}));
141177
| `"assign"` | Enables the [`assign`] module and related pointer methods, providing a means to assign a value to a specific location within a document | ||
142178
| `"resolve"` | Enables the [`resolve`] module and related pointer methods, providing a means to resolve a value at a specific location within a document | ||
143179
| `"delete"` | Enables the [`delete`] module and related pointer methods, providing a means to delete a value at a specific location within a document | `"resolve"` ||
180+
| `"miette"` | Enables integration with [`miette`](https://docs.rs/miette) for error reporting | `"std"` | |
144181

145182
<div class="rustdoc-hidden">
146183

src/diagnostic.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ mod tests {
265265
}
266266

267267
#[test]
268+
#[cfg(feature = "miette")]
268269
fn parse_error() {
269270
let invalid = "/foo/bar/invalid~3~encoding/cannot/reach";
270271
let report = Pointer::parse(invalid).diagnose(invalid).unwrap_err();

src/pointer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2345,6 +2345,7 @@ mod tests {
23452345
}
23462346

23472347
#[test]
2348+
#[cfg(feature = "miette")]
23482349
fn quick_miette_spike() {
23492350
let err = PointerBuf::parse("hello-world").unwrap_err();
23502351
println!("{:?}", miette::Report::from(err));

0 commit comments

Comments
 (0)