Skip to content

Commit

Permalink
Merge pull request #83 from sammhicks/master
Browse files Browse the repository at this point in the history
De-Escaping strings using a provided buffer
  • Loading branch information
ryan-summers authored Aug 6, 2024
2 parents f54d47f + 9f6af47 commit 534a12a
Show file tree
Hide file tree
Showing 11 changed files with 605 additions and 90 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

include:
# Test MSRV
- rust: 1.62.0 # keep in sync with manifest rust-version
- rust: 1.65.0 # keep in sync with manifest rust-version
TARGET: x86_64-unknown-linux-gnu

# Test nightly but don't fail
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Breaking
- MSRV is now `1.65.0`.

### Added

- Support for optional package `defmt` which allows for easy conversion for
error types when using tools like `probe-rs` for logging over debuggers.
- Implement `Serializer::collect_str`
- Derive `Serialize` for `de::Error` and `ser::Error`
- Support for deserializing escaped strings.

### Changed

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ categories = ["no-std"]
description = "serde-json for no_std programs"
documentation = "https://docs.rs/serde-json-core"
edition = "2018"
rust-version = "1.62.0" # keep in sync with ci, src/lib.rs, and README
rust-version = "1.65.0" # keep in sync with ci, src/lib.rs, and README
keywords = ["serde", "json"]
license = "MIT OR Apache-2.0"
name = "serde-json-core"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This project is developed and maintained by the [rust-embedded-community].

## Minimum Supported Rust Version (MSRV)

This crate is guaranteed to compile on stable Rust 1.62.0 and up. It *might*
This crate is guaranteed to compile on stable Rust 1.65.0 and up. It *might*
compile with older versions but that may change in any new patch release.

## License
Expand Down
24 changes: 12 additions & 12 deletions src/de/enum_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ use serde::de;

use crate::de::{Deserializer, Error, Result};

pub(crate) struct UnitVariantAccess<'a, 'b> {
de: &'a mut Deserializer<'b>,
pub(crate) struct UnitVariantAccess<'a, 'b, 's> {
de: &'a mut Deserializer<'b, 's>,
}

impl<'a, 'b> UnitVariantAccess<'a, 'b> {
pub(crate) fn new(de: &'a mut Deserializer<'b>) -> Self {
impl<'a, 'b, 's> UnitVariantAccess<'a, 'b, 's> {
pub(crate) fn new(de: &'a mut Deserializer<'b, 's>) -> Self {
UnitVariantAccess { de }
}
}

impl<'a, 'de> de::EnumAccess<'de> for UnitVariantAccess<'a, 'de> {
impl<'a, 'de, 's> de::EnumAccess<'de> for UnitVariantAccess<'a, 'de, 's> {
type Error = Error;
type Variant = Self;

Expand All @@ -25,7 +25,7 @@ impl<'a, 'de> de::EnumAccess<'de> for UnitVariantAccess<'a, 'de> {
}
}

impl<'de, 'a> de::VariantAccess<'de> for UnitVariantAccess<'a, 'de> {
impl<'de, 'a, 's> de::VariantAccess<'de> for UnitVariantAccess<'a, 'de, 's> {
type Error = Error;

fn unit_variant(self) -> Result<()> {
Expand Down Expand Up @@ -54,17 +54,17 @@ impl<'de, 'a> de::VariantAccess<'de> for UnitVariantAccess<'a, 'de> {
}
}

pub(crate) struct VariantAccess<'a, 'b> {
de: &'a mut Deserializer<'b>,
pub(crate) struct VariantAccess<'a, 'b, 's> {
de: &'a mut Deserializer<'b, 's>,
}

impl<'a, 'b> VariantAccess<'a, 'b> {
pub(crate) fn new(de: &'a mut Deserializer<'b>) -> Self {
impl<'a, 'b, 's> VariantAccess<'a, 'b, 's> {
pub(crate) fn new(de: &'a mut Deserializer<'b, 's>) -> Self {
VariantAccess { de }
}
}

impl<'a, 'de> de::EnumAccess<'de> for VariantAccess<'a, 'de> {
impl<'a, 'de, 's> de::EnumAccess<'de> for VariantAccess<'a, 'de, 's> {
type Error = Error;
type Variant = Self;

Expand All @@ -78,7 +78,7 @@ impl<'a, 'de> de::EnumAccess<'de> for VariantAccess<'a, 'de> {
}
}

impl<'de, 'a> de::VariantAccess<'de> for VariantAccess<'a, 'de> {
impl<'de, 'a, 's> de::VariantAccess<'de> for VariantAccess<'a, 'de, 's> {
type Error = Error;

fn unit_variant(self) -> Result<()> {
Expand Down
16 changes: 8 additions & 8 deletions src/de/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ use serde::de::{self, Visitor};

use crate::de::{Deserializer, Error};

pub struct MapAccess<'a, 'b> {
de: &'a mut Deserializer<'b>,
pub struct MapAccess<'a, 'b, 's> {
de: &'a mut Deserializer<'b, 's>,
first: bool,
}

impl<'a, 'b> MapAccess<'a, 'b> {
pub(crate) fn new(de: &'a mut Deserializer<'b>) -> Self {
impl<'a, 'b, 's> MapAccess<'a, 'b, 's> {
pub(crate) fn new(de: &'a mut Deserializer<'b, 's>) -> Self {
MapAccess { de, first: true }
}
}

impl<'a, 'de> de::MapAccess<'de> for MapAccess<'a, 'de> {
impl<'a, 'de, 's> de::MapAccess<'de> for MapAccess<'a, 'de, 's> {
type Error = Error;

fn next_key_seed<K>(&mut self, seed: K) -> Result<Option<K::Value>, Error>
Expand Down Expand Up @@ -57,11 +57,11 @@ impl<'a, 'de> de::MapAccess<'de> for MapAccess<'a, 'de> {
}
}

struct MapKey<'a, 'b> {
de: &'a mut Deserializer<'b>,
struct MapKey<'a, 'b, 's> {
de: &'a mut Deserializer<'b, 's>,
}

impl<'de, 'a> de::Deserializer<'de> for MapKey<'a, 'de> {
impl<'de, 'a, 's> de::Deserializer<'de> for MapKey<'a, 'de, 's> {
type Error = Error;

fn deserialize_any<V>(self, _visitor: V) -> Result<V::Value, Error>
Expand Down
Loading

0 comments on commit 534a12a

Please sign in to comment.