Showing preview only (1,399K chars total). Download the full file or copy to clipboard to get everything.
Repository: serde-rs/serde
Branch: master
Commit: fa7da4a93567
Files: 347
Total size: 1.3 MB
Directory structure:
gitextract_h3ikti25/
├── .github/
│ ├── FUNDING.yml
│ ├── ISSUE_TEMPLATE/
│ │ ├── 1-problem.md
│ │ ├── 2-suggestion.md
│ │ ├── 3-documentation.md
│ │ └── 4-other.md
│ └── workflows/
│ └── ci.yml
├── .gitignore
├── CONTRIBUTING.md
├── Cargo.toml
├── LICENSE-APACHE
├── LICENSE-MIT
├── README.md
├── crates-io.md
├── serde/
│ ├── Cargo.toml
│ ├── build.rs
│ └── src/
│ ├── integer128.rs
│ ├── lib.rs
│ └── private/
│ ├── de.rs
│ ├── mod.rs
│ └── ser.rs
├── serde_core/
│ ├── Cargo.toml
│ ├── README.md
│ ├── build.rs
│ └── src/
│ ├── crate_root.rs
│ ├── de/
│ │ ├── ignored_any.rs
│ │ ├── impls.rs
│ │ ├── mod.rs
│ │ └── value.rs
│ ├── format.rs
│ ├── lib.rs
│ ├── macros.rs
│ ├── private/
│ │ ├── content.rs
│ │ ├── doc.rs
│ │ ├── mod.rs
│ │ ├── seed.rs
│ │ ├── size_hint.rs
│ │ └── string.rs
│ ├── ser/
│ │ ├── fmt.rs
│ │ ├── impls.rs
│ │ ├── impossible.rs
│ │ └── mod.rs
│ └── std_error.rs
├── serde_derive/
│ ├── Cargo.toml
│ ├── build.rs
│ └── src/
│ ├── bound.rs
│ ├── de/
│ │ ├── enum_.rs
│ │ ├── enum_adjacently.rs
│ │ ├── enum_externally.rs
│ │ ├── enum_internally.rs
│ │ ├── enum_untagged.rs
│ │ ├── identifier.rs
│ │ ├── struct_.rs
│ │ ├── tuple.rs
│ │ └── unit.rs
│ ├── de.rs
│ ├── deprecated.rs
│ ├── dummy.rs
│ ├── fragment.rs
│ ├── internals/
│ │ ├── ast.rs
│ │ ├── attr.rs
│ │ ├── case.rs
│ │ ├── check.rs
│ │ ├── ctxt.rs
│ │ ├── mod.rs
│ │ ├── name.rs
│ │ ├── receiver.rs
│ │ ├── respan.rs
│ │ └── symbol.rs
│ ├── lib.rs
│ ├── pretend.rs
│ ├── ser.rs
│ └── this.rs
├── serde_derive_internals/
│ ├── Cargo.toml
│ ├── build.rs
│ └── lib.rs
└── test_suite/
├── Cargo.toml
├── no_std/
│ ├── .gitignore
│ ├── Cargo.toml
│ └── src/
│ └── main.rs
└── tests/
├── bytes/
│ └── mod.rs
├── compiletest.rs
├── macros/
│ └── mod.rs
├── regression/
│ ├── issue1904.rs
│ ├── issue2371.rs
│ ├── issue2409.rs
│ ├── issue2415.rs
│ ├── issue2565.rs
│ ├── issue2792.rs
│ ├── issue2844.rs
│ └── issue2846.rs
├── regression.rs
├── test_annotations.rs
├── test_borrow.rs
├── test_de.rs
├── test_de_error.rs
├── test_deprecated.rs
├── test_enum_adjacently_tagged.rs
├── test_enum_internally_tagged.rs
├── test_enum_untagged.rs
├── test_gen.rs
├── test_identifier.rs
├── test_ignored_any.rs
├── test_macros.rs
├── test_remote.rs
├── test_roundtrip.rs
├── test_self.rs
├── test_ser.rs
├── test_serde_path.rs
├── test_unstable.rs
├── test_value.rs
├── ui/
│ ├── borrow/
│ │ ├── bad_lifetimes.rs
│ │ ├── bad_lifetimes.stderr
│ │ ├── duplicate_lifetime.rs
│ │ ├── duplicate_lifetime.stderr
│ │ ├── duplicate_variant.rs
│ │ ├── duplicate_variant.stderr
│ │ ├── empty_lifetimes.rs
│ │ ├── empty_lifetimes.stderr
│ │ ├── no_lifetimes.rs
│ │ ├── no_lifetimes.stderr
│ │ ├── struct_variant.rs
│ │ ├── struct_variant.stderr
│ │ ├── wrong_lifetime.rs
│ │ └── wrong_lifetime.stderr
│ ├── conflict/
│ │ ├── adjacent-tag.rs
│ │ ├── adjacent-tag.stderr
│ │ ├── alias-enum.rs
│ │ ├── alias-enum.stderr
│ │ ├── alias.rs
│ │ ├── alias.stderr
│ │ ├── flatten-newtype-struct.rs
│ │ ├── flatten-newtype-struct.stderr
│ │ ├── flatten-tuple-struct.rs
│ │ ├── flatten-tuple-struct.stderr
│ │ ├── from-try-from.rs
│ │ ├── from-try-from.stderr
│ │ ├── internal-tag-alias.rs
│ │ ├── internal-tag-alias.stderr
│ │ ├── internal-tag.rs
│ │ └── internal-tag.stderr
│ ├── default-attribute/
│ │ ├── enum.rs
│ │ ├── enum.stderr
│ │ ├── enum_path.rs
│ │ ├── enum_path.stderr
│ │ ├── incorrect_type_enum_adjacently_tagged.rs
│ │ ├── incorrect_type_enum_adjacently_tagged.stderr
│ │ ├── incorrect_type_enum_externally_tagged.rs
│ │ ├── incorrect_type_enum_externally_tagged.stderr
│ │ ├── incorrect_type_enum_internally_tagged.rs
│ │ ├── incorrect_type_enum_internally_tagged.stderr
│ │ ├── incorrect_type_enum_untagged.rs
│ │ ├── incorrect_type_enum_untagged.stderr
│ │ ├── incorrect_type_newtype.rs
│ │ ├── incorrect_type_newtype.stderr
│ │ ├── incorrect_type_struct.rs
│ │ ├── incorrect_type_struct.stderr
│ │ ├── incorrect_type_tuple.rs
│ │ ├── incorrect_type_tuple.stderr
│ │ ├── tuple_struct.rs
│ │ ├── tuple_struct.stderr
│ │ ├── tuple_struct_path.rs
│ │ ├── tuple_struct_path.stderr
│ │ ├── union.rs
│ │ ├── union.stderr
│ │ ├── union_path.rs
│ │ ├── union_path.stderr
│ │ ├── unit.rs
│ │ ├── unit.stderr
│ │ ├── unit_path.rs
│ │ └── unit_path.stderr
│ ├── deprecated/
│ │ ├── deprecated_de_with.rs
│ │ ├── deprecated_de_with.stderr
│ │ ├── deprecated_ser_with.rs
│ │ └── deprecated_ser_with.stderr
│ ├── duplicate-attribute/
│ │ ├── rename-and-ser.rs
│ │ ├── rename-and-ser.stderr
│ │ ├── rename-ser-rename-ser.rs
│ │ ├── rename-ser-rename-ser.stderr
│ │ ├── rename-ser-rename.rs
│ │ ├── rename-ser-rename.stderr
│ │ ├── rename-ser-ser.rs
│ │ ├── rename-ser-ser.stderr
│ │ ├── two-rename-ser.rs
│ │ ├── two-rename-ser.stderr
│ │ ├── with-and-serialize-with.rs
│ │ └── with-and-serialize-with.stderr
│ ├── enum-representation/
│ │ ├── content-no-tag.rs
│ │ ├── content-no-tag.stderr
│ │ ├── internal-tuple-variant.rs
│ │ ├── internal-tuple-variant.stderr
│ │ ├── partially_tagged_wrong_order.rs
│ │ ├── partially_tagged_wrong_order.stderr
│ │ ├── untagged-and-adjacent.rs
│ │ ├── untagged-and-adjacent.stderr
│ │ ├── untagged-and-content.rs
│ │ ├── untagged-and-content.stderr
│ │ ├── untagged-and-internal.rs
│ │ ├── untagged-and-internal.stderr
│ │ ├── untagged-struct.rs
│ │ └── untagged-struct.stderr
│ ├── expected-string/
│ │ ├── boolean.rs
│ │ ├── boolean.stderr
│ │ ├── byte_character.rs
│ │ ├── byte_character.stderr
│ │ ├── byte_string.rs
│ │ ├── byte_string.stderr
│ │ ├── character.rs
│ │ ├── character.stderr
│ │ ├── float.rs
│ │ ├── float.stderr
│ │ ├── integer.rs
│ │ └── integer.stderr
│ ├── identifier/
│ │ ├── both.rs
│ │ ├── both.stderr
│ │ ├── field_struct.rs
│ │ ├── field_struct.stderr
│ │ ├── field_tuple.rs
│ │ ├── field_tuple.stderr
│ │ ├── newtype_not_last.rs
│ │ ├── newtype_not_last.stderr
│ │ ├── not_unit.rs
│ │ ├── not_unit.stderr
│ │ ├── other_not_last.rs
│ │ ├── other_not_last.stderr
│ │ ├── other_untagged.rs
│ │ ├── other_untagged.stderr
│ │ ├── other_variant.rs
│ │ ├── other_variant.stderr
│ │ ├── variant_struct.rs
│ │ ├── variant_struct.stderr
│ │ ├── variant_tuple.rs
│ │ └── variant_tuple.stderr
│ ├── malformed/
│ │ ├── bound.rs
│ │ ├── bound.stderr
│ │ ├── cut_off.rs
│ │ ├── cut_off.stderr
│ │ ├── not_list.rs
│ │ ├── not_list.stderr
│ │ ├── rename.rs
│ │ ├── rename.stderr
│ │ ├── str_suffix.rs
│ │ ├── str_suffix.stderr
│ │ ├── trailing_expr.rs
│ │ └── trailing_expr.stderr
│ ├── precondition/
│ │ ├── deserialize_de_lifetime.rs
│ │ ├── deserialize_de_lifetime.stderr
│ │ ├── deserialize_dst.rs
│ │ ├── deserialize_dst.stderr
│ │ ├── serialize_field_identifier.rs
│ │ ├── serialize_field_identifier.stderr
│ │ ├── serialize_variant_identifier.rs
│ │ └── serialize_variant_identifier.stderr
│ ├── remote/
│ │ ├── bad_getter.rs
│ │ ├── bad_getter.stderr
│ │ ├── bad_remote.rs
│ │ ├── bad_remote.stderr
│ │ ├── double_generic.rs
│ │ ├── double_generic.stderr
│ │ ├── enum_getter.rs
│ │ ├── enum_getter.stderr
│ │ ├── missing_field.rs
│ │ ├── missing_field.stderr
│ │ ├── nonremote_getter.rs
│ │ ├── nonremote_getter.stderr
│ │ ├── unknown_field.rs
│ │ ├── unknown_field.stderr
│ │ ├── wrong_de.rs
│ │ ├── wrong_de.stderr
│ │ ├── wrong_getter.rs
│ │ ├── wrong_getter.stderr
│ │ ├── wrong_ser.rs
│ │ └── wrong_ser.stderr
│ ├── rename/
│ │ ├── container_unknown_rename_rule.rs
│ │ ├── container_unknown_rename_rule.stderr
│ │ ├── variant_unknown_rename_rule.rs
│ │ └── variant_unknown_rename_rule.stderr
│ ├── struct-representation/
│ │ ├── internally-tagged-tuple.rs
│ │ ├── internally-tagged-tuple.stderr
│ │ ├── internally-tagged-unit.rs
│ │ └── internally-tagged-unit.stderr
│ ├── transparent/
│ │ ├── at_most_one.rs
│ │ ├── at_most_one.stderr
│ │ ├── de_at_least_one.rs
│ │ ├── de_at_least_one.stderr
│ │ ├── enum.rs
│ │ ├── enum.stderr
│ │ ├── ser_at_least_one.rs
│ │ ├── ser_at_least_one.stderr
│ │ ├── unit_struct.rs
│ │ ├── unit_struct.stderr
│ │ ├── with_from.rs
│ │ ├── with_from.stderr
│ │ ├── with_into.rs
│ │ ├── with_into.stderr
│ │ ├── with_try_from.rs
│ │ └── with_try_from.stderr
│ ├── type-attribute/
│ │ ├── from.rs
│ │ ├── from.stderr
│ │ ├── into.rs
│ │ ├── into.stderr
│ │ ├── try_from.rs
│ │ └── try_from.stderr
│ ├── unexpected-literal/
│ │ ├── container.rs
│ │ ├── container.stderr
│ │ ├── field.rs
│ │ ├── field.stderr
│ │ ├── variant.rs
│ │ └── variant.stderr
│ ├── unimplemented/
│ │ ├── required_by_dependency.rs
│ │ ├── required_by_dependency.stderr
│ │ ├── required_locally.rs
│ │ └── required_locally.stderr
│ ├── unknown-attribute/
│ │ ├── container.rs
│ │ ├── container.stderr
│ │ ├── field.rs
│ │ ├── field.stderr
│ │ ├── variant.rs
│ │ └── variant.stderr
│ ├── unsupported/
│ │ ├── union_de.rs
│ │ ├── union_de.stderr
│ │ ├── union_ser.rs
│ │ └── union_ser.stderr
│ ├── with/
│ │ ├── incorrect_type.rs
│ │ └── incorrect_type.stderr
│ └── with-variant/
│ ├── skip_de_newtype_field.rs
│ ├── skip_de_newtype_field.stderr
│ ├── skip_de_struct_field.rs
│ ├── skip_de_struct_field.stderr
│ ├── skip_de_tuple_field.rs
│ ├── skip_de_tuple_field.stderr
│ ├── skip_de_whole_variant.rs
│ ├── skip_de_whole_variant.stderr
│ ├── skip_ser_newtype_field.rs
│ ├── skip_ser_newtype_field.stderr
│ ├── skip_ser_newtype_field_if.rs
│ ├── skip_ser_newtype_field_if.stderr
│ ├── skip_ser_struct_field.rs
│ ├── skip_ser_struct_field.stderr
│ ├── skip_ser_struct_field_if.rs
│ ├── skip_ser_struct_field_if.stderr
│ ├── skip_ser_tuple_field.rs
│ ├── skip_ser_tuple_field.stderr
│ ├── skip_ser_tuple_field_if.rs
│ ├── skip_ser_tuple_field_if.stderr
│ ├── skip_ser_whole_variant.rs
│ └── skip_ser_whole_variant.stderr
└── unstable/
└── mod.rs
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/FUNDING.yml
================================================
github: dtolnay
================================================
FILE: .github/ISSUE_TEMPLATE/1-problem.md
================================================
---
name: Problem
about: Something does not seem right
---
================================================
FILE: .github/ISSUE_TEMPLATE/2-suggestion.md
================================================
---
name: Suggestion
about: Share how Serde could support your use case better
---
================================================
FILE: .github/ISSUE_TEMPLATE/3-documentation.md
================================================
---
name: Documentation
about: Certainly there is room for improvement
---
================================================
FILE: .github/ISSUE_TEMPLATE/4-other.md
================================================
---
name: Anything else!
about: Whatever is on your mind
---
================================================
FILE: .github/workflows/ci.yml
================================================
name: CI
on:
push:
pull_request:
workflow_dispatch:
schedule: [cron: "40 1 * * *"]
permissions:
contents: read
env:
RUSTFLAGS: -Dwarnings
jobs:
test:
name: Test suite
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@nightly
- run: cd test_suite && cargo test --features unstable
- uses: actions/upload-artifact@v6
if: always()
with:
name: Cargo.lock
path: Cargo.lock
continue-on-error: true
windows:
name: Test suite (windows)
runs-on: windows-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@nightly
- run: cd test_suite && cargo test --features unstable -- --skip ui --exact
stable:
name: Rust ${{matrix.rust}}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust: [stable, beta]
timeout-minutes: 45
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{matrix.rust}}
- run: cd serde && cargo build --features rc
- run: cd serde && cargo build --no-default-features
- run: cd test_suite/no_std && cargo build
nightly:
name: Rust nightly${{matrix.os == 'windows' && ' (windows)' || ''}}
runs-on: ${{matrix.os}}-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu, windows]
timeout-minutes: 45
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@nightly
- run: cd serde && cargo build
- run: cd serde && cargo build --no-default-features
- run: cd serde && cargo build --no-default-features --features alloc
- run: cd serde && cargo build --no-default-features --features rc,alloc
- run: cd serde && cargo build --no-default-features --features unstable
- run: cd serde_core && cargo test --features rc,unstable
- run: cd test_suite/no_std && cargo build
if: matrix.os != 'windows'
- run: cd serde_derive && cargo check --tests
env:
RUSTFLAGS: --cfg exhaustive ${{env.RUSTFLAGS}}
if: matrix.os != 'windows'
build:
name: Rust ${{matrix.rust}}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust: [1.56.0, 1.60.0]
timeout-minutes: 45
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{matrix.rust}}
- run: sed -i '/"test_suite"/d' Cargo.toml
- run: cd serde && cargo build --features rc
- run: cd serde && cargo build --no-default-features
- run: cd serde && cargo build --no-default-features --features alloc
- run: cd serde && cargo build
derive:
name: Rust 1.71.0
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@1.71.0
- run: |
sed -i 's/proc-macro2 = { workspace = true/proc-macro2 = { version = "1"/' serde_derive*/Cargo.toml
sed -i 's/quote = { workspace = true/quote = { version = "1"/' serde_derive*/Cargo.toml
sed -i 's/syn = { workspace = true/syn = { version = "2"/' serde_derive*/Cargo.toml
- run: cd serde && cargo check --no-default-features
- run: cd serde && cargo check
- run: cd serde_derive && cargo check
minimal:
name: Minimal versions
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@nightly
- run: cargo generate-lockfile -Z minimal-versions
- run: cargo check --locked --workspace
doc:
name: Documentation
runs-on: ubuntu-latest
timeout-minutes: 45
env:
RUSTDOCFLAGS: -Dwarnings
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@nightly
- uses: dtolnay/install@cargo-docs-rs
- run: cargo docs-rs -p serde
- run: cargo docs-rs -p serde_core
- run: cargo docs-rs -p serde_derive
- run: cargo docs-rs -p serde_derive_internals
clippy:
name: Clippy
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
timeout-minutes: 45
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@clippy
- run: cd serde && cargo clippy --features rc,unstable -- -Dclippy::all -Dclippy::pedantic
- run: cd serde_core && cargo clippy --features rc,unstable -- -Dclippy::all -Dclippy::pedantic
- run: cd serde_derive && cargo clippy -- -Dclippy::all -Dclippy::pedantic
- run: cd serde_derive_internals && cargo clippy -- -Dclippy::all -Dclippy::pedantic
- run: cd test_suite && cargo clippy --tests --features unstable -- -Dclippy::all -Dclippy::pedantic
- run: cd test_suite/no_std && cargo clippy -- -Dclippy::all -Dclippy::pedantic
miri:
name: Miri
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@miri
- run: cargo miri setup
- run: cd serde_core && cargo miri test --features rc,unstable
env:
MIRIFLAGS: -Zmiri-strict-provenance
- run: cd test_suite && cargo miri test --features unstable
env:
MIRIFLAGS: -Zmiri-strict-provenance
outdated:
name: Outdated
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
timeout-minutes: 45
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- uses: dtolnay/install@cargo-outdated
- run: cargo outdated --workspace --exit-code 1
================================================
FILE: .gitignore
================================================
/target/
/Cargo.lock
================================================
FILE: CONTRIBUTING.md
================================================
# Contributing to Serde
Serde welcomes contribution from everyone in the form of suggestions, bug
reports, pull requests, and feedback. This document gives some guidance if you
are thinking of helping us.
## Submitting bug reports and feature requests
Serde development is spread across lots of repositories, but this serde-rs/serde
repository is always a safe choice for opening any issues related to Serde.
When reporting a bug or asking for help, please include enough details so that
the people helping you can reproduce the behavior you are seeing. For some tips
on how to approach this, read about how to produce a [Minimal, Complete, and
Verifiable example].
[Minimal, Complete, and Verifiable example]: https://stackoverflow.com/help/mcve
When making a feature request, please make it clear what problem you intend to
solve with the feature, any ideas for how Serde could support solving that
problem, any possible alternatives, and any disadvantages.
## Running the test suite
We encourage you to check that the test suite passes locally before submitting a
pull request with your changes. If anything does not pass, typically it will be
easier to iterate and fix it locally than waiting for the CI servers to run
tests for you.
##### In the [`serde_core`] directory
```sh
# Test all the example code in Serde documentation
cargo test
```
##### In the [`test_suite`] directory
```sh
# Run the full test suite, including tests of unstable functionality
cargo +nightly test --features unstable
```
Note that this test suite currently only supports running on a nightly compiler.
[`serde_core`]: https://github.com/serde-rs/serde/tree/master/serde_core
[`test_suite`]: https://github.com/serde-rs/serde/tree/master/test_suite
## Conduct
In all Serde-related forums, we follow the [Rust Code of Conduct]. For
escalation or moderation issues please contact Erick (erick.tryzelaar@gmail.com)
instead of the Rust moderation team.
[Rust Code of Conduct]: https://www.rust-lang.org/policies/code-of-conduct
================================================
FILE: Cargo.toml
================================================
[workspace]
members = [
"serde",
"serde_core",
"serde_derive",
"serde_derive_internals",
"test_suite",
]
resolver = "2"
[patch.crates-io]
serde = { path = "serde" }
serde_core = { path = "serde_core" }
serde_derive = { path = "serde_derive" }
[workspace.dependencies]
proc-macro2 = { version = "1.0.74", default-features = false }
quote = { version = "1.0.35", default-features = false }
syn = { version = "2.0.81", default-features = false }
================================================
FILE: LICENSE-APACHE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
================================================
FILE: LICENSE-MIT
================================================
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
================================================
FILE: README.md
================================================
# Serde   [![Build Status]][actions] [![Latest Version]][crates.io] [![serde msrv]][Rust 1.56] [![serde_derive msrv]][Rust 1.71]
[Build Status]: https://img.shields.io/github/actions/workflow/status/serde-rs/serde/ci.yml?branch=master
[actions]: https://github.com/serde-rs/serde/actions?query=branch%3Amaster
[Latest Version]: https://img.shields.io/crates/v/serde.svg
[crates.io]: https://crates.io/crates/serde
[serde msrv]: https://img.shields.io/crates/msrv/serde.svg?label=serde%20msrv&color=lightgray
[serde_derive msrv]: https://img.shields.io/crates/msrv/serde_derive.svg?label=serde_derive%20msrv&color=lightgray
[Rust 1.56]: https://blog.rust-lang.org/2021/10/21/Rust-1.56.0/
[Rust 1.71]: https://blog.rust-lang.org/2023/07/13/Rust-1.71.0/
**Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and generically.**
---
You may be looking for:
- [An overview of Serde](https://serde.rs)
- [Data formats supported by Serde](https://serde.rs/#data-formats)
- [Setting up `#[derive(Serialize, Deserialize)]`](https://serde.rs/derive.html)
- [Examples](https://serde.rs/examples.html)
- [API documentation](https://docs.rs/serde)
- [Release notes](https://github.com/serde-rs/serde/releases)
## Serde in action
<details>
<summary>
Click to show Cargo.toml.
<a href="https://play.rust-lang.org/?edition=2021&gist=72755f28f99afc95e01d63174b28c1f5" target="_blank">Run this code in the playground.</a>
</summary>
```toml
[dependencies]
# The core APIs, including the Serialize and Deserialize traits. Always
# required when using Serde. The "derive" feature is only required when
# using #[derive(Serialize, Deserialize)] to make Serde work with structs
# and enums defined in your crate.
serde = { version = "1.0", features = ["derive"] }
# Each data format lives in its own crate; the sample code below uses JSON
# but you may be using a different one.
serde_json = "1.0"
```
</details>
<p></p>
```rust
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
struct Point {
x: i32,
y: i32,
}
fn main() {
let point = Point { x: 1, y: 2 };
// Convert the Point to a JSON string.
let serialized = serde_json::to_string(&point).unwrap();
// Prints serialized = {"x":1,"y":2}
println!("serialized = {}", serialized);
// Convert the JSON string back to a Point.
let deserialized: Point = serde_json::from_str(&serialized).unwrap();
// Prints deserialized = Point { x: 1, y: 2 }
println!("deserialized = {:?}", deserialized);
}
```
## Getting help
Serde is one of the most widely used Rust libraries so any place that Rustaceans
congregate will be able to help you out. For chat, consider trying the
[#rust-questions] or [#rust-beginners] channels of the unofficial community
Discord (invite: <https://discord.gg/rust-lang-community>), the [#rust-usage] or
[#beginners] channels of the official Rust Project Discord (invite:
<https://discord.gg/rust-lang>), or the [#general][zulip] stream in Zulip. For
asynchronous, consider the [\[rust\] tag on StackOverflow][stackoverflow], the
[/r/rust] subreddit which has a pinned weekly easy questions post, or the Rust
[Discourse forum][discourse]. It's acceptable to file a support issue in this
repo but they tend not to get as many eyes as any of the above and may get
closed without a response after some time.
[#rust-questions]: https://discord.com/channels/273534239310479360/274215136414400513
[#rust-beginners]: https://discord.com/channels/273534239310479360/273541522815713281
[#rust-usage]: https://discord.com/channels/442252698964721669/443150878111694848
[#beginners]: https://discord.com/channels/442252698964721669/448238009733742612
[zulip]: https://rust-lang.zulipchat.com/#narrow/stream/122651-general
[stackoverflow]: https://stackoverflow.com/questions/tagged/rust
[/r/rust]: https://www.reddit.com/r/rust
[discourse]: https://users.rust-lang.org
<br>
#### License
<sup>
Licensed under either of <a href="LICENSE-APACHE">Apache License, Version
2.0</a> or <a href="LICENSE-MIT">MIT license</a> at your option.
</sup>
<br>
<sub>
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in Serde by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.
</sub>
================================================
FILE: crates-io.md
================================================
<!-- Serde readme rendered on crates.io -->
**Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and generically.**
---
You may be looking for:
- [An overview of Serde](https://serde.rs)
- [Data formats supported by Serde](https://serde.rs/#data-formats)
- [Setting up `#[derive(Serialize, Deserialize)]`](https://serde.rs/derive.html)
- [Examples](https://serde.rs/examples.html)
- [API documentation](https://docs.rs/serde)
- [Release notes](https://github.com/serde-rs/serde/releases)
## Serde in action
```rust
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
struct Point {
x: i32,
y: i32,
}
fn main() {
let point = Point { x: 1, y: 2 };
// Convert the Point to a JSON string.
let serialized = serde_json::to_string(&point).unwrap();
// Prints serialized = {"x":1,"y":2}
println!("serialized = {}", serialized);
// Convert the JSON string back to a Point.
let deserialized: Point = serde_json::from_str(&serialized).unwrap();
// Prints deserialized = Point { x: 1, y: 2 }
println!("deserialized = {:?}", deserialized);
}
```
## Getting help
Serde is one of the most widely used Rust libraries so any place that Rustaceans
congregate will be able to help you out. For chat, consider trying the
[#rust-questions] or [#rust-beginners] channels of the unofficial community
Discord (invite: <https://discord.gg/rust-lang-community>), the [#rust-usage]
or [#beginners] channels of the official Rust Project Discord (invite:
<https://discord.gg/rust-lang>), or the [#general][zulip] stream in Zulip. For
asynchronous, consider the [\[rust\] tag on StackOverflow][stackoverflow], the
[/r/rust] subreddit which has a pinned weekly easy questions post, or the Rust
[Discourse forum][discourse]. It's acceptable to file a support issue in this
repo but they tend not to get as many eyes as any of the above and may get
closed without a response after some time.
[#rust-questions]: https://discord.com/channels/273534239310479360/274215136414400513
[#rust-beginners]: https://discord.com/channels/273534239310479360/273541522815713281
[#rust-usage]: https://discord.com/channels/442252698964721669/443150878111694848
[#beginners]: https://discord.com/channels/442252698964721669/448238009733742612
[zulip]: https://rust-lang.zulipchat.com/#narrow/stream/122651-general
[stackoverflow]: https://stackoverflow.com/questions/tagged/rust
[/r/rust]: https://www.reddit.com/r/rust
[discourse]: https://users.rust-lang.org
================================================
FILE: serde/Cargo.toml
================================================
[package]
name = "serde"
version = "1.0.228"
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
build = "build.rs"
categories = ["encoding", "no-std", "no-std::no-alloc"]
description = "A generic serialization/deserialization framework"
documentation = "https://docs.rs/serde"
edition = "2021"
homepage = "https://serde.rs"
keywords = ["serde", "serialization", "no_std"]
license = "MIT OR Apache-2.0"
readme = "crates-io.md"
repository = "https://github.com/serde-rs/serde"
rust-version = "1.56"
[dependencies]
serde_core = { version = "=1.0.228", path = "../serde_core", default-features = false, features = ["result"] }
serde_derive = { version = "1", optional = true, path = "../serde_derive" }
[package.metadata.playground]
features = ["derive", "rc"]
[package.metadata.docs.rs]
features = ["derive", "rc", "unstable"]
targets = ["x86_64-unknown-linux-gnu"]
rustdoc-args = [
"--generate-link-to-definition",
"--generate-macro-expansion",
"--extern-html-root-url=core=https://doc.rust-lang.org",
"--extern-html-root-url=alloc=https://doc.rust-lang.org",
"--extern-html-root-url=std=https://doc.rust-lang.org",
]
### FEATURES #################################################################
[features]
default = ["std"]
# Provide derive(Serialize, Deserialize) macros.
derive = ["serde_derive"]
# Provide impls for common standard library types like Vec<T> and HashMap<K, V>.
# Requires a dependency on the Rust standard library.
std = ["serde_core/std"]
# Provide impls for types that require unstable functionality. For tracking and
# discussion of unstable functionality please refer to this issue:
#
# https://github.com/serde-rs/serde/issues/812
unstable = ["serde_core/unstable"]
# Provide impls for types in the Rust core allocation and collections library
# including String, Box<T>, Vec<T>, and Cow<T>. This is a subset of std but may
# be enabled without depending on all of std.
alloc = ["serde_core/alloc"]
# Opt into impls for Rc<T> and Arc<T>. Serializing and deserializing these types
# does not preserve identity and may result in multiple copies of the same data.
# Be sure that this is what you want before enabling this feature.
rc = ["serde_core/rc"]
================================================
FILE: serde/build.rs
================================================
use std::env;
use std::fs;
use std::path::PathBuf;
use std::process::Command;
use std::str;
const PRIVATE: &str = "\
#[doc(hidden)]
pub mod __private$$ {
#[doc(hidden)]
pub use crate::private::*;
}
use serde_core::__private$$ as serde_core_private;
";
// The rustc-cfg strings below are *not* public API. Please let us know by
// opening a GitHub issue if your build environment requires some way to enable
// these cfgs other than by executing our build script.
fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rustc-cfg=if_docsrs_then_no_serde_core");
let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
let patch_version = env::var("CARGO_PKG_VERSION_PATCH").unwrap();
let module = PRIVATE.replace("$$", &patch_version);
fs::write(out_dir.join("private.rs"), module).unwrap();
let minor = match rustc_minor_version() {
Some(minor) => minor,
None => return,
};
if minor >= 77 {
println!("cargo:rustc-check-cfg=cfg(feature, values(\"result\"))");
println!("cargo:rustc-check-cfg=cfg(if_docsrs_then_no_serde_core)");
println!("cargo:rustc-check-cfg=cfg(no_core_cstr)");
println!("cargo:rustc-check-cfg=cfg(no_core_error)");
println!("cargo:rustc-check-cfg=cfg(no_core_net)");
println!("cargo:rustc-check-cfg=cfg(no_core_num_saturating)");
println!("cargo:rustc-check-cfg=cfg(no_diagnostic_namespace)");
println!("cargo:rustc-check-cfg=cfg(no_serde_derive)");
println!("cargo:rustc-check-cfg=cfg(no_std_atomic)");
println!("cargo:rustc-check-cfg=cfg(no_std_atomic64)");
println!("cargo:rustc-check-cfg=cfg(no_target_has_atomic)");
}
// Current minimum supported version of serde_derive crate is Rust 1.71.
if minor < 71 {
println!("cargo:rustc-cfg=no_serde_derive");
}
// Support for the `#[diagnostic]` tool attribute namespace
// https://blog.rust-lang.org/2024/05/02/Rust-1.78.0.html#diagnostic-attributes
if minor < 78 {
println!("cargo:rustc-cfg=no_diagnostic_namespace");
}
}
fn rustc_minor_version() -> Option<u32> {
let rustc = env::var_os("RUSTC")?;
let output = Command::new(rustc).arg("--version").output().ok()?;
let version = str::from_utf8(&output.stdout).ok()?;
let mut pieces = version.split('.');
if pieces.next() != Some("rustc 1") {
return None;
}
pieces.next()?.parse().ok()
}
================================================
FILE: serde/src/integer128.rs
================================================
#[macro_export]
#[deprecated = "
This macro has no effect on any version of Serde released in the past 2 years.
It was used long ago in crates that needed to support Rustc older than 1.26.0,
or Emscripten targets older than 1.40.0, which did not yet have 128-bit integer
support. These days Serde requires a Rust compiler newer than that so 128-bit
integers are always supported.
"]
#[doc(hidden)]
macro_rules! serde_if_integer128 {
($($tt:tt)*) => {
$($tt)*
};
}
================================================
FILE: serde/src/lib.rs
================================================
//! # Serde
//!
//! Serde is a framework for ***ser***ializing and ***de***serializing Rust data
//! structures efficiently and generically.
//!
//! The Serde ecosystem consists of data structures that know how to serialize
//! and deserialize themselves along with data formats that know how to
//! serialize and deserialize other things. Serde provides the layer by which
//! these two groups interact with each other, allowing any supported data
//! structure to be serialized and deserialized using any supported data format.
//!
//! See the Serde website <https://serde.rs> for additional documentation and
//! usage examples.
//!
//! ## Design
//!
//! Where many other languages rely on runtime reflection for serializing data,
//! Serde is instead built on Rust's powerful trait system. A data structure
//! that knows how to serialize and deserialize itself is one that implements
//! Serde's `Serialize` and `Deserialize` traits (or uses Serde's derive
//! attribute to automatically generate implementations at compile time). This
//! avoids any overhead of reflection or runtime type information. In fact in
//! many situations the interaction between data structure and data format can
//! be completely optimized away by the Rust compiler, leaving Serde
//! serialization to perform the same speed as a handwritten serializer for the
//! specific selection of data structure and data format.
//!
//! ## Data formats
//!
//! The following is a partial list of data formats that have been implemented
//! for Serde by the community.
//!
//! - [JSON], the ubiquitous JavaScript Object Notation used by many HTTP APIs.
//! - [Postcard], a no\_std and embedded-systems friendly compact binary format.
//! - [CBOR], a Concise Binary Object Representation designed for small message
//! size without the need for version negotiation.
//! - [YAML], a self-proclaimed human-friendly configuration language that ain't
//! markup language.
//! - [MessagePack], an efficient binary format that resembles a compact JSON.
//! - [TOML], a minimal configuration format used by [Cargo].
//! - [Pickle], a format common in the Python world.
//! - [RON], a Rusty Object Notation.
//! - [BSON], the data storage and network transfer format used by MongoDB.
//! - [Avro], a binary format used within Apache Hadoop, with support for schema
//! definition.
//! - [JSON5], a superset of JSON including some productions from ES5.
//! - [URL] query strings, in the x-www-form-urlencoded format.
//! - [Starlark], the format used for describing build targets by the Bazel and
//! Buck build systems. *(serialization only)*
//! - [Envy], a way to deserialize environment variables into Rust structs.
//! *(deserialization only)*
//! - [Envy Store], a way to deserialize [AWS Parameter Store] parameters into
//! Rust structs. *(deserialization only)*
//! - [S-expressions], the textual representation of code and data used by the
//! Lisp language family.
//! - [D-Bus]'s binary wire format.
//! - [FlexBuffers], the schemaless cousin of Google's FlatBuffers zero-copy
//! serialization format.
//! - [Bencode], a simple binary format used in the BitTorrent protocol.
//! - [Token streams], for processing Rust procedural macro input.
//! *(deserialization only)*
//! - [DynamoDB Items], the format used by [rusoto_dynamodb] to transfer data to
//! and from DynamoDB.
//! - [Hjson], a syntax extension to JSON designed around human reading and
//! editing. *(deserialization only)*
//! - [CSV], Comma-separated values is a tabular text file format.
//!
//! [JSON]: https://github.com/serde-rs/json
//! [Postcard]: https://github.com/jamesmunns/postcard
//! [CBOR]: https://github.com/enarx/ciborium
//! [YAML]: https://github.com/dtolnay/serde-yaml
//! [MessagePack]: https://github.com/3Hren/msgpack-rust
//! [TOML]: https://docs.rs/toml
//! [Pickle]: https://github.com/birkenfeld/serde-pickle
//! [RON]: https://github.com/ron-rs/ron
//! [BSON]: https://github.com/mongodb/bson-rust
//! [Avro]: https://docs.rs/apache-avro
//! [JSON5]: https://github.com/callum-oakley/json5-rs
//! [URL]: https://docs.rs/serde_qs
//! [Starlark]: https://github.com/dtolnay/serde-starlark
//! [Envy]: https://github.com/softprops/envy
//! [Envy Store]: https://github.com/softprops/envy-store
//! [Cargo]: https://doc.rust-lang.org/cargo/reference/manifest.html
//! [AWS Parameter Store]: https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-parameter-store.html
//! [S-expressions]: https://github.com/rotty/lexpr-rs
//! [D-Bus]: https://docs.rs/zvariant
//! [FlexBuffers]: https://github.com/google/flatbuffers/tree/master/rust/flexbuffers
//! [Bencode]: https://github.com/P3KI/bendy
//! [Token streams]: https://github.com/oxidecomputer/serde_tokenstream
//! [DynamoDB Items]: https://docs.rs/serde_dynamo
//! [rusoto_dynamodb]: https://docs.rs/rusoto_dynamodb
//! [Hjson]: https://github.com/Canop/deser-hjson
//! [CSV]: https://docs.rs/csv
////////////////////////////////////////////////////////////////////////////////
// Serde types in rustdoc of other crates get linked to here.
#![doc(html_root_url = "https://docs.rs/serde/1.0.228")]
// Support using Serde without the standard library!
#![cfg_attr(not(feature = "std"), no_std)]
// Show which crate feature enables conditionally compiled APIs in documentation.
#![cfg_attr(docsrs, feature(doc_cfg, rustdoc_internals))]
#![cfg_attr(docsrs, allow(internal_features))]
// Unstable functionality only if the user asks for it. For tracking and
// discussion of these features please refer to this issue:
//
// https://github.com/serde-rs/serde/issues/812
#![cfg_attr(all(feature = "unstable", docsrs), feature(never_type))]
#![allow(
unknown_lints,
bare_trait_objects,
deprecated,
mismatched_lifetime_syntaxes
)]
// Ignored clippy and clippy_pedantic lints
#![allow(
// clippy bug: https://github.com/rust-lang/rust-clippy/issues/5704
clippy::unnested_or_patterns,
// clippy bug: https://github.com/rust-lang/rust-clippy/issues/7768
clippy::semicolon_if_nothing_returned,
// not available in our oldest supported compiler
clippy::empty_enums,
clippy::type_repetition_in_bounds, // https://github.com/rust-lang/rust-clippy/issues/8772
// integer and float ser/de requires these sorts of casts
clippy::cast_possible_truncation,
clippy::cast_possible_wrap,
clippy::cast_precision_loss,
clippy::cast_sign_loss,
// things are often more readable this way
clippy::cast_lossless,
clippy::module_name_repetitions,
clippy::single_match_else,
clippy::type_complexity,
clippy::use_self,
clippy::zero_prefixed_literal,
// correctly used
clippy::derive_partial_eq_without_eq,
clippy::enum_glob_use,
clippy::explicit_auto_deref,
clippy::incompatible_msrv,
clippy::let_underscore_untyped,
clippy::map_err_ignore,
clippy::new_without_default,
clippy::result_unit_err,
clippy::wildcard_imports,
// not practical
clippy::needless_pass_by_value,
clippy::similar_names,
clippy::too_many_lines,
// preference
clippy::doc_markdown,
clippy::elidable_lifetime_names,
clippy::needless_lifetimes,
clippy::unseparated_literal_suffix,
// false positive
clippy::needless_doctest_main,
// noisy
clippy::missing_errors_doc,
clippy::must_use_candidate,
)]
// Restrictions
#![deny(clippy::question_mark_used)]
// Rustc lints.
#![deny(missing_docs, unused_imports)]
////////////////////////////////////////////////////////////////////////////////
#[cfg(feature = "alloc")]
extern crate alloc;
// Rustdoc has a lot of shortcomings related to cross-crate re-exports that make
// the rendered documentation of serde_core traits in serde more challenging to
// understand than the equivalent documentation of the same items in serde_core.
// https://github.com/rust-lang/rust/labels/A-cross-crate-reexports
// So, just for the purpose of docs.rs documentation, we inline the contents of
// serde_core into serde. This sidesteps all the cross-crate rustdoc bugs.
#[cfg(docsrs)]
#[macro_use]
#[path = "core/crate_root.rs"]
mod crate_root;
#[cfg(docsrs)]
#[macro_use]
#[path = "core/macros.rs"]
mod macros;
#[cfg(not(docsrs))]
macro_rules! crate_root {
() => {
/// A facade around all the types we need from the `std`, `core`, and `alloc`
/// crates. This avoids elaborate import wrangling having to happen in every
/// module.
mod lib {
mod core {
#[cfg(not(feature = "std"))]
pub use core::*;
#[cfg(feature = "std")]
pub use std::*;
}
pub use self::core::{f32, f64};
pub use self::core::{ptr, str};
#[cfg(any(feature = "std", feature = "alloc"))]
pub use self::core::slice;
pub use self::core::clone;
pub use self::core::convert;
pub use self::core::default;
pub use self::core::fmt::{self, Debug, Display, Write as FmtWrite};
pub use self::core::marker::{self, PhantomData};
pub use self::core::option;
pub use self::core::result;
#[cfg(all(feature = "alloc", not(feature = "std")))]
pub use alloc::borrow::{Cow, ToOwned};
#[cfg(feature = "std")]
pub use std::borrow::{Cow, ToOwned};
#[cfg(all(feature = "alloc", not(feature = "std")))]
pub use alloc::string::{String, ToString};
#[cfg(feature = "std")]
pub use std::string::{String, ToString};
#[cfg(all(feature = "alloc", not(feature = "std")))]
pub use alloc::vec::Vec;
#[cfg(feature = "std")]
pub use std::vec::Vec;
#[cfg(all(feature = "alloc", not(feature = "std")))]
pub use alloc::boxed::Box;
#[cfg(feature = "std")]
pub use std::boxed::Box;
}
// None of this crate's error handling needs the `From::from` error conversion
// performed implicitly by the `?` operator or the standard library's `try!`
// macro. This simplified macro gives a 5.5% improvement in compile time
// compared to standard `try!`, and 9% improvement compared to `?`.
#[cfg(not(no_serde_derive))]
macro_rules! tri {
($expr:expr) => {
match $expr {
Ok(val) => val,
Err(err) => return Err(err),
}
};
}
////////////////////////////////////////////////////////////////////////////////
pub use serde_core::{
de, forward_to_deserialize_any, ser, Deserialize, Deserializer, Serialize, Serializer,
};
// Used by generated code and doc tests. Not public API.
#[doc(hidden)]
mod private;
include!(concat!(env!("OUT_DIR"), "/private.rs"));
};
}
crate_root!();
mod integer128;
// Re-export #[derive(Serialize, Deserialize)].
//
// The reason re-exporting is not enabled by default is that disabling it would
// be annoying for crates that provide handwritten impls or data formats. They
// would need to disable default features and then explicitly re-enable std.
#[cfg(feature = "serde_derive")]
extern crate serde_derive;
/// Derive macro available if serde is built with `features = ["derive"]`.
#[cfg(feature = "serde_derive")]
#[cfg_attr(docsrs, doc(cfg(feature = "derive")))]
pub use serde_derive::{Deserialize, Serialize};
#[macro_export]
#[doc(hidden)]
macro_rules! __require_serde_not_serde_core {
() => {};
}
================================================
FILE: serde/src/private/de.rs
================================================
use crate::lib::*;
use crate::de::value::{BorrowedBytesDeserializer, BytesDeserializer};
use crate::de::{
Deserialize, DeserializeSeed, Deserializer, EnumAccess, Error, IntoDeserializer, VariantAccess,
Visitor,
};
#[cfg(any(feature = "std", feature = "alloc"))]
use crate::de::{MapAccess, Unexpected};
#[cfg(any(feature = "std", feature = "alloc"))]
pub use self::content::{
content_as_str, Content, ContentDeserializer, ContentRefDeserializer, ContentVisitor,
EnumDeserializer, InternallyTaggedUnitVisitor, TagContentOtherField,
TagContentOtherFieldVisitor, TagOrContentField, TagOrContentFieldVisitor, TaggedContentVisitor,
UntaggedUnitVisitor,
};
pub use crate::serde_core_private::InPlaceSeed;
/// If the missing field is of type `Option<T>` then treat is as `None`,
/// otherwise it is an error.
pub fn missing_field<'de, V, E>(field: &'static str) -> Result<V, E>
where
V: Deserialize<'de>,
E: Error,
{
struct MissingFieldDeserializer<E>(&'static str, PhantomData<E>);
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de, E> Deserializer<'de> for MissingFieldDeserializer<E>
where
E: Error,
{
type Error = E;
fn deserialize_any<V>(self, _visitor: V) -> Result<V::Value, E>
where
V: Visitor<'de>,
{
Err(Error::missing_field(self.0))
}
fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, E>
where
V: Visitor<'de>,
{
visitor.visit_none()
}
serde_core::forward_to_deserialize_any! {
bool i8 i16 i32 i64 i128 u8 u16 u32 u64 u128 f32 f64 char str string
bytes byte_buf unit unit_struct newtype_struct seq tuple
tuple_struct map struct enum identifier ignored_any
}
}
let deserializer = MissingFieldDeserializer(field, PhantomData);
Deserialize::deserialize(deserializer)
}
#[cfg(any(feature = "std", feature = "alloc"))]
pub fn borrow_cow_str<'de: 'a, 'a, D, R>(deserializer: D) -> Result<R, D::Error>
where
D: Deserializer<'de>,
R: From<Cow<'a, str>>,
{
struct CowStrVisitor;
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'a> Visitor<'a> for CowStrVisitor {
type Value = Cow<'a, str>;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter.write_str("a string")
}
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
where
E: Error,
{
Ok(Cow::Owned(v.to_owned()))
}
fn visit_borrowed_str<E>(self, v: &'a str) -> Result<Self::Value, E>
where
E: Error,
{
Ok(Cow::Borrowed(v))
}
fn visit_string<E>(self, v: String) -> Result<Self::Value, E>
where
E: Error,
{
Ok(Cow::Owned(v))
}
fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
where
E: Error,
{
match str::from_utf8(v) {
Ok(s) => Ok(Cow::Owned(s.to_owned())),
Err(_) => Err(Error::invalid_value(Unexpected::Bytes(v), &self)),
}
}
fn visit_borrowed_bytes<E>(self, v: &'a [u8]) -> Result<Self::Value, E>
where
E: Error,
{
match str::from_utf8(v) {
Ok(s) => Ok(Cow::Borrowed(s)),
Err(_) => Err(Error::invalid_value(Unexpected::Bytes(v), &self)),
}
}
fn visit_byte_buf<E>(self, v: Vec<u8>) -> Result<Self::Value, E>
where
E: Error,
{
match String::from_utf8(v) {
Ok(s) => Ok(Cow::Owned(s)),
Err(e) => Err(Error::invalid_value(
Unexpected::Bytes(&e.into_bytes()),
&self,
)),
}
}
}
deserializer.deserialize_str(CowStrVisitor).map(From::from)
}
#[cfg(any(feature = "std", feature = "alloc"))]
pub fn borrow_cow_bytes<'de: 'a, 'a, D, R>(deserializer: D) -> Result<R, D::Error>
where
D: Deserializer<'de>,
R: From<Cow<'a, [u8]>>,
{
struct CowBytesVisitor;
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'a> Visitor<'a> for CowBytesVisitor {
type Value = Cow<'a, [u8]>;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter.write_str("a byte array")
}
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
where
E: Error,
{
Ok(Cow::Owned(v.as_bytes().to_vec()))
}
fn visit_borrowed_str<E>(self, v: &'a str) -> Result<Self::Value, E>
where
E: Error,
{
Ok(Cow::Borrowed(v.as_bytes()))
}
fn visit_string<E>(self, v: String) -> Result<Self::Value, E>
where
E: Error,
{
Ok(Cow::Owned(v.into_bytes()))
}
fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
where
E: Error,
{
Ok(Cow::Owned(v.to_vec()))
}
fn visit_borrowed_bytes<E>(self, v: &'a [u8]) -> Result<Self::Value, E>
where
E: Error,
{
Ok(Cow::Borrowed(v))
}
fn visit_byte_buf<E>(self, v: Vec<u8>) -> Result<Self::Value, E>
where
E: Error,
{
Ok(Cow::Owned(v))
}
}
deserializer
.deserialize_bytes(CowBytesVisitor)
.map(From::from)
}
#[cfg(any(feature = "std", feature = "alloc"))]
mod content {
// This module is private and nothing here should be used outside of
// generated code.
//
// We will iterate on the implementation for a few releases and only have to
// worry about backward compatibility for the `untagged` and `tag` attributes
// rather than for this entire mechanism.
//
// This issue is tracking making some of this stuff public:
// https://github.com/serde-rs/serde/issues/741
use crate::lib::*;
use crate::de::{
self, Deserialize, DeserializeSeed, Deserializer, EnumAccess, Expected, IgnoredAny,
MapAccess, SeqAccess, Unexpected, Visitor,
};
use crate::serde_core_private::size_hint;
pub use crate::serde_core_private::Content;
pub fn content_as_str<'a, 'de>(content: &'a Content<'de>) -> Option<&'a str> {
match *content {
Content::Str(x) => Some(x),
Content::String(ref x) => Some(x),
Content::Bytes(x) => str::from_utf8(x).ok(),
Content::ByteBuf(ref x) => str::from_utf8(x).ok(),
_ => None,
}
}
fn content_clone<'de>(content: &Content<'de>) -> Content<'de> {
match content {
Content::Bool(b) => Content::Bool(*b),
Content::U8(n) => Content::U8(*n),
Content::U16(n) => Content::U16(*n),
Content::U32(n) => Content::U32(*n),
Content::U64(n) => Content::U64(*n),
Content::I8(n) => Content::I8(*n),
Content::I16(n) => Content::I16(*n),
Content::I32(n) => Content::I32(*n),
Content::I64(n) => Content::I64(*n),
Content::F32(f) => Content::F32(*f),
Content::F64(f) => Content::F64(*f),
Content::Char(c) => Content::Char(*c),
Content::String(s) => Content::String(s.clone()),
Content::Str(s) => Content::Str(*s),
Content::ByteBuf(b) => Content::ByteBuf(b.clone()),
Content::Bytes(b) => Content::Bytes(b),
Content::None => Content::None,
Content::Some(content) => Content::Some(Box::new(content_clone(content))),
Content::Unit => Content::Unit,
Content::Newtype(content) => Content::Newtype(Box::new(content_clone(content))),
Content::Seq(seq) => Content::Seq(seq.iter().map(content_clone).collect()),
Content::Map(map) => Content::Map(
map.iter()
.map(|(k, v)| (content_clone(k), content_clone(v)))
.collect(),
),
}
}
#[cold]
fn content_unexpected<'a, 'de>(content: &'a Content<'de>) -> Unexpected<'a> {
match *content {
Content::Bool(b) => Unexpected::Bool(b),
Content::U8(n) => Unexpected::Unsigned(n as u64),
Content::U16(n) => Unexpected::Unsigned(n as u64),
Content::U32(n) => Unexpected::Unsigned(n as u64),
Content::U64(n) => Unexpected::Unsigned(n),
Content::I8(n) => Unexpected::Signed(n as i64),
Content::I16(n) => Unexpected::Signed(n as i64),
Content::I32(n) => Unexpected::Signed(n as i64),
Content::I64(n) => Unexpected::Signed(n),
Content::F32(f) => Unexpected::Float(f as f64),
Content::F64(f) => Unexpected::Float(f),
Content::Char(c) => Unexpected::Char(c),
Content::String(ref s) => Unexpected::Str(s),
Content::Str(s) => Unexpected::Str(s),
Content::ByteBuf(ref b) => Unexpected::Bytes(b),
Content::Bytes(b) => Unexpected::Bytes(b),
Content::None | Content::Some(_) => Unexpected::Option,
Content::Unit => Unexpected::Unit,
Content::Newtype(_) => Unexpected::NewtypeStruct,
Content::Seq(_) => Unexpected::Seq,
Content::Map(_) => Unexpected::Map,
}
}
pub struct ContentVisitor<'de> {
value: PhantomData<Content<'de>>,
}
impl<'de> ContentVisitor<'de> {
pub fn new() -> Self {
ContentVisitor { value: PhantomData }
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de> DeserializeSeed<'de> for ContentVisitor<'de> {
type Value = Content<'de>;
fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
where
D: Deserializer<'de>,
{
deserializer.__deserialize_content_v1(self)
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de> Visitor<'de> for ContentVisitor<'de> {
type Value = Content<'de>;
fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.write_str("any value")
}
fn visit_bool<F>(self, value: bool) -> Result<Self::Value, F>
where
F: de::Error,
{
Ok(Content::Bool(value))
}
fn visit_i8<F>(self, value: i8) -> Result<Self::Value, F>
where
F: de::Error,
{
Ok(Content::I8(value))
}
fn visit_i16<F>(self, value: i16) -> Result<Self::Value, F>
where
F: de::Error,
{
Ok(Content::I16(value))
}
fn visit_i32<F>(self, value: i32) -> Result<Self::Value, F>
where
F: de::Error,
{
Ok(Content::I32(value))
}
fn visit_i64<F>(self, value: i64) -> Result<Self::Value, F>
where
F: de::Error,
{
Ok(Content::I64(value))
}
fn visit_u8<F>(self, value: u8) -> Result<Self::Value, F>
where
F: de::Error,
{
Ok(Content::U8(value))
}
fn visit_u16<F>(self, value: u16) -> Result<Self::Value, F>
where
F: de::Error,
{
Ok(Content::U16(value))
}
fn visit_u32<F>(self, value: u32) -> Result<Self::Value, F>
where
F: de::Error,
{
Ok(Content::U32(value))
}
fn visit_u64<F>(self, value: u64) -> Result<Self::Value, F>
where
F: de::Error,
{
Ok(Content::U64(value))
}
fn visit_f32<F>(self, value: f32) -> Result<Self::Value, F>
where
F: de::Error,
{
Ok(Content::F32(value))
}
fn visit_f64<F>(self, value: f64) -> Result<Self::Value, F>
where
F: de::Error,
{
Ok(Content::F64(value))
}
fn visit_char<F>(self, value: char) -> Result<Self::Value, F>
where
F: de::Error,
{
Ok(Content::Char(value))
}
fn visit_str<F>(self, value: &str) -> Result<Self::Value, F>
where
F: de::Error,
{
Ok(Content::String(value.into()))
}
fn visit_borrowed_str<F>(self, value: &'de str) -> Result<Self::Value, F>
where
F: de::Error,
{
Ok(Content::Str(value))
}
fn visit_string<F>(self, value: String) -> Result<Self::Value, F>
where
F: de::Error,
{
Ok(Content::String(value))
}
fn visit_bytes<F>(self, value: &[u8]) -> Result<Self::Value, F>
where
F: de::Error,
{
Ok(Content::ByteBuf(value.into()))
}
fn visit_borrowed_bytes<F>(self, value: &'de [u8]) -> Result<Self::Value, F>
where
F: de::Error,
{
Ok(Content::Bytes(value))
}
fn visit_byte_buf<F>(self, value: Vec<u8>) -> Result<Self::Value, F>
where
F: de::Error,
{
Ok(Content::ByteBuf(value))
}
fn visit_unit<F>(self) -> Result<Self::Value, F>
where
F: de::Error,
{
Ok(Content::Unit)
}
fn visit_none<F>(self) -> Result<Self::Value, F>
where
F: de::Error,
{
Ok(Content::None)
}
fn visit_some<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
where
D: Deserializer<'de>,
{
let v = tri!(ContentVisitor::new().deserialize(deserializer));
Ok(Content::Some(Box::new(v)))
}
fn visit_newtype_struct<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
where
D: Deserializer<'de>,
{
let v = tri!(ContentVisitor::new().deserialize(deserializer));
Ok(Content::Newtype(Box::new(v)))
}
fn visit_seq<V>(self, mut visitor: V) -> Result<Self::Value, V::Error>
where
V: SeqAccess<'de>,
{
let mut vec =
Vec::<Content>::with_capacity(size_hint::cautious::<Content>(visitor.size_hint()));
while let Some(e) = tri!(visitor.next_element_seed(ContentVisitor::new())) {
vec.push(e);
}
Ok(Content::Seq(vec))
}
fn visit_map<V>(self, mut visitor: V) -> Result<Self::Value, V::Error>
where
V: MapAccess<'de>,
{
let mut vec =
Vec::<(Content, Content)>::with_capacity(
size_hint::cautious::<(Content, Content)>(visitor.size_hint()),
);
while let Some(kv) =
tri!(visitor.next_entry_seed(ContentVisitor::new(), ContentVisitor::new()))
{
vec.push(kv);
}
Ok(Content::Map(vec))
}
fn visit_enum<V>(self, _visitor: V) -> Result<Self::Value, V::Error>
where
V: EnumAccess<'de>,
{
Err(de::Error::custom(
"untagged and internally tagged enums do not support enum input",
))
}
}
/// This is the type of the map keys in an internally tagged enum.
///
/// Not public API.
pub enum TagOrContent<'de> {
Tag,
Content(Content<'de>),
}
/// Serves as a seed for deserializing a key of internally tagged enum.
/// Cannot capture externally tagged enums, `i128` and `u128`.
struct TagOrContentVisitor<'de> {
name: &'static str,
value: PhantomData<TagOrContent<'de>>,
}
impl<'de> TagOrContentVisitor<'de> {
fn new(name: &'static str) -> Self {
TagOrContentVisitor {
name,
value: PhantomData,
}
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de> DeserializeSeed<'de> for TagOrContentVisitor<'de> {
type Value = TagOrContent<'de>;
fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
where
D: Deserializer<'de>,
{
// Internally tagged enums are only supported in self-describing
// formats.
deserializer.deserialize_any(self)
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de> Visitor<'de> for TagOrContentVisitor<'de> {
type Value = TagOrContent<'de>;
fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
write!(fmt, "a type tag `{}` or any other value", self.name)
}
fn visit_bool<F>(self, value: bool) -> Result<Self::Value, F>
where
F: de::Error,
{
ContentVisitor::new()
.visit_bool(value)
.map(TagOrContent::Content)
}
fn visit_i8<F>(self, value: i8) -> Result<Self::Value, F>
where
F: de::Error,
{
ContentVisitor::new()
.visit_i8(value)
.map(TagOrContent::Content)
}
fn visit_i16<F>(self, value: i16) -> Result<Self::Value, F>
where
F: de::Error,
{
ContentVisitor::new()
.visit_i16(value)
.map(TagOrContent::Content)
}
fn visit_i32<F>(self, value: i32) -> Result<Self::Value, F>
where
F: de::Error,
{
ContentVisitor::new()
.visit_i32(value)
.map(TagOrContent::Content)
}
fn visit_i64<F>(self, value: i64) -> Result<Self::Value, F>
where
F: de::Error,
{
ContentVisitor::new()
.visit_i64(value)
.map(TagOrContent::Content)
}
fn visit_u8<F>(self, value: u8) -> Result<Self::Value, F>
where
F: de::Error,
{
ContentVisitor::new()
.visit_u8(value)
.map(TagOrContent::Content)
}
fn visit_u16<F>(self, value: u16) -> Result<Self::Value, F>
where
F: de::Error,
{
ContentVisitor::new()
.visit_u16(value)
.map(TagOrContent::Content)
}
fn visit_u32<F>(self, value: u32) -> Result<Self::Value, F>
where
F: de::Error,
{
ContentVisitor::new()
.visit_u32(value)
.map(TagOrContent::Content)
}
fn visit_u64<F>(self, value: u64) -> Result<Self::Value, F>
where
F: de::Error,
{
ContentVisitor::new()
.visit_u64(value)
.map(TagOrContent::Content)
}
fn visit_f32<F>(self, value: f32) -> Result<Self::Value, F>
where
F: de::Error,
{
ContentVisitor::new()
.visit_f32(value)
.map(TagOrContent::Content)
}
fn visit_f64<F>(self, value: f64) -> Result<Self::Value, F>
where
F: de::Error,
{
ContentVisitor::new()
.visit_f64(value)
.map(TagOrContent::Content)
}
fn visit_char<F>(self, value: char) -> Result<Self::Value, F>
where
F: de::Error,
{
ContentVisitor::new()
.visit_char(value)
.map(TagOrContent::Content)
}
fn visit_str<F>(self, value: &str) -> Result<Self::Value, F>
where
F: de::Error,
{
if value == self.name {
Ok(TagOrContent::Tag)
} else {
ContentVisitor::new()
.visit_str(value)
.map(TagOrContent::Content)
}
}
fn visit_borrowed_str<F>(self, value: &'de str) -> Result<Self::Value, F>
where
F: de::Error,
{
if value == self.name {
Ok(TagOrContent::Tag)
} else {
ContentVisitor::new()
.visit_borrowed_str(value)
.map(TagOrContent::Content)
}
}
fn visit_string<F>(self, value: String) -> Result<Self::Value, F>
where
F: de::Error,
{
if value == self.name {
Ok(TagOrContent::Tag)
} else {
ContentVisitor::new()
.visit_string(value)
.map(TagOrContent::Content)
}
}
fn visit_bytes<F>(self, value: &[u8]) -> Result<Self::Value, F>
where
F: de::Error,
{
if value == self.name.as_bytes() {
Ok(TagOrContent::Tag)
} else {
ContentVisitor::new()
.visit_bytes(value)
.map(TagOrContent::Content)
}
}
fn visit_borrowed_bytes<F>(self, value: &'de [u8]) -> Result<Self::Value, F>
where
F: de::Error,
{
if value == self.name.as_bytes() {
Ok(TagOrContent::Tag)
} else {
ContentVisitor::new()
.visit_borrowed_bytes(value)
.map(TagOrContent::Content)
}
}
fn visit_byte_buf<F>(self, value: Vec<u8>) -> Result<Self::Value, F>
where
F: de::Error,
{
if value == self.name.as_bytes() {
Ok(TagOrContent::Tag)
} else {
ContentVisitor::new()
.visit_byte_buf(value)
.map(TagOrContent::Content)
}
}
fn visit_unit<F>(self) -> Result<Self::Value, F>
where
F: de::Error,
{
ContentVisitor::new()
.visit_unit()
.map(TagOrContent::Content)
}
fn visit_none<F>(self) -> Result<Self::Value, F>
where
F: de::Error,
{
ContentVisitor::new()
.visit_none()
.map(TagOrContent::Content)
}
fn visit_some<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
where
D: Deserializer<'de>,
{
ContentVisitor::new()
.visit_some(deserializer)
.map(TagOrContent::Content)
}
fn visit_newtype_struct<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
where
D: Deserializer<'de>,
{
ContentVisitor::new()
.visit_newtype_struct(deserializer)
.map(TagOrContent::Content)
}
fn visit_seq<V>(self, visitor: V) -> Result<Self::Value, V::Error>
where
V: SeqAccess<'de>,
{
ContentVisitor::new()
.visit_seq(visitor)
.map(TagOrContent::Content)
}
fn visit_map<V>(self, visitor: V) -> Result<Self::Value, V::Error>
where
V: MapAccess<'de>,
{
ContentVisitor::new()
.visit_map(visitor)
.map(TagOrContent::Content)
}
fn visit_enum<V>(self, visitor: V) -> Result<Self::Value, V::Error>
where
V: EnumAccess<'de>,
{
ContentVisitor::new()
.visit_enum(visitor)
.map(TagOrContent::Content)
}
}
/// Used by generated code to deserialize an internally tagged enum.
///
/// Captures map or sequence from the original deserializer and searches
/// a tag in it (in case of sequence, tag is the first element of sequence).
///
/// Not public API.
pub struct TaggedContentVisitor<T> {
tag_name: &'static str,
expecting: &'static str,
value: PhantomData<T>,
}
impl<T> TaggedContentVisitor<T> {
/// Visitor for the content of an internally tagged enum with the given
/// tag name.
pub fn new(name: &'static str, expecting: &'static str) -> Self {
TaggedContentVisitor {
tag_name: name,
expecting,
value: PhantomData,
}
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de, T> Visitor<'de> for TaggedContentVisitor<T>
where
T: Deserialize<'de>,
{
type Value = (T, Content<'de>);
fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.write_str(self.expecting)
}
fn visit_seq<S>(self, mut seq: S) -> Result<Self::Value, S::Error>
where
S: SeqAccess<'de>,
{
let tag = match tri!(seq.next_element()) {
Some(tag) => tag,
None => {
return Err(de::Error::missing_field(self.tag_name));
}
};
let rest = de::value::SeqAccessDeserializer::new(seq);
Ok((tag, tri!(ContentVisitor::new().deserialize(rest))))
}
fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
where
M: MapAccess<'de>,
{
let mut tag = None;
let mut vec = Vec::<(Content, Content)>::with_capacity(size_hint::cautious::<(
Content,
Content,
)>(map.size_hint()));
while let Some(k) = tri!(map.next_key_seed(TagOrContentVisitor::new(self.tag_name))) {
match k {
TagOrContent::Tag => {
if tag.is_some() {
return Err(de::Error::duplicate_field(self.tag_name));
}
tag = Some(tri!(map.next_value()));
}
TagOrContent::Content(k) => {
let v = tri!(map.next_value_seed(ContentVisitor::new()));
vec.push((k, v));
}
}
}
match tag {
None => Err(de::Error::missing_field(self.tag_name)),
Some(tag) => Ok((tag, Content::Map(vec))),
}
}
}
/// Used by generated code to deserialize an adjacently tagged enum.
///
/// Not public API.
pub enum TagOrContentField {
Tag,
Content,
}
/// Not public API.
pub struct TagOrContentFieldVisitor {
/// Name of the tag field of the adjacently tagged enum
pub tag: &'static str,
/// Name of the content field of the adjacently tagged enum
pub content: &'static str,
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de> DeserializeSeed<'de> for TagOrContentFieldVisitor {
type Value = TagOrContentField;
fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
where
D: Deserializer<'de>,
{
deserializer.deserialize_identifier(self)
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de> Visitor<'de> for TagOrContentFieldVisitor {
type Value = TagOrContentField;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(formatter, "{:?} or {:?}", self.tag, self.content)
}
fn visit_u64<E>(self, field_index: u64) -> Result<Self::Value, E>
where
E: de::Error,
{
match field_index {
0 => Ok(TagOrContentField::Tag),
1 => Ok(TagOrContentField::Content),
_ => Err(de::Error::invalid_value(
Unexpected::Unsigned(field_index),
&self,
)),
}
}
fn visit_str<E>(self, field: &str) -> Result<Self::Value, E>
where
E: de::Error,
{
if field == self.tag {
Ok(TagOrContentField::Tag)
} else if field == self.content {
Ok(TagOrContentField::Content)
} else {
Err(de::Error::invalid_value(Unexpected::Str(field), &self))
}
}
fn visit_bytes<E>(self, field: &[u8]) -> Result<Self::Value, E>
where
E: de::Error,
{
if field == self.tag.as_bytes() {
Ok(TagOrContentField::Tag)
} else if field == self.content.as_bytes() {
Ok(TagOrContentField::Content)
} else {
Err(de::Error::invalid_value(Unexpected::Bytes(field), &self))
}
}
}
/// Used by generated code to deserialize an adjacently tagged enum when
/// ignoring unrelated fields is allowed.
///
/// Not public API.
pub enum TagContentOtherField {
Tag,
Content,
Other,
}
/// Not public API.
pub struct TagContentOtherFieldVisitor {
/// Name of the tag field of the adjacently tagged enum
pub tag: &'static str,
/// Name of the content field of the adjacently tagged enum
pub content: &'static str,
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de> DeserializeSeed<'de> for TagContentOtherFieldVisitor {
type Value = TagContentOtherField;
fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
where
D: Deserializer<'de>,
{
deserializer.deserialize_identifier(self)
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de> Visitor<'de> for TagContentOtherFieldVisitor {
type Value = TagContentOtherField;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(
formatter,
"{:?}, {:?}, or other ignored fields",
self.tag, self.content
)
}
fn visit_u64<E>(self, field_index: u64) -> Result<Self::Value, E>
where
E: de::Error,
{
match field_index {
0 => Ok(TagContentOtherField::Tag),
1 => Ok(TagContentOtherField::Content),
_ => Ok(TagContentOtherField::Other),
}
}
fn visit_str<E>(self, field: &str) -> Result<Self::Value, E>
where
E: de::Error,
{
self.visit_bytes(field.as_bytes())
}
fn visit_bytes<E>(self, field: &[u8]) -> Result<Self::Value, E>
where
E: de::Error,
{
if field == self.tag.as_bytes() {
Ok(TagContentOtherField::Tag)
} else if field == self.content.as_bytes() {
Ok(TagContentOtherField::Content)
} else {
Ok(TagContentOtherField::Other)
}
}
}
/// Not public API
pub struct ContentDeserializer<'de, E> {
content: Content<'de>,
err: PhantomData<E>,
}
impl<'de, E> ContentDeserializer<'de, E>
where
E: de::Error,
{
#[cold]
fn invalid_type(self, exp: &dyn Expected) -> E {
de::Error::invalid_type(content_unexpected(&self.content), exp)
}
fn deserialize_integer<V>(self, visitor: V) -> Result<V::Value, E>
where
V: Visitor<'de>,
{
match self.content {
Content::U8(v) => visitor.visit_u8(v),
Content::U16(v) => visitor.visit_u16(v),
Content::U32(v) => visitor.visit_u32(v),
Content::U64(v) => visitor.visit_u64(v),
Content::I8(v) => visitor.visit_i8(v),
Content::I16(v) => visitor.visit_i16(v),
Content::I32(v) => visitor.visit_i32(v),
Content::I64(v) => visitor.visit_i64(v),
_ => Err(self.invalid_type(&visitor)),
}
}
fn deserialize_float<V>(self, visitor: V) -> Result<V::Value, E>
where
V: Visitor<'de>,
{
match self.content {
Content::F32(v) => visitor.visit_f32(v),
Content::F64(v) => visitor.visit_f64(v),
Content::U8(v) => visitor.visit_u8(v),
Content::U16(v) => visitor.visit_u16(v),
Content::U32(v) => visitor.visit_u32(v),
Content::U64(v) => visitor.visit_u64(v),
Content::I8(v) => visitor.visit_i8(v),
Content::I16(v) => visitor.visit_i16(v),
Content::I32(v) => visitor.visit_i32(v),
Content::I64(v) => visitor.visit_i64(v),
_ => Err(self.invalid_type(&visitor)),
}
}
}
fn visit_content_seq<'de, V, E>(content: Vec<Content<'de>>, visitor: V) -> Result<V::Value, E>
where
V: Visitor<'de>,
E: de::Error,
{
let mut seq_visitor = SeqDeserializer::new(content);
let value = tri!(visitor.visit_seq(&mut seq_visitor));
tri!(seq_visitor.end());
Ok(value)
}
fn visit_content_map<'de, V, E>(
content: Vec<(Content<'de>, Content<'de>)>,
visitor: V,
) -> Result<V::Value, E>
where
V: Visitor<'de>,
E: de::Error,
{
let mut map_visitor = MapDeserializer::new(content);
let value = tri!(visitor.visit_map(&mut map_visitor));
tri!(map_visitor.end());
Ok(value)
}
/// Used when deserializing an internally tagged enum because the content
/// will be used exactly once.
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de, E> Deserializer<'de> for ContentDeserializer<'de, E>
where
E: de::Error,
{
type Error = E;
fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
match self.content {
Content::Bool(v) => visitor.visit_bool(v),
Content::U8(v) => visitor.visit_u8(v),
Content::U16(v) => visitor.visit_u16(v),
Content::U32(v) => visitor.visit_u32(v),
Content::U64(v) => visitor.visit_u64(v),
Content::I8(v) => visitor.visit_i8(v),
Content::I16(v) => visitor.visit_i16(v),
Content::I32(v) => visitor.visit_i32(v),
Content::I64(v) => visitor.visit_i64(v),
Content::F32(v) => visitor.visit_f32(v),
Content::F64(v) => visitor.visit_f64(v),
Content::Char(v) => visitor.visit_char(v),
Content::String(v) => visitor.visit_string(v),
Content::Str(v) => visitor.visit_borrowed_str(v),
Content::ByteBuf(v) => visitor.visit_byte_buf(v),
Content::Bytes(v) => visitor.visit_borrowed_bytes(v),
Content::Unit => visitor.visit_unit(),
Content::None => visitor.visit_none(),
Content::Some(v) => visitor.visit_some(ContentDeserializer::new(*v)),
Content::Newtype(v) => visitor.visit_newtype_struct(ContentDeserializer::new(*v)),
Content::Seq(v) => visit_content_seq(v, visitor),
Content::Map(v) => visit_content_map(v, visitor),
}
}
fn deserialize_bool<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
match self.content {
Content::Bool(v) => visitor.visit_bool(v),
_ => Err(self.invalid_type(&visitor)),
}
}
fn deserialize_i8<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_integer(visitor)
}
fn deserialize_i16<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_integer(visitor)
}
fn deserialize_i32<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_integer(visitor)
}
fn deserialize_i64<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_integer(visitor)
}
fn deserialize_u8<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_integer(visitor)
}
fn deserialize_u16<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_integer(visitor)
}
fn deserialize_u32<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_integer(visitor)
}
fn deserialize_u64<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_integer(visitor)
}
fn deserialize_f32<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_float(visitor)
}
fn deserialize_f64<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_float(visitor)
}
fn deserialize_char<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
match self.content {
Content::Char(v) => visitor.visit_char(v),
Content::String(v) => visitor.visit_string(v),
Content::Str(v) => visitor.visit_borrowed_str(v),
_ => Err(self.invalid_type(&visitor)),
}
}
fn deserialize_str<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_string(visitor)
}
fn deserialize_string<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
match self.content {
Content::String(v) => visitor.visit_string(v),
Content::Str(v) => visitor.visit_borrowed_str(v),
Content::ByteBuf(v) => visitor.visit_byte_buf(v),
Content::Bytes(v) => visitor.visit_borrowed_bytes(v),
_ => Err(self.invalid_type(&visitor)),
}
}
fn deserialize_bytes<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_byte_buf(visitor)
}
fn deserialize_byte_buf<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
match self.content {
Content::String(v) => visitor.visit_string(v),
Content::Str(v) => visitor.visit_borrowed_str(v),
Content::ByteBuf(v) => visitor.visit_byte_buf(v),
Content::Bytes(v) => visitor.visit_borrowed_bytes(v),
Content::Seq(v) => visit_content_seq(v, visitor),
_ => Err(self.invalid_type(&visitor)),
}
}
fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
match self.content {
Content::None => visitor.visit_none(),
Content::Some(v) => visitor.visit_some(ContentDeserializer::new(*v)),
Content::Unit => visitor.visit_unit(),
_ => visitor.visit_some(self),
}
}
fn deserialize_unit<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
match self.content {
Content::Unit => visitor.visit_unit(),
// Allow deserializing newtype variant containing unit.
//
// #[derive(Deserialize)]
// #[serde(tag = "result")]
// enum Response<T> {
// Success(T),
// }
//
// We want {"result":"Success"} to deserialize into Response<()>.
Content::Map(ref v) if v.is_empty() => visitor.visit_unit(),
_ => Err(self.invalid_type(&visitor)),
}
}
fn deserialize_unit_struct<V>(
self,
_name: &'static str,
visitor: V,
) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
match self.content {
// As a special case, allow deserializing untagged newtype
// variant containing unit struct.
//
// #[derive(Deserialize)]
// struct Info;
//
// #[derive(Deserialize)]
// #[serde(tag = "topic")]
// enum Message {
// Info(Info),
// }
//
// We want {"topic":"Info"} to deserialize even though
// ordinarily unit structs do not deserialize from empty map/seq.
Content::Map(ref v) if v.is_empty() => visitor.visit_unit(),
Content::Seq(ref v) if v.is_empty() => visitor.visit_unit(),
_ => self.deserialize_any(visitor),
}
}
fn deserialize_newtype_struct<V>(
self,
_name: &str,
visitor: V,
) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
match self.content {
Content::Newtype(v) => visitor.visit_newtype_struct(ContentDeserializer::new(*v)),
_ => visitor.visit_newtype_struct(self),
}
}
fn deserialize_seq<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
match self.content {
Content::Seq(v) => visit_content_seq(v, visitor),
_ => Err(self.invalid_type(&visitor)),
}
}
fn deserialize_tuple<V>(self, _len: usize, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_seq(visitor)
}
fn deserialize_tuple_struct<V>(
self,
_name: &'static str,
_len: usize,
visitor: V,
) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_seq(visitor)
}
fn deserialize_map<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
match self.content {
Content::Map(v) => visit_content_map(v, visitor),
_ => Err(self.invalid_type(&visitor)),
}
}
fn deserialize_struct<V>(
self,
_name: &'static str,
_fields: &'static [&'static str],
visitor: V,
) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
match self.content {
Content::Seq(v) => visit_content_seq(v, visitor),
Content::Map(v) => visit_content_map(v, visitor),
_ => Err(self.invalid_type(&visitor)),
}
}
fn deserialize_enum<V>(
self,
_name: &str,
_variants: &'static [&'static str],
visitor: V,
) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
let (variant, value) = match self.content {
Content::Map(value) => {
let mut iter = value.into_iter();
let (variant, value) = match iter.next() {
Some(v) => v,
None => {
return Err(de::Error::invalid_value(
de::Unexpected::Map,
&"map with a single key",
));
}
};
// enums are encoded in json as maps with a single key:value pair
if iter.next().is_some() {
return Err(de::Error::invalid_value(
de::Unexpected::Map,
&"map with a single key",
));
}
(variant, Some(value))
}
s @ Content::String(_) | s @ Content::Str(_) => (s, None),
other => {
return Err(de::Error::invalid_type(
content_unexpected(&other),
&"string or map",
));
}
};
visitor.visit_enum(EnumDeserializer::new(variant, value))
}
fn deserialize_identifier<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
match self.content {
Content::String(v) => visitor.visit_string(v),
Content::Str(v) => visitor.visit_borrowed_str(v),
Content::ByteBuf(v) => visitor.visit_byte_buf(v),
Content::Bytes(v) => visitor.visit_borrowed_bytes(v),
Content::U8(v) => visitor.visit_u8(v),
Content::U64(v) => visitor.visit_u64(v),
_ => Err(self.invalid_type(&visitor)),
}
}
fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
drop(self);
visitor.visit_unit()
}
fn __deserialize_content_v1<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de, Value = Content<'de>>,
{
let _ = visitor;
Ok(self.content)
}
}
impl<'de, E> ContentDeserializer<'de, E> {
/// private API, don't use
pub fn new(content: Content<'de>) -> Self {
ContentDeserializer {
content,
err: PhantomData,
}
}
}
struct SeqDeserializer<'de, E> {
iter: <Vec<Content<'de>> as IntoIterator>::IntoIter,
count: usize,
marker: PhantomData<E>,
}
impl<'de, E> SeqDeserializer<'de, E> {
fn new(content: Vec<Content<'de>>) -> Self {
SeqDeserializer {
iter: content.into_iter(),
count: 0,
marker: PhantomData,
}
}
}
impl<'de, E> SeqDeserializer<'de, E>
where
E: de::Error,
{
fn end(self) -> Result<(), E> {
let remaining = self.iter.count();
if remaining == 0 {
Ok(())
} else {
// First argument is the number of elements in the data, second
// argument is the number of elements expected by the Deserialize.
Err(de::Error::invalid_length(
self.count + remaining,
&ExpectedInSeq(self.count),
))
}
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de, E> Deserializer<'de> for SeqDeserializer<'de, E>
where
E: de::Error,
{
type Error = E;
fn deserialize_any<V>(mut self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
let v = tri!(visitor.visit_seq(&mut self));
tri!(self.end());
Ok(v)
}
serde_core::forward_to_deserialize_any! {
bool i8 i16 i32 i64 i128 u8 u16 u32 u64 u128 f32 f64 char str string
bytes byte_buf option unit unit_struct newtype_struct seq tuple
tuple_struct map struct enum identifier ignored_any
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de, E> SeqAccess<'de> for SeqDeserializer<'de, E>
where
E: de::Error,
{
type Error = E;
fn next_element_seed<V>(&mut self, seed: V) -> Result<Option<V::Value>, Self::Error>
where
V: DeserializeSeed<'de>,
{
match self.iter.next() {
Some(value) => {
self.count += 1;
seed.deserialize(ContentDeserializer::new(value)).map(Some)
}
None => Ok(None),
}
}
fn size_hint(&self) -> Option<usize> {
size_hint::from_bounds(&self.iter)
}
}
struct ExpectedInSeq(usize);
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl Expected for ExpectedInSeq {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
if self.0 == 1 {
formatter.write_str("1 element in sequence")
} else {
write!(formatter, "{} elements in sequence", self.0)
}
}
}
struct MapDeserializer<'de, E> {
iter: <Vec<(Content<'de>, Content<'de>)> as IntoIterator>::IntoIter,
value: Option<Content<'de>>,
count: usize,
error: PhantomData<E>,
}
impl<'de, E> MapDeserializer<'de, E> {
fn new(content: Vec<(Content<'de>, Content<'de>)>) -> Self {
MapDeserializer {
iter: content.into_iter(),
value: None,
count: 0,
error: PhantomData,
}
}
}
impl<'de, E> MapDeserializer<'de, E>
where
E: de::Error,
{
fn end(self) -> Result<(), E> {
let remaining = self.iter.count();
if remaining == 0 {
Ok(())
} else {
// First argument is the number of elements in the data, second
// argument is the number of elements expected by the Deserialize.
Err(de::Error::invalid_length(
self.count + remaining,
&ExpectedInMap(self.count),
))
}
}
}
impl<'de, E> MapDeserializer<'de, E> {
fn next_pair(&mut self) -> Option<(Content<'de>, Content<'de>)> {
match self.iter.next() {
Some((k, v)) => {
self.count += 1;
Some((k, v))
}
None => None,
}
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de, E> Deserializer<'de> for MapDeserializer<'de, E>
where
E: de::Error,
{
type Error = E;
fn deserialize_any<V>(mut self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
let value = tri!(visitor.visit_map(&mut self));
tri!(self.end());
Ok(value)
}
fn deserialize_seq<V>(mut self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
let value = tri!(visitor.visit_seq(&mut self));
tri!(self.end());
Ok(value)
}
fn deserialize_tuple<V>(self, len: usize, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
let _ = len;
self.deserialize_seq(visitor)
}
serde_core::forward_to_deserialize_any! {
bool i8 i16 i32 i64 i128 u8 u16 u32 u64 u128 f32 f64 char str string
bytes byte_buf option unit unit_struct newtype_struct tuple_struct map
struct enum identifier ignored_any
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de, E> MapAccess<'de> for MapDeserializer<'de, E>
where
E: de::Error,
{
type Error = E;
fn next_key_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
where
T: DeserializeSeed<'de>,
{
match self.next_pair() {
Some((key, value)) => {
self.value = Some(value);
seed.deserialize(ContentDeserializer::new(key)).map(Some)
}
None => Ok(None),
}
}
fn next_value_seed<T>(&mut self, seed: T) -> Result<T::Value, Self::Error>
where
T: DeserializeSeed<'de>,
{
let value = self.value.take();
// Panic because this indicates a bug in the program rather than an
// expected failure.
let value = value.expect("MapAccess::next_value called before next_key");
seed.deserialize(ContentDeserializer::new(value))
}
fn next_entry_seed<TK, TV>(
&mut self,
kseed: TK,
vseed: TV,
) -> Result<Option<(TK::Value, TV::Value)>, Self::Error>
where
TK: DeserializeSeed<'de>,
TV: DeserializeSeed<'de>,
{
match self.next_pair() {
Some((key, value)) => {
let key = tri!(kseed.deserialize(ContentDeserializer::new(key)));
let value = tri!(vseed.deserialize(ContentDeserializer::new(value)));
Ok(Some((key, value)))
}
None => Ok(None),
}
}
fn size_hint(&self) -> Option<usize> {
size_hint::from_bounds(&self.iter)
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de, E> SeqAccess<'de> for MapDeserializer<'de, E>
where
E: de::Error,
{
type Error = E;
fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
where
T: de::DeserializeSeed<'de>,
{
match self.next_pair() {
Some((k, v)) => {
let de = PairDeserializer(k, v, PhantomData);
seed.deserialize(de).map(Some)
}
None => Ok(None),
}
}
fn size_hint(&self) -> Option<usize> {
size_hint::from_bounds(&self.iter)
}
}
struct PairDeserializer<'de, E>(Content<'de>, Content<'de>, PhantomData<E>);
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de, E> Deserializer<'de> for PairDeserializer<'de, E>
where
E: de::Error,
{
type Error = E;
serde_core::forward_to_deserialize_any! {
bool i8 i16 i32 i64 i128 u8 u16 u32 u64 u128 f32 f64 char str string
bytes byte_buf option unit unit_struct newtype_struct tuple_struct map
struct enum identifier ignored_any
}
fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_seq(visitor)
}
fn deserialize_seq<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
let mut pair_visitor = PairVisitor(Some(self.0), Some(self.1), PhantomData);
let pair = tri!(visitor.visit_seq(&mut pair_visitor));
if pair_visitor.1.is_none() {
Ok(pair)
} else {
let remaining = pair_visitor.size_hint().unwrap();
// First argument is the number of elements in the data, second
// argument is the number of elements expected by the Deserialize.
Err(de::Error::invalid_length(2, &ExpectedInSeq(2 - remaining)))
}
}
fn deserialize_tuple<V>(self, len: usize, visitor: V) -> Result<V::Value, Self::Error>
where
V: de::Visitor<'de>,
{
if len == 2 {
self.deserialize_seq(visitor)
} else {
// First argument is the number of elements in the data, second
// argument is the number of elements expected by the Deserialize.
Err(de::Error::invalid_length(2, &ExpectedInSeq(len)))
}
}
}
struct PairVisitor<'de, E>(Option<Content<'de>>, Option<Content<'de>>, PhantomData<E>);
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de, E> SeqAccess<'de> for PairVisitor<'de, E>
where
E: de::Error,
{
type Error = E;
fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
where
T: DeserializeSeed<'de>,
{
if let Some(k) = self.0.take() {
seed.deserialize(ContentDeserializer::new(k)).map(Some)
} else if let Some(v) = self.1.take() {
seed.deserialize(ContentDeserializer::new(v)).map(Some)
} else {
Ok(None)
}
}
fn size_hint(&self) -> Option<usize> {
if self.0.is_some() {
Some(2)
} else if self.1.is_some() {
Some(1)
} else {
Some(0)
}
}
}
struct ExpectedInMap(usize);
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl Expected for ExpectedInMap {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
if self.0 == 1 {
formatter.write_str("1 element in map")
} else {
write!(formatter, "{} elements in map", self.0)
}
}
}
pub struct EnumDeserializer<'de, E>
where
E: de::Error,
{
variant: Content<'de>,
value: Option<Content<'de>>,
err: PhantomData<E>,
}
impl<'de, E> EnumDeserializer<'de, E>
where
E: de::Error,
{
pub fn new(variant: Content<'de>, value: Option<Content<'de>>) -> EnumDeserializer<'de, E> {
EnumDeserializer {
variant,
value,
err: PhantomData,
}
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de, E> de::EnumAccess<'de> for EnumDeserializer<'de, E>
where
E: de::Error,
{
type Error = E;
type Variant = VariantDeserializer<'de, Self::Error>;
fn variant_seed<V>(self, seed: V) -> Result<(V::Value, Self::Variant), E>
where
V: de::DeserializeSeed<'de>,
{
let visitor = VariantDeserializer {
value: self.value,
err: PhantomData,
};
seed.deserialize(ContentDeserializer::new(self.variant))
.map(|v| (v, visitor))
}
}
pub struct VariantDeserializer<'de, E>
where
E: de::Error,
{
value: Option<Content<'de>>,
err: PhantomData<E>,
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de, E> de::VariantAccess<'de> for VariantDeserializer<'de, E>
where
E: de::Error,
{
type Error = E;
fn unit_variant(self) -> Result<(), E> {
match self.value {
Some(value) => de::Deserialize::deserialize(ContentDeserializer::new(value)),
None => Ok(()),
}
}
fn newtype_variant_seed<T>(self, seed: T) -> Result<T::Value, E>
where
T: de::DeserializeSeed<'de>,
{
match self.value {
Some(value) => seed.deserialize(ContentDeserializer::new(value)),
None => Err(de::Error::invalid_type(
de::Unexpected::UnitVariant,
&"newtype variant",
)),
}
}
fn tuple_variant<V>(self, _len: usize, visitor: V) -> Result<V::Value, Self::Error>
where
V: de::Visitor<'de>,
{
match self.value {
Some(Content::Seq(v)) => {
de::Deserializer::deserialize_any(SeqDeserializer::new(v), visitor)
}
Some(other) => Err(de::Error::invalid_type(
content_unexpected(&other),
&"tuple variant",
)),
None => Err(de::Error::invalid_type(
de::Unexpected::UnitVariant,
&"tuple variant",
)),
}
}
fn struct_variant<V>(
self,
_fields: &'static [&'static str],
visitor: V,
) -> Result<V::Value, Self::Error>
where
V: de::Visitor<'de>,
{
match self.value {
Some(Content::Map(v)) => {
de::Deserializer::deserialize_any(MapDeserializer::new(v), visitor)
}
Some(Content::Seq(v)) => {
de::Deserializer::deserialize_any(SeqDeserializer::new(v), visitor)
}
Some(other) => Err(de::Error::invalid_type(
content_unexpected(&other),
&"struct variant",
)),
None => Err(de::Error::invalid_type(
de::Unexpected::UnitVariant,
&"struct variant",
)),
}
}
}
/// Not public API.
pub struct ContentRefDeserializer<'a, 'de: 'a, E> {
content: &'a Content<'de>,
err: PhantomData<E>,
}
impl<'a, 'de, E> ContentRefDeserializer<'a, 'de, E>
where
E: de::Error,
{
#[cold]
fn invalid_type(self, exp: &dyn Expected) -> E {
de::Error::invalid_type(content_unexpected(self.content), exp)
}
fn deserialize_integer<V>(self, visitor: V) -> Result<V::Value, E>
where
V: Visitor<'de>,
{
match *self.content {
Content::U8(v) => visitor.visit_u8(v),
Content::U16(v) => visitor.visit_u16(v),
Content::U32(v) => visitor.visit_u32(v),
Content::U64(v) => visitor.visit_u64(v),
Content::I8(v) => visitor.visit_i8(v),
Content::I16(v) => visitor.visit_i16(v),
Content::I32(v) => visitor.visit_i32(v),
Content::I64(v) => visitor.visit_i64(v),
_ => Err(self.invalid_type(&visitor)),
}
}
fn deserialize_float<V>(self, visitor: V) -> Result<V::Value, E>
where
V: Visitor<'de>,
{
match *self.content {
Content::F32(v) => visitor.visit_f32(v),
Content::F64(v) => visitor.visit_f64(v),
Content::U8(v) => visitor.visit_u8(v),
Content::U16(v) => visitor.visit_u16(v),
Content::U32(v) => visitor.visit_u32(v),
Content::U64(v) => visitor.visit_u64(v),
Content::I8(v) => visitor.visit_i8(v),
Content::I16(v) => visitor.visit_i16(v),
Content::I32(v) => visitor.visit_i32(v),
Content::I64(v) => visitor.visit_i64(v),
_ => Err(self.invalid_type(&visitor)),
}
}
}
fn visit_content_seq_ref<'a, 'de, V, E>(
content: &'a [Content<'de>],
visitor: V,
) -> Result<V::Value, E>
where
V: Visitor<'de>,
E: de::Error,
{
let mut seq_visitor = SeqRefDeserializer::new(content);
let value = tri!(visitor.visit_seq(&mut seq_visitor));
tri!(seq_visitor.end());
Ok(value)
}
fn visit_content_map_ref<'a, 'de, V, E>(
content: &'a [(Content<'de>, Content<'de>)],
visitor: V,
) -> Result<V::Value, E>
where
V: Visitor<'de>,
E: de::Error,
{
let mut map_visitor = MapRefDeserializer::new(content);
let value = tri!(visitor.visit_map(&mut map_visitor));
tri!(map_visitor.end());
Ok(value)
}
/// Used when deserializing an untagged enum because the content may need
/// to be used more than once.
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de, 'a, E> Deserializer<'de> for ContentRefDeserializer<'a, 'de, E>
where
E: de::Error,
{
type Error = E;
fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, E>
where
V: Visitor<'de>,
{
match *self.content {
Content::Bool(v) => visitor.visit_bool(v),
Content::U8(v) => visitor.visit_u8(v),
Content::U16(v) => visitor.visit_u16(v),
Content::U32(v) => visitor.visit_u32(v),
Content::U64(v) => visitor.visit_u64(v),
Content::I8(v) => visitor.visit_i8(v),
Content::I16(v) => visitor.visit_i16(v),
Content::I32(v) => visitor.visit_i32(v),
Content::I64(v) => visitor.visit_i64(v),
Content::F32(v) => visitor.visit_f32(v),
Content::F64(v) => visitor.visit_f64(v),
Content::Char(v) => visitor.visit_char(v),
Content::String(ref v) => visitor.visit_str(v),
Content::Str(v) => visitor.visit_borrowed_str(v),
Content::ByteBuf(ref v) => visitor.visit_bytes(v),
Content::Bytes(v) => visitor.visit_borrowed_bytes(v),
Content::Unit => visitor.visit_unit(),
Content::None => visitor.visit_none(),
Content::Some(ref v) => visitor.visit_some(ContentRefDeserializer::new(v)),
Content::Newtype(ref v) => {
visitor.visit_newtype_struct(ContentRefDeserializer::new(v))
}
Content::Seq(ref v) => visit_content_seq_ref(v, visitor),
Content::Map(ref v) => visit_content_map_ref(v, visitor),
}
}
fn deserialize_bool<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
match *self.content {
Content::Bool(v) => visitor.visit_bool(v),
_ => Err(self.invalid_type(&visitor)),
}
}
fn deserialize_i8<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_integer(visitor)
}
fn deserialize_i16<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_integer(visitor)
}
fn deserialize_i32<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_integer(visitor)
}
fn deserialize_i64<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_integer(visitor)
}
fn deserialize_u8<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_integer(visitor)
}
fn deserialize_u16<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_integer(visitor)
}
fn deserialize_u32<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_integer(visitor)
}
fn deserialize_u64<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_integer(visitor)
}
fn deserialize_f32<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_float(visitor)
}
fn deserialize_f64<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_float(visitor)
}
fn deserialize_char<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
match *self.content {
Content::Char(v) => visitor.visit_char(v),
Content::String(ref v) => visitor.visit_str(v),
Content::Str(v) => visitor.visit_borrowed_str(v),
_ => Err(self.invalid_type(&visitor)),
}
}
fn deserialize_str<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
match *self.content {
Content::String(ref v) => visitor.visit_str(v),
Content::Str(v) => visitor.visit_borrowed_str(v),
Content::ByteBuf(ref v) => visitor.visit_bytes(v),
Content::Bytes(v) => visitor.visit_borrowed_bytes(v),
_ => Err(self.invalid_type(&visitor)),
}
}
fn deserialize_string<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_str(visitor)
}
fn deserialize_bytes<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
match *self.content {
Content::String(ref v) => visitor.visit_str(v),
Content::Str(v) => visitor.visit_borrowed_str(v),
Content::ByteBuf(ref v) => visitor.visit_bytes(v),
Content::Bytes(v) => visitor.visit_borrowed_bytes(v),
Content::Seq(ref v) => visit_content_seq_ref(v, visitor),
_ => Err(self.invalid_type(&visitor)),
}
}
fn deserialize_byte_buf<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_bytes(visitor)
}
fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, E>
where
V: Visitor<'de>,
{
// Covered by tests/test_enum_untagged.rs
// with_optional_field::*
match *self.content {
Content::None => visitor.visit_none(),
Content::Some(ref v) => visitor.visit_some(ContentRefDeserializer::new(v)),
Content::Unit => visitor.visit_unit(),
// This case is to support data formats which do not encode an
// indication whether a value is optional. An example of such a
// format is JSON, and a counterexample is RON. When requesting
// `deserialize_any` in JSON, the data format never performs
// `Visitor::visit_some` but we still must be able to
// deserialize the resulting Content into data structures with
// optional fields.
_ => visitor.visit_some(self),
}
}
fn deserialize_unit<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
match *self.content {
Content::Unit => visitor.visit_unit(),
_ => Err(self.invalid_type(&visitor)),
}
}
fn deserialize_unit_struct<V>(
self,
_name: &'static str,
visitor: V,
) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_unit(visitor)
}
fn deserialize_newtype_struct<V>(self, _name: &str, visitor: V) -> Result<V::Value, E>
where
V: Visitor<'de>,
{
// Covered by tests/test_enum_untagged.rs
// newtype_struct
match *self.content {
Content::Newtype(ref v) => {
visitor.visit_newtype_struct(ContentRefDeserializer::new(v))
}
// This case is to support data formats that encode newtype
// structs and their underlying data the same, with no
// indication whether a newtype wrapper was present. For example
// JSON does this, while RON does not. In RON a newtype's name
// is included in the serialized representation and it knows to
// call `Visitor::visit_newtype_struct` from `deserialize_any`.
// JSON's `deserialize_any` never calls `visit_newtype_struct`
// but in this code we still must be able to deserialize the
// resulting Content into newtypes.
_ => visitor.visit_newtype_struct(self),
}
}
fn deserialize_seq<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
match *self.content {
Content::Seq(ref v) => visit_content_seq_ref(v, visitor),
_ => Err(self.invalid_type(&visitor)),
}
}
fn deserialize_tuple<V>(self, _len: usize, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_seq(visitor)
}
fn deserialize_tuple_struct<V>(
self,
_name: &'static str,
_len: usize,
visitor: V,
) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_seq(visitor)
}
fn deserialize_map<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
match *self.content {
Content::Map(ref v) => visit_content_map_ref(v, visitor),
_ => Err(self.invalid_type(&visitor)),
}
}
fn deserialize_struct<V>(
self,
_name: &'static str,
_fields: &'static [&'static str],
visitor: V,
) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
match *self.content {
Content::Seq(ref v) => visit_content_seq_ref(v, visitor),
Content::Map(ref v) => visit_content_map_ref(v, visitor),
_ => Err(self.invalid_type(&visitor)),
}
}
fn deserialize_enum<V>(
self,
_name: &str,
_variants: &'static [&'static str],
visitor: V,
) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
let (variant, value) = match *self.content {
Content::Map(ref value) => {
let mut iter = value.iter();
let (variant, value) = match iter.next() {
Some(v) => v,
None => {
return Err(de::Error::invalid_value(
de::Unexpected::Map,
&"map with a single key",
));
}
};
// enums are encoded in json as maps with a single key:value pair
if iter.next().is_some() {
return Err(de::Error::invalid_value(
de::Unexpected::Map,
&"map with a single key",
));
}
(variant, Some(value))
}
ref s @ Content::String(_) | ref s @ Content::Str(_) => (s, None),
ref other => {
return Err(de::Error::invalid_type(
content_unexpected(other),
&"string or map",
));
}
};
visitor.visit_enum(EnumRefDeserializer {
variant,
value,
err: PhantomData,
})
}
fn deserialize_identifier<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
match *self.content {
Content::String(ref v) => visitor.visit_str(v),
Content::Str(v) => visitor.visit_borrowed_str(v),
Content::ByteBuf(ref v) => visitor.visit_bytes(v),
Content::Bytes(v) => visitor.visit_borrowed_bytes(v),
Content::U8(v) => visitor.visit_u8(v),
Content::U64(v) => visitor.visit_u64(v),
_ => Err(self.invalid_type(&visitor)),
}
}
fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
visitor.visit_unit()
}
fn __deserialize_content_v1<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de, Value = Content<'de>>,
{
let _ = visitor;
Ok(content_clone(self.content))
}
}
impl<'a, 'de, E> ContentRefDeserializer<'a, 'de, E> {
/// private API, don't use
pub fn new(content: &'a Content<'de>) -> Self {
ContentRefDeserializer {
content,
err: PhantomData,
}
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'a, 'de: 'a, E> Copy for ContentRefDeserializer<'a, 'de, E> {}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'a, 'de: 'a, E> Clone for ContentRefDeserializer<'a, 'de, E> {
fn clone(&self) -> Self {
*self
}
}
struct SeqRefDeserializer<'a, 'de, E> {
iter: <&'a [Content<'de>] as IntoIterator>::IntoIter,
count: usize,
marker: PhantomData<E>,
}
impl<'a, 'de, E> SeqRefDeserializer<'a, 'de, E> {
fn new(content: &'a [Content<'de>]) -> Self {
SeqRefDeserializer {
iter: content.iter(),
count: 0,
marker: PhantomData,
}
}
}
impl<'a, 'de, E> SeqRefDeserializer<'a, 'de, E>
where
E: de::Error,
{
fn end(self) -> Result<(), E> {
let remaining = self.iter.count();
if remaining == 0 {
Ok(())
} else {
// First argument is the number of elements in the data, second
// argument is the number of elements expected by the Deserialize.
Err(de::Error::invalid_length(
self.count + remaining,
&ExpectedInSeq(self.count),
))
}
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'a, 'de, E> Deserializer<'de> for SeqRefDeserializer<'a, 'de, E>
where
E: de::Error,
{
type Error = E;
fn deserialize_any<V>(mut self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
let v = tri!(visitor.visit_seq(&mut self));
tri!(self.end());
Ok(v)
}
serde_core::forward_to_deserialize_any! {
bool i8 i16 i32 i64 i128 u8 u16 u32 u64 u128 f32 f64 char str string
bytes byte_buf option unit unit_struct newtype_struct seq tuple
tuple_struct map struct enum identifier ignored_any
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'a, 'de, E> SeqAccess<'de> for SeqRefDeserializer<'a, 'de, E>
where
E: de::Error,
{
type Error = E;
fn next_element_seed<V>(&mut self, seed: V) -> Result<Option<V::Value>, Self::Error>
where
V: DeserializeSeed<'de>,
{
match self.iter.next() {
Some(value) => {
self.count += 1;
seed.deserialize(ContentRefDeserializer::new(value))
.map(Some)
}
None => Ok(None),
}
}
fn size_hint(&self) -> Option<usize> {
size_hint::from_bounds(&self.iter)
}
}
struct MapRefDeserializer<'a, 'de, E> {
iter: <&'a [(Content<'de>, Content<'de>)] as IntoIterator>::IntoIter,
value: Option<&'a Content<'de>>,
count: usize,
error: PhantomData<E>,
}
impl<'a, 'de, E> MapRefDeserializer<'a, 'de, E> {
fn new(content: &'a [(Content<'de>, Content<'de>)]) -> Self {
MapRefDeserializer {
iter: content.iter(),
value: None,
count: 0,
error: PhantomData,
}
}
}
impl<'a, 'de, E> MapRefDeserializer<'a, 'de, E>
where
E: de::Error,
{
fn end(self) -> Result<(), E> {
let remaining = self.iter.count();
if remaining == 0 {
Ok(())
} else {
// First argument is the number of elements in the data, second
// argument is the number of elements expected by the Deserialize.
Err(de::Error::invalid_length(
self.count + remaining,
&ExpectedInMap(self.count),
))
}
}
}
impl<'a, 'de, E> MapRefDeserializer<'a, 'de, E> {
fn next_pair(&mut self) -> Option<(&'a Content<'de>, &'a Content<'de>)> {
match self.iter.next() {
Some((k, v)) => {
self.count += 1;
Some((k, v))
}
None => None,
}
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'a, 'de, E> Deserializer<'de> for MapRefDeserializer<'a, 'de, E>
where
E: de::Error,
{
type Error = E;
fn deserialize_any<V>(mut self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
let value = tri!(visitor.visit_map(&mut self));
tri!(self.end());
Ok(value)
}
fn deserialize_seq<V>(mut self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
let value = tri!(visitor.visit_seq(&mut self));
tri!(self.end());
Ok(value)
}
fn deserialize_tuple<V>(self, len: usize, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
let _ = len;
self.deserialize_seq(visitor)
}
serde_core::forward_to_deserialize_any! {
bool i8 i16 i32 i64 i128 u8 u16 u32 u64 u128 f32 f64 char str string
bytes byte_buf option unit unit_struct newtype_struct tuple_struct map
struct enum identifier ignored_any
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'a, 'de, E> MapAccess<'de> for MapRefDeserializer<'a, 'de, E>
where
E: de::Error,
{
type Error = E;
fn next_key_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
where
T: DeserializeSeed<'de>,
{
match self.next_pair() {
Some((key, value)) => {
self.value = Some(value);
seed.deserialize(ContentRefDeserializer::new(key)).map(Some)
}
None => Ok(None),
}
}
fn next_value_seed<T>(&mut self, seed: T) -> Result<T::Value, Self::Error>
where
T: DeserializeSeed<'de>,
{
let value = self.value.take();
// Panic because this indicates a bug in the program rather than an
// expected failure.
let value = value.expect("MapAccess::next_value called before next_key");
seed.deserialize(ContentRefDeserializer::new(value))
}
fn next_entry_seed<TK, TV>(
&mut self,
kseed: TK,
vseed: TV,
) -> Result<Option<(TK::Value, TV::Value)>, Self::Error>
where
TK: DeserializeSeed<'de>,
TV: DeserializeSeed<'de>,
{
match self.next_pair() {
Some((key, value)) => {
let key = tri!(kseed.deserialize(ContentRefDeserializer::new(key)));
let value = tri!(vseed.deserialize(ContentRefDeserializer::new(value)));
Ok(Some((key, value)))
}
None => Ok(None),
}
}
fn size_hint(&self) -> Option<usize> {
size_hint::from_bounds(&self.iter)
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'a, 'de, E> SeqAccess<'de> for MapRefDeserializer<'a, 'de, E>
where
E: de::Error,
{
type Error = E;
fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
where
T: de::DeserializeSeed<'de>,
{
match self.next_pair() {
Some((k, v)) => {
let de = PairRefDeserializer(k, v, PhantomData);
seed.deserialize(de).map(Some)
}
None => Ok(None),
}
}
fn size_hint(&self) -> Option<usize> {
size_hint::from_bounds(&self.iter)
}
}
struct PairRefDeserializer<'a, 'de, E>(&'a Content<'de>, &'a Content<'de>, PhantomData<E>);
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'a, 'de, E> Deserializer<'de> for PairRefDeserializer<'a, 'de, E>
where
E: de::Error,
{
type Error = E;
serde_core::forward_to_deserialize_any! {
bool i8 i16 i32 i64 i128 u8 u16 u32 u64 u128 f32 f64 char str string
bytes byte_buf option unit unit_struct newtype_struct tuple_struct map
struct enum identifier ignored_any
}
fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_seq(visitor)
}
fn deserialize_seq<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
let mut pair_visitor = PairRefVisitor(Some(self.0), Some(self.1), PhantomData);
let pair = tri!(visitor.visit_seq(&mut pair_visitor));
if pair_visitor.1.is_none() {
Ok(pair)
} else {
let remaining = pair_visitor.size_hint().unwrap();
// First argument is the number of elements in the data, second
// argument is the number of elements expected by the Deserialize.
Err(de::Error::invalid_length(2, &ExpectedInSeq(2 - remaining)))
}
}
fn deserialize_tuple<V>(self, len: usize, visitor: V) -> Result<V::Value, Self::Error>
where
V: de::Visitor<'de>,
{
if len == 2 {
self.deserialize_seq(visitor)
} else {
// First argument is the number of elements in the data, second
// argument is the number of elements expected by the Deserialize.
Err(de::Error::invalid_length(2, &ExpectedInSeq(len)))
}
}
}
struct PairRefVisitor<'a, 'de, E>(
Option<&'a Content<'de>>,
Option<&'a Content<'de>>,
PhantomData<E>,
);
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'a, 'de, E> SeqAccess<'de> for PairRefVisitor<'a, 'de, E>
where
E: de::Error,
{
type Error = E;
fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
where
T: DeserializeSeed<'de>,
{
if let Some(k) = self.0.take() {
seed.deserialize(ContentRefDeserializer::new(k)).map(Some)
} else if let Some(v) = self.1.take() {
seed.deserialize(ContentRefDeserializer::new(v)).map(Some)
} else {
Ok(None)
}
}
fn size_hint(&self) -> Option<usize> {
if self.0.is_some() {
Some(2)
} else if self.1.is_some() {
Some(1)
} else {
Some(0)
}
}
}
struct EnumRefDeserializer<'a, 'de: 'a, E>
where
E: de::Error,
{
variant: &'a Content<'de>,
value: Option<&'a Content<'de>>,
err: PhantomData<E>,
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de, 'a, E> de::EnumAccess<'de> for EnumRefDeserializer<'a, 'de, E>
where
E: de::Error,
{
type Error = E;
type Variant = VariantRefDeserializer<'a, 'de, Self::Error>;
fn variant_seed<V>(self, seed: V) -> Result<(V::Value, Self::Variant), Self::Error>
where
V: de::DeserializeSeed<'de>,
{
let visitor = VariantRefDeserializer {
value: self.value,
err: PhantomData,
};
seed.deserialize(ContentRefDeserializer::new(self.variant))
.map(|v| (v, visitor))
}
}
struct VariantRefDeserializer<'a, 'de: 'a, E>
where
E: de::Error,
{
value: Option<&'a Content<'de>>,
err: PhantomData<E>,
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de, 'a, E> de::VariantAccess<'de> for VariantRefDeserializer<'a, 'de, E>
where
E: de::Error,
{
type Error = E;
fn unit_variant(self) -> Result<(), E> {
match self.value {
Some(value) => de::Deserialize::deserialize(ContentRefDeserializer::new(value)),
// Covered by tests/test_annotations.rs
// test_partially_untagged_adjacently_tagged_enum
// Covered by tests/test_enum_untagged.rs
// newtype_enum::unit
None => Ok(()),
}
}
fn newtype_variant_seed<T>(self, seed: T) -> Result<T::Value, E>
where
T: de::DeserializeSeed<'de>,
{
match self.value {
// Covered by tests/test_annotations.rs
// test_partially_untagged_enum_desugared
// test_partially_untagged_enum_generic
// Covered by tests/test_enum_untagged.rs
// newtype_enum::newtype
Some(value) => seed.deserialize(ContentRefDeserializer::new(value)),
None => Err(de::Error::invalid_type(
de::Unexpected::UnitVariant,
&"newtype variant",
)),
}
}
fn tuple_variant<V>(self, _len: usize, visitor: V) -> Result<V::Value, Self::Error>
where
V: de::Visitor<'de>,
{
match self.value {
// Covered by tests/test_annotations.rs
// test_partially_untagged_enum
// test_partially_untagged_enum_desugared
// Covered by tests/test_enum_untagged.rs
// newtype_enum::tuple0
// newtype_enum::tuple2
Some(Content::Seq(v)) => visit_content_seq_ref(v, visitor),
Some(other) => Err(de::Error::invalid_type(
content_unexpected(other),
&"tuple variant",
)),
None => Err(de::Error::invalid_type(
de::Unexpected::UnitVariant,
&"tuple variant",
)),
}
}
fn struct_variant<V>(
self,
_fields: &'static [&'static str],
visitor: V,
) -> Result<V::Value, Self::Error>
where
V: de::Visitor<'de>,
{
match self.value {
// Covered by tests/test_enum_untagged.rs
// newtype_enum::struct_from_map
Some(Content::Map(v)) => visit_content_map_ref(v, visitor),
// Covered by tests/test_enum_untagged.rs
// newtype_enum::struct_from_seq
// newtype_enum::empty_struct_from_seq
Some(Content::Seq(v)) => visit_content_seq_ref(v, visitor),
Some(other) => Err(de::Error::invalid_type(
content_unexpected(other),
&"struct variant",
)),
None => Err(de::Error::invalid_type(
de::Unexpected::UnitVariant,
&"struct variant",
)),
}
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de, E> de::IntoDeserializer<'de, E> for ContentDeserializer<'de, E>
where
E: de::Error,
{
type Deserializer = Self;
fn into_deserializer(self) -> Self {
self
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de, 'a, E> de::IntoDeserializer<'de, E> for ContentRefDeserializer<'a, 'de, E>
where
E: de::Error,
{
type Deserializer = Self;
fn into_deserializer(self) -> Self {
self
}
}
/// Visitor for deserializing an internally tagged unit variant.
///
/// Not public API.
pub struct InternallyTaggedUnitVisitor<'a> {
type_name: &'a str,
variant_name: &'a str,
}
impl<'a> InternallyTaggedUnitVisitor<'a> {
/// Not public API.
pub fn new(type_name: &'a str, variant_name: &'a str) -> Self {
InternallyTaggedUnitVisitor {
type_name,
variant_name,
}
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de, 'a> Visitor<'de> for InternallyTaggedUnitVisitor<'a> {
type Value = ();
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(
formatter,
"unit variant {}::{}",
self.type_name, self.variant_name
)
}
fn visit_seq<S>(self, _: S) -> Result<(), S::Error>
where
S: SeqAccess<'de>,
{
Ok(())
}
fn visit_map<M>(self, mut access: M) -> Result<(), M::Error>
where
M: MapAccess<'de>,
{
while tri!(access.next_entry::<IgnoredAny, IgnoredAny>()).is_some() {}
Ok(())
}
}
/// Visitor for deserializing an untagged unit variant.
///
/// Not public API.
pub struct UntaggedUnitVisitor<'a> {
type_name: &'a str,
variant_name: &'a str,
}
impl<'a> UntaggedUnitVisitor<'a> {
/// Not public API.
pub fn new(type_name: &'a str, variant_name: &'a str) -> Self {
UntaggedUnitVisitor {
type_name,
variant_name,
}
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de, 'a> Visitor<'de> for UntaggedUnitVisitor<'a> {
type Value = ();
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(
formatter,
"unit variant {}::{}",
self.type_name, self.variant_name
)
}
fn visit_unit<E>(self) -> Result<(), E>
where
E: de::Error,
{
Ok(())
}
fn visit_none<E>(self) -> Result<(), E>
where
E: de::Error,
{
Ok(())
}
}
}
////////////////////////////////////////////////////////////////////////////////
// Like `IntoDeserializer` but also implemented for `&[u8]`. This is used for
// the newtype fallthrough case of `field_identifier`.
//
// #[derive(Deserialize)]
// #[serde(field_identifier)]
// enum F {
// A,
// B,
// Other(String), // deserialized using IdentifierDeserializer
// }
pub trait IdentifierDeserializer<'de, E: Error> {
type Deserializer: Deserializer<'de, Error = E>;
fn from(self) -> Self::Deserializer;
}
pub struct Borrowed<'de, T: 'de + ?Sized>(pub &'de T);
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de, E> IdentifierDeserializer<'de, E> for u64
where
E: Error,
{
type Deserializer = <u64 as IntoDeserializer<'de, E>>::Deserializer;
fn from(self) -> Self::Deserializer {
self.into_deserializer()
}
}
pub struct StrDeserializer<'a, E> {
value: &'a str,
marker: PhantomData<E>,
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de, 'a, E> Deserializer<'de> for StrDeserializer<'a, E>
where
E: Error,
{
type Error = E;
fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
visitor.visit_str(self.value)
}
serde_core::forward_to_deserialize_any! {
bool i8 i16 i32 i64 i128 u8 u16 u32 u64 u128 f32 f64 char str string
bytes byte_buf option unit unit_struct newtype_struct seq tuple
tuple_struct map struct enum identifier ignored_any
}
}
pub struct BorrowedStrDeserializer<'de, E> {
value: &'de str,
marker: PhantomData<E>,
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de, E> Deserializer<'de> for BorrowedStrDeserializer<'de, E>
where
E: Error,
{
type Error = E;
fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
visitor.visit_borrowed_str(self.value)
}
serde_core::forward_to_deserialize_any! {
bool i8 i16 i32 i64 i128 u8 u16 u32 u64 u128 f32 f64 char str string
bytes byte_buf option unit unit_struct newtype_struct seq tuple
tuple_struct map struct enum identifier ignored_any
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'a, E> IdentifierDeserializer<'a, E> for &'a str
where
E: Error,
{
type Deserializer = StrDeserializer<'a, E>;
fn from(self) -> Self::Deserializer {
StrDeserializer {
value: self,
marker: PhantomData,
}
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de, E> IdentifierDeserializer<'de, E> for Borrowed<'de, str>
where
E: Error,
{
type Deserializer = BorrowedStrDeserializer<'de, E>;
fn from(self) -> Self::Deserializer {
BorrowedStrDeserializer {
value: self.0,
marker: PhantomData,
}
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'a, E> IdentifierDeserializer<'a, E> for &'a [u8]
where
E: Error,
{
type Deserializer = BytesDeserializer<'a, E>;
fn from(self) -> Self::Deserializer {
BytesDeserializer::new(self)
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de, E> IdentifierDeserializer<'de, E> for Borrowed<'de, [u8]>
where
E: Error,
{
type Deserializer = BorrowedBytesDeserializer<'de, E>;
fn from(self) -> Self::Deserializer {
BorrowedBytesDeserializer::new(self.0)
}
}
#[cfg(any(feature = "std", feature = "alloc"))]
pub struct FlatMapDeserializer<'a, 'de: 'a, E>(
pub &'a mut Vec<Option<(Content<'de>, Content<'de>)>>,
pub PhantomData<E>,
);
#[cfg(any(feature = "std", feature = "alloc"))]
impl<'a, 'de, E> FlatMapDeserializer<'a, 'de, E>
where
E: Error,
{
fn deserialize_other<V>() -> Result<V, E> {
Err(Error::custom("can only flatten structs and maps"))
}
}
#[cfg(any(feature = "std", feature = "alloc"))]
macro_rules! forward_to_deserialize_other {
($($func:ident ($($arg:ty),*))*) => {
$(
fn $func<V>(self, $(_: $arg,)* _visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
Self::deserialize_other()
}
)*
}
}
#[cfg(any(feature = "std", feature = "alloc"))]
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'a, 'de, E> Deserializer<'de> for FlatMapDeserializer<'a, 'de, E>
where
E: Error,
{
type Error = E;
fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
self.deserialize_map(visitor)
}
fn deserialize_enum<V>(
self,
name: &'static str,
variants: &'static [&'static str],
visitor: V,
) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
for entry in self.0 {
if let Some((key, value)) = flat_map_take_entry(entry, variants) {
return visitor.visit_enum(EnumDeserializer::new(key, Some(value)));
}
}
Err(Error::custom(format_args!(
"no variant of enum {} found in flattened data",
name
)))
}
fn deserialize_map<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
visitor.visit_map(FlatMapAccess {
iter: self.0.iter(),
pending_content: None,
_marker: PhantomData,
})
}
fn deserialize_struct<V>(
self,
_: &'static str,
fields: &'static [&'static str],
visitor: V,
) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
visitor.visit_map(FlatStructAccess {
iter: self.0.iter_mut(),
pending_content: None,
fields,
_marker: PhantomData,
})
}
fn deserialize_newtype_struct<V>(self, _name: &str, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
visitor.visit_newtype_struct(self)
}
fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
match visitor.__private_visit_untagged_option(self) {
Ok(value) => Ok(value),
Err(()) => Self::deserialize_other(),
}
}
fn deserialize_unit<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
visitor.visit_unit()
}
fn deserialize_unit_struct<V>(
self,
_name: &'static str,
visitor: V,
) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
visitor.visit_unit()
}
fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
visitor.visit_unit()
}
forward_to_deserialize_other! {
deserialize_bool()
deserialize_i8()
deserialize_i16()
deserialize_i32()
deserialize_i64()
deserialize_u8()
deserialize_u16()
deserialize_u32()
deserialize_u64()
deserialize_f32()
deserialize_f64()
deserialize_char()
deserialize_str()
deserialize_string()
deserialize_bytes()
deserialize_byte_buf()
deserialize_seq()
deserialize_tuple(usize)
deserialize_tuple_struct(&'static str, usize)
deserialize_identifier()
}
}
#[cfg(any(feature = "std", feature = "alloc"))]
struct FlatMapAccess<'a, 'de: 'a, E> {
iter: slice::Iter<'a, Option<(Content<'de>, Content<'de>)>>,
pending_content: Option<&'a Content<'de>>,
_marker: PhantomData<E>,
}
#[cfg(any(feature = "std", feature = "alloc"))]
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'a, 'de, E> MapAccess<'de> for FlatMapAccess<'a, 'de, E>
where
E: Error,
{
type Error = E;
fn next_key_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
where
T: DeserializeSeed<'de>,
{
for item in &mut self.iter {
// Items in the vector are nulled out when used by a struct.
if let Some((ref key, ref content)) = *item {
// Do not take(), instead borrow this entry. The internally tagged
// enum does its own buffering so we can't tell whether this entry
// is going to be consumed. Borrowing here leaves the entry
// available for later flattened fields.
self.pending_content = Some(content);
return seed.deserialize(ContentRefDeserializer::new(key)).map(Some);
}
}
Ok(None)
}
fn next_value_seed<T>(&mut self, seed: T) -> Result<T::Value, Self::Error>
where
T: DeserializeSeed<'de>,
{
match self.pending_content.take() {
Some(value) => seed.deserialize(ContentRefDeserializer::new(value)),
None => Err(Error::custom("value is missing")),
}
}
}
#[cfg(any(feature = "std", feature = "alloc"))]
struct FlatStructAccess<'a, 'de: 'a, E> {
iter: slice::IterMut<'a, Option<(Content<'de>, Content<'de>)>>,
pending_content: Option<Content<'de>>,
fields: &'static [&'static str],
_marker: PhantomData<E>,
}
#[cfg(any(feature = "std", feature = "alloc"))]
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'a, 'de, E> MapAccess<'de> for FlatStructAccess<'a, 'de, E>
where
E: Error,
{
type Error = E;
fn next_key_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
where
T: DeserializeSeed<'de>,
{
for entry in self.iter.by_ref() {
if let Some((key, content)) = flat_map_take_entry(entry, self.fields) {
self.pending_content = Some(content);
return seed.deserialize(ContentDeserializer::new(key)).map(Some);
}
}
Ok(None)
}
fn next_value_seed<T>(&mut self, seed: T) -> Result<T::Value, Self::Error>
where
T: DeserializeSeed<'de>,
{
match self.pending_content.take() {
Some(value) => seed.deserialize(ContentDeserializer::new(value)),
None => Err(Error::custom("value is missing")),
}
}
}
/// Claims one key-value pair from a FlatMapDeserializer's field buffer if the
/// field name matches any of the recognized ones.
#[cfg(any(feature = "std", feature = "alloc"))]
fn flat_map_take_entry<'de>(
entry: &mut Option<(Content<'de>, Content<'de>)>,
recognized: &[&str],
) -> Option<(Content<'de>, Content<'de>)> {
// Entries in the FlatMapDeserializer buffer are nulled out as they get
// claimed for deserialization. We only use an entry if it is still present
// and if the field is one recognized by the current data structure.
let is_recognized = match entry {
None => false,
Some((k, _v)) => content_as_str(k).map_or(false, |name| recognized.contains(&name)),
};
if is_recognized {
entry.take()
} else {
None
}
}
pub struct AdjacentlyTaggedEnumVariantSeed<F> {
pub enum_name: &'static str,
pub variants: &'static [&'static str],
pub fields_enum: PhantomData<F>,
}
pub struct AdjacentlyTaggedEnumVariantVisitor<F> {
enum_name: &'static str,
fields_enum: PhantomData<F>,
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de, F> Visitor<'de> for AdjacentlyTaggedEnumVariantVisitor<F>
where
F: Deserialize<'de>,
{
type Value = F;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(formatter, "variant of enum {}", self.enum_name)
}
fn visit_enum<A>(self, data: A) -> Result<Self::Value, A::Error>
where
A: EnumAccess<'de>,
{
let (variant, variant_access) = tri!(data.variant());
tri!(variant_access.unit_variant());
Ok(variant)
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'de, F> DeserializeSeed<'de> for AdjacentlyTaggedEnumVariantSeed<F>
where
F: Deserialize<'de>,
{
type Value = F;
fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
where
D: Deserializer<'de>,
{
deserializer.deserialize_enum(
self.enum_name,
self.variants,
AdjacentlyTaggedEnumVariantVisitor {
enum_name: self.enum_name,
fields_enum: PhantomData,
},
)
}
}
================================================
FILE: serde/src/private/mod.rs
================================================
#[cfg(not(no_serde_derive))]
pub mod de;
#[cfg(not(no_serde_derive))]
pub mod ser;
pub use crate::lib::clone::Clone;
pub use crate::lib::convert::{From, Into, TryFrom};
pub use crate::lib::default::Default;
pub use crate::lib::fmt::{self, Formatter};
pub use crate::lib::marker::PhantomData;
pub use crate::lib::option::Option::{self, None, Some};
pub use crate::lib::ptr;
pub use crate::lib::result::Result::{self, Err, Ok};
pub use crate::serde_core_private::string::from_utf8_lossy;
#[cfg(any(feature = "alloc", feature = "std"))]
pub use crate::lib::{ToString, Vec};
================================================
FILE: serde/src/private/ser.rs
================================================
use crate::lib::*;
use crate::ser::{self, Impossible, Serialize, SerializeMap, SerializeStruct, Serializer};
#[cfg(any(feature = "std", feature = "alloc"))]
use self::content::{
Content, ContentSerializer, SerializeStructVariantAsMapValue, SerializeTupleVariantAsMapValue,
};
/// Used to check that serde(getter) attributes return the expected type.
/// Not public API.
pub fn constrain<T: ?Sized>(t: &T) -> &T {
t
}
/// Not public API.
pub fn serialize_tagged_newtype<S, T>(
serializer: S,
type_ident: &'static str,
variant_ident: &'static str,
tag: &'static str,
variant_name: &'static str,
value: &T,
) -> Result<S::Ok, S::Error>
where
S: Serializer,
T: Serialize,
{
value.serialize(TaggedSerializer {
type_ident,
variant_ident,
tag,
variant_name,
delegate: serializer,
})
}
struct TaggedSerializer<S> {
type_ident: &'static str,
variant_ident: &'static str,
tag: &'static str,
variant_name: &'static str,
delegate: S,
}
enum Unsupported {
Boolean,
Integer,
Float,
Char,
String,
ByteArray,
Optional,
Sequence,
Tuple,
TupleStruct,
#[cfg(not(any(feature = "std", feature = "alloc")))]
Enum,
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl Display for Unsupported {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
match *self {
Unsupported::Boolean => formatter.write_str("a boolean"),
Unsupported::Integer => formatter.write_str("an integer"),
Unsupported::Float => formatter.write_str("a float"),
Unsupported::Char => formatter.write_str("a char"),
Unsupported::String => formatter.write_str("a string"),
Unsupported::ByteArray => formatter.write_str("a byte array"),
Unsupported::Optional => formatter.write_str("an optional"),
Unsupported::Sequence => formatter.write_str("a sequence"),
Unsupported::Tuple => formatter.write_str("a tuple"),
Unsupported::TupleStruct => formatter.write_str("a tuple struct"),
#[cfg(not(any(feature = "std", feature = "alloc")))]
Unsupported::Enum => formatter.write_str("an enum"),
}
}
}
impl<S> TaggedSerializer<S>
where
S: Serializer,
{
fn bad_type(self, what: Unsupported) -> S::Error {
ser::Error::custom(format_args!(
"cannot serialize tagged newtype variant {}::{} containing {}",
self.type_ident, self.variant_ident, what
))
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<S> Serializer for TaggedSerializer<S>
where
S: Serializer,
{
type Ok = S::Ok;
type Error = S::Error;
type SerializeSeq = Impossible<S::Ok, S::Error>;
type SerializeTuple = Impossible<S::Ok, S::Error>;
type SerializeTupleStruct = Impossible<S::Ok, S::Error>;
type SerializeMap = S::SerializeMap;
type SerializeStruct = S::SerializeStruct;
#[cfg(not(any(feature = "std", feature = "alloc")))]
type SerializeTupleVariant = Impossible<S::Ok, S::Error>;
#[cfg(any(feature = "std", feature = "alloc"))]
type SerializeTupleVariant = SerializeTupleVariantAsMapValue<S::SerializeMap>;
#[cfg(not(any(feature = "std", feature = "alloc")))]
type SerializeStructVariant = Impossible<S::Ok, S::Error>;
#[cfg(any(feature = "std", feature = "alloc"))]
type SerializeStructVariant = SerializeStructVariantAsMapValue<S::SerializeMap>;
fn serialize_bool(self, _: bool) -> Result<Self::Ok, Self::Error> {
Err(self.bad_type(Unsupported::Boolean))
}
fn serialize_i8(self, _: i8) -> Result<Self::Ok, Self::Error> {
Err(self.bad_type(Unsupported::Integer))
}
fn serialize_i16(self, _: i16) -> Result<Self::Ok, Self::Error> {
Err(self.bad_type(Unsupported::Integer))
}
fn serialize_i32(self, _: i32) -> Result<Self::Ok, Self::Error> {
Err(self.bad_type(Unsupported::Integer))
}
fn serialize_i64(self, _: i64) -> Result<Self::Ok, Self::Error> {
Err(self.bad_type(Unsupported::Integer))
}
fn serialize_u8(self, _: u8) -> Result<Self::Ok, Self::Error> {
Err(self.bad_type(Unsupported::Integer))
}
fn serialize_u16(self, _: u16) -> Result<Self::Ok, Self::Error> {
Err(self.bad_type(Unsupported::Integer))
}
fn serialize_u32(self, _: u32) -> Result<Self::Ok, Self::Error> {
Err(self.bad_type(Unsupported::Integer))
}
fn serialize_u64(self, _: u64) -> Result<Self::Ok, Self::Error> {
Err(self.bad_type(Unsupported::Integer))
}
fn serialize_f32(self, _: f32) -> Result<Self::Ok, Self::Error> {
Err(self.bad_type(Unsupported::Float))
}
fn serialize_f64(self, _: f64) -> Result<Self::Ok, Self::Error> {
Err(self.bad_type(Unsupported::Float))
}
fn serialize_char(self, _: char) -> Result<Self::Ok, Self::Error> {
Err(self.bad_type(Unsupported::Char))
}
fn serialize_str(self, _: &str) -> Result<Self::Ok, Self::Error> {
Err(self.bad_type(Unsupported::String))
}
fn serialize_bytes(self, _: &[u8]) -> Result<Self::Ok, Self::Error> {
Err(self.bad_type(Unsupported::ByteArray))
}
fn serialize_none(self) -> Result<Self::Ok, Self::Error> {
Err(self.bad_type(Unsupported::Optional))
}
fn serialize_some<T>(self, _: &T) -> Result<Self::Ok, Self::Error>
where
T: ?Sized + Serialize,
{
Err(self.bad_type(Unsupported::Optional))
}
fn serialize_unit(self) -> Result<Self::Ok, Self::Error> {
let mut map = tri!(self.delegate.serialize_map(Some(1)));
tri!(map.serialize_entry(self.tag, self.variant_name));
map.end()
}
fn serialize_unit_struct(self, _: &'static str) -> Result<Self::Ok, Self::Error> {
let mut map = tri!(self.delegate.serialize_map(Some(1)));
tri!(map.serialize_entry(self.tag, self.variant_name));
map.end()
}
fn serialize_unit_variant(
self,
_: &'static str,
_: u32,
inner_variant: &'static str,
) -> Result<Self::Ok, Self::Error> {
let mut map = tri!(self.delegate.serialize_map(Some(2)));
tri!(map.serialize_entry(self.tag, self.variant_name));
tri!(map.serialize_entry(inner_variant, &()));
map.end()
}
fn serialize_newtype_struct<T>(
self,
_: &'static str,
value: &T,
) -> Result<Self::Ok, Self::Error>
where
T: ?Sized + Serialize,
{
value.serialize(self)
}
fn serialize_newtype_variant<T>(
self,
_: &'static str,
_: u32,
inner_variant: &'static str,
inner_value: &T,
) -> Result<Self::Ok, Self::Error>
where
T: ?Sized + Serialize,
{
let mut map = tri!(self.delegate.serialize_map(Some(2)));
tri!(map.serialize_entry(self.tag, self.variant_name));
tri!(map.serialize_entry(inner_variant, inner_value));
map.end()
}
fn serialize_seq(self, _: Option<usize>) -> Result<Self::SerializeSeq, Self::Error> {
Err(self.bad_type(Unsupported::Sequence))
}
fn serialize_tuple(self, _: usize) -> Result<Self::SerializeTuple, Self::Error> {
Err(self.bad_type(Unsupported::Tuple))
}
fn serialize_tuple_struct(
self,
_: &'static str,
_: usize,
) -> Result<Self::SerializeTupleStruct, Self::Error> {
Err(self.bad_type(Unsupported::TupleStruct))
}
#[cfg(not(any(feature = "std", feature = "alloc")))]
fn serialize_tuple_variant(
self,
_: &'static str,
_: u32,
_: &'static str,
_: usize,
) -> Result<Self::SerializeTupleVariant, Self::Error> {
// Lack of push-based serialization means we need to buffer the content
// of the tuple variant, so it requires std.
Err(self.bad_type(Unsupported::Enum))
}
#[cfg(any(feature = "std", feature = "alloc"))]
fn serialize_tuple_variant(
self,
_: &'static str,
_: u32,
inner_variant: &'static str,
len: usize,
) -> Result<Self::SerializeTupleVariant, Self::Error> {
let mut map = tri!(self.delegate.serialize_map(Some(2)));
tri!(map.serialize_entry(self.tag, self.variant_name));
tri!(map.serialize_key(inner_variant));
Ok(SerializeTupleVariantAsMapValue::new(
map,
inner_variant,
len,
))
}
fn serialize_map(self, len: Option<usize>) -> Result<Self::SerializeMap, Self::Error> {
let mut map = tri!(self.delegate.serialize_map(len.map(|len| len + 1)));
tri!(map.serialize_entry(self.tag, self.variant_name));
Ok(map)
}
fn serialize_struct(
self,
name: &'static str,
len: usize,
) -> Result<Self::SerializeStruct, Self::Error> {
let mut state = tri!(self.delegate.serialize_struct(name, len + 1));
tri!(state.serialize_field(self.tag, self.variant_name));
Ok(state)
}
#[cfg(not(any(feature = "std", feature = "alloc")))]
fn serialize_struct_variant(
self,
_: &'static str,
_: u32,
_: &'static str,
_: usize,
) -> Result<Self::SerializeStructVariant, Self::Error> {
// Lack of push-based serialization means we need to buffer the content
// of the struct variant, so it requires std.
Err(self.bad_type(Unsupported::Enum))
}
#[cfg(any(feature = "std", feature = "alloc"))]
fn serialize_struct_variant(
self,
_: &'static str,
_: u32,
inner_variant: &'static str,
len: usize,
) -> Result<Self::SerializeStructVariant, Self::Error> {
let mut map = tri!(self.delegate.serialize_map(Some(2)));
tri!(map.serialize_entry(self.tag, self.variant_name));
tri!(map.serialize_key(inner_variant));
Ok(SerializeStructVariantAsMapValue::new(
map,
inner_variant,
len,
))
}
#[cfg(not(any(feature = "std", feature = "alloc")))]
fn collect_str<T>(self, _: &T) -> Result<Self::Ok, Self::Error>
where
T: ?Sized + Display,
{
Err(self.bad_type(Unsupported::String))
}
}
#[cfg(any(feature = "std", feature = "alloc"))]
mod content {
use crate::lib::*;
use crate::ser::{self, Serialize, Serializer};
pub struct SerializeTupleVariantAsMapValue<M> {
map: M,
name: &'static str,
fields: Vec<Content>,
}
impl<M> SerializeTupleVariantAsMapValue<M> {
pub fn new(map: M, name: &'static str, len: usize) -> Self {
SerializeTupleVariantAsMapValue {
map,
name,
fields: Vec::with_capacity(len),
}
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<M> ser::SerializeTupleVariant for SerializeTupleVariantAsMapValue<M>
where
M: ser::SerializeMap,
{
type Ok = M::Ok;
type Error = M::Error;
fn serialize_field<T>(&mut self, value: &T) -> Result<(), M::Error>
where
T: ?Sized + Serialize,
{
let value = tri!(value.serialize(ContentSerializer::<M::Error>::new()));
self.fields.push(value);
Ok(())
}
fn end(mut self) -> Result<M::Ok, M::Error> {
tri!(self
.map
.serialize_value(&Content::TupleStruct(self.name, self.fields)));
self.map.end()
}
}
pub struct SerializeStructVariantAsMapValue<M> {
map: M,
name: &'static str,
fields: Vec<(&'static str, Content)>,
}
impl<M> SerializeStructVariantAsMapValue<M> {
pub fn new(map: M, name: &'static str, len: usize) -> Self {
SerializeStructVariantAsMapValue {
map,
name,
fields: Vec::with_capacity(len),
}
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<M> ser::SerializeStructVariant for SerializeStructVariantAsMapValue<M>
where
M: ser::SerializeMap,
{
type Ok = M::Ok;
type Error = M::Error;
fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), M::Error>
where
T: ?Sized + Serialize,
{
let value = tri!(value.serialize(ContentSerializer::<M::Error>::new()));
self.fields.push((key, value));
Ok(())
}
fn end(mut self) -> Result<M::Ok, M::Error> {
tri!(self
.map
.serialize_value(&Content::Struct(self.name, self.fields)));
self.map.end()
}
}
pub enum Content {
Bool(bool),
U8(u8),
U16(u16),
U32(u32),
U64(u64),
I8(i8),
I16(i16),
I32(i32),
I64(i64),
F32(f32),
F64(f64),
Char(char),
String(String),
Bytes(Vec<u8>),
None,
Some(Box<Content>),
Unit,
UnitStruct(&'static str),
UnitVariant(&'static str, u32, &'static str),
NewtypeStruct(&'static str, Box<Content>),
NewtypeVariant(&'static str, u32, &'static str, Box<Content>),
Seq(Vec<Content>),
Tuple(Vec<Content>),
TupleStruct(&'static str, Vec<Content>),
TupleVariant(&'static str, u32, &'static str, Vec<Content>),
Map(Vec<(Content, Content)>),
Struct(&'static str, Vec<(&'static str, Content)>),
StructVariant(
&'static str,
u32,
&'static str,
Vec<(&'static str, Content)>,
),
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl Serialize for Content {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
match *self {
Content::Bool(b) => serializer.serialize_bool(b),
Content::U8(u) => serializer.serialize_u8(u),
Content::U16(u) => serializer.serialize_u16(u),
Content::U32(u) => serializer.serialize_u32(u),
Content::U64(u) => serializer.serialize_u64(u),
Content::I8(i) => serializer.serialize_i8(i),
Content::I16(i) => serializer.serialize_i16(i),
Content::I32(i) => serializer.serialize_i32(i),
Content::I64(i) => serializer.serialize_i64(i),
Content::F32(f) => serializer.serialize_f32(f),
Content::F64(f) => serializer.serialize_f64(f),
Content::Char(c) => serializer.serialize_char(c),
Content::String(ref s) => serializer.serialize_str(s),
Content::Bytes(ref b) => serializer.serialize_bytes(b),
Content::None => serializer.serialize_none(),
Content::Some(ref c) => serializer.serialize_some(&**c),
Content::Unit => serializer.serialize_unit(),
Content::UnitStruct(n) => serializer.serialize_unit_struct(n),
Content::UnitVariant(n, i, v) => serializer.serialize_unit_variant(n, i, v),
Content::NewtypeStruct(n, ref c) => serializer.serialize_newtype_struct(n, &**c),
Content::NewtypeVariant(n, i, v, ref c) => {
serializer.serialize_newtype_variant(n, i, v, &**c)
}
Content::Seq(ref elements) => elements.serialize(serializer),
Content::Tuple(ref elements) => {
use crate::ser::SerializeTuple;
let mut tuple = tri!(serializer.serialize_tuple(elements.len()));
for e in elements {
tri!(tuple.serialize_element(e));
}
tuple.end()
}
Content::TupleStruct(n, ref fields) => {
use crate::ser::SerializeTupleStruct;
let mut ts = tri!(serializer.serialize_tuple_struct(n, fields.len()));
for f in fields {
tri!(ts.serialize_field(f));
}
ts.end()
}
Content::TupleVariant(n, i, v, ref fields) => {
use crate::ser::SerializeTupleVariant;
let mut tv = tri!(serializer.serialize_tuple_variant(n, i, v, fields.len()));
for f in fields {
tri!(tv.serialize_field(f));
}
tv.end()
}
Content::Map(ref entries) => {
use crate::ser::SerializeMap;
let mut map = tri!(serializer.serialize_map(Some(entries.len())));
for (k, v) in entries {
tri!(map.serialize_entry(k, v));
}
map.end()
}
Content::Struct(n, ref fields) => {
use crate::ser::SerializeStruct;
let mut s = tri!(serializer.serialize_struct(n, fields.len()));
for &(k, ref v) in fields {
tri!(s.serialize_field(k, v));
}
s.end()
}
Content::StructVariant(n, i, v, ref fields) => {
use crate::ser::SerializeStructVariant;
let mut sv = tri!(serializer.serialize_struct_variant(n, i, v, fields.len()));
for &(k, ref v) in fields {
tri!(sv.serialize_field(k, v));
}
sv.end()
}
}
}
}
pub struct ContentSerializer<E> {
error: PhantomData<E>,
}
impl<E> ContentSerializer<E> {
pub fn new() -> Self {
ContentSerializer { error: PhantomData }
}
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<E> Serializer for ContentSerializer<E>
where
E: ser::Error,
{
type Ok = Content;
type Error = E;
type SerializeSeq = SerializeSeq<E>;
type SerializeTuple = SerializeTuple<E>;
type SerializeTupleStruct = SerializeTupleStruct<E>;
type SerializeTupleVariant = SerializeTupleVariant<E>;
type SerializeMap = SerializeMap<E>;
type SerializeStruct = SerializeStruct<E>;
type SerializeStructVariant = SerializeStructVariant<E>;
fn serialize_bool(self, v: bool) -> Result<Content, E> {
Ok(Content::Bool(v))
}
fn serialize_i8(self, v: i8) -> Result<Content, E> {
Ok(Content::I8(v))
}
fn serialize_i16(self, v: i16) -> Result<Content, E> {
Ok(Content::I16(v))
}
fn serialize_i32(self, v: i32) -> Result<Content, E> {
Ok(Content::I32(v))
}
fn serialize_i64(self, v: i64) -> Result<Content, E> {
Ok(Content::I64(v))
}
fn serialize_u8(self, v: u8) -> Result<Content, E> {
Ok(Content::U8(v))
}
fn serialize_u16(self, v: u16) -> Result<Content, E> {
Ok(Content::U16(v))
}
fn serialize_u32(self, v: u32) -> Result<Content, E> {
Ok(Content::U32(v))
}
fn serialize_u64(self, v: u64) -> Result<Content, E> {
Ok(Content::U64(v))
}
fn serialize_f32(self, v: f32) -> Result<Content, E> {
Ok(Content::F32(v))
}
fn serialize_f64(self, v: f64) -> Result<Content, E> {
Ok(Content::F64(v))
}
fn serialize_char(self, v: char) -> Result<Content, E> {
Ok(Content::Char(v))
}
fn serialize_str(self, value: &str) -> Result<Content, E> {
Ok(Content::String(value.to_owned()))
}
fn serialize_bytes(self, value: &[u8]) -> Result<Content, E> {
Ok(Content::Bytes(value.to_owned()))
}
fn serialize_none(self) -> Result<Content, E> {
Ok(Content::None)
}
fn serialize_some<T>(self, value: &T) -> Result<Content, E>
where
T: ?Sized + Serialize,
{
Ok(Content::Some(Box::new(tri!(value.serialize(self)))))
}
fn serialize_unit(self) -> Result<Content, E> {
Ok(Content::Unit)
}
fn serialize_unit_struct(self, name: &'static str) -> Result<Content, E> {
Ok(Content::UnitStruct(name))
}
fn serialize_unit_variant(
self,
name: &'static str,
variant_index: u32,
variant: &'static str,
) -> Result<Content, E> {
Ok(Content::UnitVariant(name, variant_index, variant))
}
fn serialize_newtype_struct<T>(self, name: &'static str, value: &T) -> Result<Content, E>
where
T: ?Sized + Serialize,
{
Ok(Content::NewtypeStruct(
name,
Box::new(tri!(value.serialize(self))),
))
}
fn serialize_newtype_variant<T>(
self,
name: &'static str,
variant_index: u32,
variant: &'static str,
value: &T,
) -> Result<Content, E>
where
T: ?Sized + Serialize,
{
Ok(Content::NewtypeVariant(
name,
variant_index,
variant,
Box::new(tri!(value.serialize(self))),
))
}
fn serialize_seq(self, len: Option<usize>) -> Result<Self::SerializeSeq, E> {
Ok(SerializeSeq {
elements: Vec::with_capacity(len.unwrap_or(0)),
error: PhantomData,
})
}
fn serialize_tuple(self, len: usize) -> Result<Self::SerializeTuple, E> {
Ok(SerializeTuple {
elements: Vec::with_capacity(len),
error: PhantomData,
})
}
fn serialize_tuple_struct(
self,
name: &'static str,
len: usize,
) -> Result<Self::SerializeTupleStruct, E> {
Ok(SerializeTupleStruct {
name,
fields: Vec::with_capacity(len),
error: PhantomData,
})
}
fn serialize_tuple_variant(
self,
name: &'static str,
variant_index: u32,
variant: &'static str,
len: usize,
) -> Result<Self::SerializeTupleVariant, E> {
Ok(SerializeTupleVariant {
name,
variant_index,
variant,
fields: Vec::with_capacity(len),
error: PhantomData,
})
}
fn serialize_map(self, len: Option<usize>) -> Result<Self::SerializeMap, E> {
Ok(SerializeMap {
entries: Vec::with_capacity(len.unwrap_or(0)),
key: None,
error: PhantomData,
})
}
fn serialize_struct(
self,
name: &'static str,
len: usize,
) -> Result<Self::SerializeStruct, E> {
Ok(SerializeStruct {
name,
fields: Vec::with_capacity(len),
error: PhantomData,
})
}
fn serialize_struct_variant(
self,
name: &'static str,
variant_index: u32,
variant: &'static str,
len: usize,
) -> Result<Self::SerializeStructVariant, E> {
Ok(SerializeStructVariant {
name,
variant_index,
variant,
fields: Vec::with_capacity(len),
error: PhantomData,
})
}
}
pub struct SerializeSeq<E> {
elements: Vec<Content>,
error: PhantomData<E>,
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<E> ser::SerializeSeq for SerializeSeq<E>
where
E: ser::Error,
{
type Ok = Content;
type Error = E;
fn serialize_element<T>(&mut self, value: &T) -> Result<(), E>
where
T: ?Sized + Serialize,
{
let value = tri!(value.serialize(ContentSerializer::<E>::new()));
self.elements.push(value);
Ok(())
}
fn end(self) -> Result<Content, E> {
Ok(Content::Seq(self.elements))
}
}
pub struct SerializeTuple<E> {
elements: Vec<Content>,
error: PhantomData<E>,
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<E> ser::SerializeTuple for SerializeTuple<E>
where
E: ser::Error,
{
type Ok = Content;
type Error = E;
fn serialize_element<T>(&mut self, value: &T) -> Result<(), E>
where
T: ?Sized + Serialize,
{
let value = tri!(value.serialize(ContentSerializer::<E>::new()));
self.elements.push(value);
Ok(())
}
fn end(self) -> Result<Content, E> {
Ok(Content::Tuple(self.elements))
}
}
pub struct SerializeTupleStruct<E> {
name: &'static str,
fields: Vec<Content>,
error: PhantomData<E>,
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<E> ser::SerializeTupleStruct for SerializeTupleStruct<E>
where
E: ser::Error,
{
type Ok = Content;
type Error = E;
fn serialize_field<T>(&mut self, value: &T) -> Result<(), E>
where
T: ?Sized + Serialize,
{
let value = tri!(value.serialize(ContentSerializer::<E>::new()));
self.fields.push(value);
Ok(())
}
fn end(self) -> Result<Content, E> {
Ok(Content::TupleStruct(self.name, self.fields))
}
}
pub struct SerializeTupleVariant<E> {
name: &'static str,
variant_index: u32,
variant: &'static str,
fields: Vec<Content>,
error: PhantomData<E>,
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<E> ser::SerializeTupleVariant for SerializeTupleVariant<E>
where
E: ser::Error,
{
type Ok = Content;
type Error = E;
fn serialize_field<T>(&mut self, value: &T) -> Result<(), E>
where
T: ?Sized + Serialize,
{
let value = tri!(value.serialize(ContentSerializer::<E>::new()));
self.fields.push(value);
Ok(())
}
fn end(self) -> Result<Content, E> {
Ok(Content::TupleVariant(
self.name,
self.variant_index,
self.variant,
self.fields,
))
}
}
pub struct SerializeMap<E> {
entries: Vec<(Content, Content)>,
key: Option<Content>,
error: PhantomData<E>,
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<E> ser::SerializeMap for SerializeMap<E>
where
E: ser::Error,
{
type Ok = Content;
type Error = E;
fn serialize_key<T>(&mut self, key: &T) -> Result<(), E>
where
T: ?Sized + Serialize,
{
let key = tri!(key.serialize(ContentSerializer::<E>::new()));
self.key = Some(key);
Ok(())
}
fn serialize_value<T>(&mut self, value: &T) -> Result<(), E>
where
T: ?Sized + Serialize,
{
let key = self
.key
.take()
.expect("serialize_value called before serialize_key");
let value = tri!(value.serialize(ContentSerializer::<E>::new()));
self.entries.push((key, value));
Ok(())
}
fn end(self) -> Result<Content, E> {
Ok(Content::Map(self.entries))
}
fn serialize_entry<K, V>(&mut self, key: &K, value: &V) -> Result<(), E>
where
K: ?Sized + Serialize,
V: ?Sized + Serialize,
{
let key = tri!(key.serialize(ContentSerializer::<E>::new()));
let value = tri!(value.serialize(ContentSerializer::<E>::new()));
self.entries.push((key, value));
Ok(())
}
}
pub struct SerializeStruct<E> {
name: &'static str,
fields: Vec<(&'static str, Content)>,
error: PhantomData<E>,
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<E> ser::SerializeStruct for SerializeStruct<E>
where
E: ser::Error,
{
type Ok = Content;
type Error = E;
fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), E>
where
T: ?Sized + Serialize,
{
let value = tri!(value.serialize(ContentSerializer::<E>::new()));
self.fields.push((key, value));
Ok(())
}
fn end(self) -> Result<Content, E> {
Ok(Content::Struct(self.name, self.fields))
}
}
pub struct SerializeStructVariant<E> {
name: &'static str,
variant_index: u32,
variant: &'static str,
fields: Vec<(&'static str, Content)>,
error: PhantomData<E>,
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<E> ser::SerializeStructVariant for SerializeStructVariant<E>
where
E: ser::Error,
{
type Ok = Content;
type Error = E;
fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), E>
where
T: ?Sized + Serialize,
{
let value = tri!(value.serialize(ContentSerializer::<E>::new()));
self.fields.push((key, value));
Ok(())
}
fn end(self) -> Result<Content, E> {
Ok(Content::StructVariant(
self.name,
self.variant_index,
self.variant,
self.fields,
))
}
}
}
#[cfg(any(feature = "std", feature = "alloc"))]
pub struct FlatMapSerializer<'a, M: 'a>(pub &'a mut M);
#[cfg(any(feature = "std", feature = "alloc"))]
impl<'a, M> FlatMapSerializer<'a, M>
where
M: SerializeMap + 'a,
{
fn bad_type(what: Unsupported) -> M::Error {
ser::Error::custom(format_args!(
"can only flatten structs and maps (got {})",
what
))
}
}
#[cfg(any(feature = "std", feature = "alloc"))]
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'a, M> Serializer for FlatMapSerializer<'a, M>
where
M: SerializeMap + 'a,
{
type Ok = ();
type Error = M::Error;
type SerializeSeq = Impossible<Self::Ok, M::Error>;
type SerializeTuple = Impossible<Self::Ok, M::Error>;
type SerializeTupleStruct = Impossible<Self::Ok, M::Error>;
type SerializeMap = FlatMapSerializeMap<'a, M>;
type SerializeStruct = FlatMapSerializeStruct<'a, M>;
type SerializeTupleVariant = FlatMapSerializeTupleVariantAsMapValue<'a, M>;
type SerializeStructVariant = FlatMapSerializeStructVariantAsMapValue<'a, M>;
fn serialize_bool(self, _: bool) -> Result<Self::Ok, Self::Error> {
Err(Self::bad_type(Unsupported::Boolean))
}
fn serialize_i8(self, _: i8) -> Result<Self::Ok, Self::Error> {
Err(Self::bad_type(Unsupported::Integer))
}
fn serialize_i16(self, _: i16) -> Result<Self::Ok, Self::Error> {
Err(Self::bad_type(Unsupported::Integer))
}
fn serialize_i32(self, _: i32) -> Result<Self::Ok, Self::Error> {
Err(Self::bad_type(Unsupported::Integer))
}
fn serialize_i64(self, _: i64) -> Result<Self::Ok, Self::Error> {
Err(Self::bad_type(Unsupported::Integer))
}
fn serialize_u8(self, _: u8) -> Result<Self::Ok, Self::Error> {
Err(Self::bad_type(Unsupported::Integer))
}
fn serialize_u16(self, _: u16) -> Result<Self::Ok, Self::Error> {
Err(Self::bad_type(Unsupported::Integer))
}
fn serialize_u32(self, _: u32) -> Result<Self::Ok, Self::Error> {
Err(Self::bad_type(Unsupported::Integer))
}
fn serialize_u64(self, _: u64) -> Result<Self::Ok, Self::Error> {
Err(Self::bad_type(Unsupported::Integer))
}
fn serialize_f32(self, _: f32) -> Result<Self::Ok, Self::Error> {
Err(Self::bad_type(Unsupported::Float))
}
fn serialize_f64(self, _: f64) -> Result<Self::Ok, Self::Error> {
Err(Self::bad_type(Unsupported::Float))
}
fn serialize_char(self, _: char) -> Result<Self::Ok, Self::Error> {
Err(Self::bad_type(Unsupported::Char))
}
fn serialize_str(self, _: &str) -> Result<Self::Ok, Self::Error> {
Err(Self::bad_type(Unsupported::String))
}
fn serialize_bytes(self, _: &[u8]) -> Result<Self::Ok, Self::Error> {
Err(Self::bad_type(Unsupported::ByteArray))
}
fn serialize_none(self) -> Result<Self::Ok, Self::Error> {
Ok(())
}
fn serialize_some<T>(self, value: &T) -> Result<Self::Ok, Self::Error>
where
T: ?Sized + Serialize,
{
value.serialize(self)
}
fn serialize_unit(self) -> Result<Self::Ok, Self::Error> {
Ok(())
}
fn serialize_unit_struct(self, _: &'static str) -> Result<Self::Ok, Self::Error> {
Ok(())
}
fn serialize_unit_variant(
self,
_: &'static str,
_: u32,
variant: &'static str,
) -> Result<Self::Ok, Self::Error> {
self.0.serialize_entry(variant, &())
}
fn serialize_newtype_struct<T>(
self,
_: &'static str,
value: &T,
) -> Result<Self::Ok, Self::Error>
where
T: ?Sized + Serialize,
{
value.serialize(self)
}
fn serialize_newtype_variant<T>(
self,
_: &'static str,
_: u32,
variant: &'static str,
value: &T,
) -> Result<Self::Ok, Self::Error>
where
T: ?Sized + Serialize,
{
self.0.serialize_entry(variant, value)
}
fn serialize_seq(self, _: Option<usize>) -> Result<Self::SerializeSeq, Self::Error> {
Err(Self::bad_type(Unsupported::Sequence))
}
fn serialize_tuple(self, _: usize) -> Result<Self::SerializeTuple, Self::Error> {
Err(Self::bad_type(Unsupported::Tuple))
}
fn serialize_tuple_struct(
self,
_: &'static str,
_: usize,
) -> Result<Self::SerializeTupleStruct, Self::Error> {
Err(Self::bad_type(Unsupported::TupleStruct))
}
fn serialize_tuple_variant(
self,
_: &'static str,
_: u32,
variant: &'static str,
_: usize,
) -> Result<Self::SerializeTupleVariant, Self::Error> {
tri!(self.0.serialize_key(variant));
Ok(FlatMapSerializeTupleVariantAsMapValue::new(self.0))
}
fn serialize_map(self, _: Option<usize>) -> Result<Self::SerializeMap, Self::Error> {
Ok(FlatMapSerializeMap(self.0))
}
fn serialize_struct(
self,
_: &'static str,
_: usize,
) -> Result<Self::SerializeStruct, Self::Error> {
Ok(FlatMapSerializeStruct(self.0))
}
fn serialize_struct_variant(
self,
_: &'static str,
_: u32,
inner_variant: &'static str,
_: usize,
) -> Result<Self::SerializeStructVariant, Self::Error> {
tri!(self.0.serialize_key(inner_variant));
Ok(FlatMapSerializeStructVariantAsMapValue::new(
self.0,
inner_variant,
))
}
}
#[cfg(any(feature = "std", feature = "alloc"))]
pub struct FlatMapSerializeMap<'a, M: 'a>(&'a mut M);
#[cfg(any(feature = "std", feature = "alloc"))]
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'a, M> ser::SerializeMap for FlatMapSerializeMap<'a, M>
where
M: SerializeMap + 'a,
{
type Ok = ();
type Error = M::Error;
fn serialize_key<T>(&mut self, key: &T) -> Result<(), Self::Error>
where
T: ?Sized + Serialize,
{
self.0.serialize_key(key)
}
fn serialize_value<T>(&mut self, value: &T) -> Result<(), Self::Error>
where
T: ?Sized + Serialize,
{
self.0.serialize_value(value)
}
fn serialize_entry<K, V>(&mut self, key: &K, value: &V) -> Result<(), Self::Error>
where
K: ?Sized + Serialize,
V: ?Sized + Serialize,
{
self.0.serialize_entry(key, value)
}
fn end(self) -> Result<(), Self::Error> {
Ok(())
}
}
#[cfg(any(feature = "std", feature = "alloc"))]
pub struct FlatMapSerializeStruct<'a, M: 'a>(&'a mut M);
#[cfg(any(feature = "std", feature = "alloc"))]
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'a, M> ser::SerializeStruct for FlatMapSerializeStruct<'a, M>
where
M: SerializeMap + 'a,
{
type Ok = ();
type Error = M::Error;
fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), Self::Error>
where
T: ?Sized + Serialize,
{
self.0.serialize_entry(key, value)
}
fn end(self) -> Result<(), Self::Error> {
Ok(())
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
#[cfg(any(feature = "std", feature = "alloc"))]
pub struct FlatMapSerializeTupleVariantAsMapValue<'a, M: 'a> {
map: &'a mut M,
fields: Vec<Content>,
}
#[cfg(any(feature = "std", feature = "alloc"))]
impl<'a, M> FlatMapSerializeTupleVariantAsMapValue<'a, M>
where
M: SerializeMap + 'a,
{
fn new(map: &'a mut M) -> Self {
FlatMapSerializeTupleVariantAsMapValue {
map,
fields: Vec::new(),
}
}
}
#[cfg(any(feature = "std", feature = "alloc"))]
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'a, M> ser::SerializeTupleVariant for FlatMapSerializeTupleVariantAsMapValue<'a, M>
where
M: SerializeMap + 'a,
{
type Ok = ();
type Error = M::Error;
fn serialize_field<T>(&mut self, value: &T) -> Result<(), Self::Error>
where
T: ?Sized + Serialize,
{
let value = tri!(value.serialize(ContentSerializer::<M::Error>::new()));
self.fields.push(value);
Ok(())
}
fn end(self) -> Result<(), Self::Error> {
tri!(self.map.serialize_value(&Content::Seq(self.fields)));
Ok(())
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
#[cfg(any(feature = "std", feature = "alloc"))]
pub struct FlatMapSerializeStructVariantAsMapValue<'a, M: 'a> {
map: &'a mut M,
name: &'static str,
fields: Vec<(&'static str, Content)>,
}
#[cfg(any(feature = "std", feature = "alloc"))]
impl<'a, M> FlatMapSerializeStructVariantAsMapValue<'a, M>
where
M: SerializeMap + 'a,
{
fn new(map: &'a mut M, name: &'static str) -> FlatMapSerializeStructVariantAsMapValue<'a, M> {
FlatMapSerializeStructVariantAsMapValue {
map,
name,
fields: Vec::new(),
}
}
}
#[cfg(any(feature = "std", feature = "alloc"))]
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<'a, M> ser::SerializeStructVariant for FlatMapSerializeStructVariantAsMapValue<'a, M>
where
M: SerializeMap + 'a,
{
type Ok = ();
type Error = M::Error;
fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), Self::Error>
where
T: ?Sized + Serialize,
{
let value = tri!(value.serialize(ContentSerializer::<M::Error>::new()));
self.fields.push((key, value));
Ok(())
}
fn end(self) -> Result<(), Self::Error> {
tri!(self
.map
.serialize_value(&Content::Struct(self.name, self.fields)));
Ok(())
}
}
pub struct AdjacentlyTaggedEnumVariant {
pub enum_name: &'static str,
pub variant_index: u32,
pub variant_name: &'static str,
}
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl Serialize for AdjacentlyTaggedEnumVariant {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_unit_variant(self.enum_name, self.variant_index, self.variant_name)
}
}
// Error when Serialize for a non_exhaustive remote enum encounters a variant
// that is not recognized.
pub struct CannotSerializeVariant<T>(pub T);
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
impl<T> Display for CannotSerializeVariant<T>
where
T: Debug,
{
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(formatter, "enum variant cannot be serialized: {:?}", self.0)
}
}
================================================
FILE: serde_core/Cargo.toml
================================================
[package]
name = "serde_core"
version = "1.0.228"
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
build = "build.rs"
categories = ["encoding", "no-std", "no-std::no-alloc"]
description = "Serde traits only, with no support for derive -- use the `serde` crate instead"
documentation = "https://docs.rs/serde_core"
edition = "2021"
homepage = "https://serde.rs"
keywords = ["serde", "serialization", "no_std"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/serde-rs/serde"
rust-version = "1.56"
[dev-dependencies]
serde = { version = "1", path = "../serde" }
serde_derive = { version = "1", path = "../serde_derive" }
[package.metadata.playground]
features = ["rc", "result"]
[package.metadata.docs.rs]
features = ["rc", "result", "unstable"]
targets = ["x86_64-unknown-linux-gnu"]
rustdoc-args = [
"--generate-link-to-definition",
"--generate-macro-expansion",
"--extern-html-root-url=core=https://doc.rust-lang.org",
"--extern-html-root-url=alloc=https://doc.rust-lang.org",
"--extern-html-root-url=std=https://doc.rust-lang.org",
]
# This cfg cannot be enabled, but it still forces Cargo to keep serde_derive's
# version in lockstep with serde's, even if someone depends on the two crates
# separately with serde's "derive" feature disabled. Every serde_derive release
# is compatible with exactly one serde release because the generated code
# involves nonpublic APIs which a
gitextract_h3ikti25/
├── .github/
│ ├── FUNDING.yml
│ ├── ISSUE_TEMPLATE/
│ │ ├── 1-problem.md
│ │ ├── 2-suggestion.md
│ │ ├── 3-documentation.md
│ │ └── 4-other.md
│ └── workflows/
│ └── ci.yml
├── .gitignore
├── CONTRIBUTING.md
├── Cargo.toml
├── LICENSE-APACHE
├── LICENSE-MIT
├── README.md
├── crates-io.md
├── serde/
│ ├── Cargo.toml
│ ├── build.rs
│ └── src/
│ ├── integer128.rs
│ ├── lib.rs
│ └── private/
│ ├── de.rs
│ ├── mod.rs
│ └── ser.rs
├── serde_core/
│ ├── Cargo.toml
│ ├── README.md
│ ├── build.rs
│ └── src/
│ ├── crate_root.rs
│ ├── de/
│ │ ├── ignored_any.rs
│ │ ├── impls.rs
│ │ ├── mod.rs
│ │ └── value.rs
│ ├── format.rs
│ ├── lib.rs
│ ├── macros.rs
│ ├── private/
│ │ ├── content.rs
│ │ ├── doc.rs
│ │ ├── mod.rs
│ │ ├── seed.rs
│ │ ├── size_hint.rs
│ │ └── string.rs
│ ├── ser/
│ │ ├── fmt.rs
│ │ ├── impls.rs
│ │ ├── impossible.rs
│ │ └── mod.rs
│ └── std_error.rs
├── serde_derive/
│ ├── Cargo.toml
│ ├── build.rs
│ └── src/
│ ├── bound.rs
│ ├── de/
│ │ ├── enum_.rs
│ │ ├── enum_adjacently.rs
│ │ ├── enum_externally.rs
│ │ ├── enum_internally.rs
│ │ ├── enum_untagged.rs
│ │ ├── identifier.rs
│ │ ├── struct_.rs
│ │ ├── tuple.rs
│ │ └── unit.rs
│ ├── de.rs
│ ├── deprecated.rs
│ ├── dummy.rs
│ ├── fragment.rs
│ ├── internals/
│ │ ├── ast.rs
│ │ ├── attr.rs
│ │ ├── case.rs
│ │ ├── check.rs
│ │ ├── ctxt.rs
│ │ ├── mod.rs
│ │ ├── name.rs
│ │ ├── receiver.rs
│ │ ├── respan.rs
│ │ └── symbol.rs
│ ├── lib.rs
│ ├── pretend.rs
│ ├── ser.rs
│ └── this.rs
├── serde_derive_internals/
│ ├── Cargo.toml
│ ├── build.rs
│ └── lib.rs
└── test_suite/
├── Cargo.toml
├── no_std/
│ ├── .gitignore
│ ├── Cargo.toml
│ └── src/
│ └── main.rs
└── tests/
├── bytes/
│ └── mod.rs
├── compiletest.rs
├── macros/
│ └── mod.rs
├── regression/
│ ├── issue1904.rs
│ ├── issue2371.rs
│ ├── issue2409.rs
│ ├── issue2415.rs
│ ├── issue2565.rs
│ ├── issue2792.rs
│ ├── issue2844.rs
│ └── issue2846.rs
├── regression.rs
├── test_annotations.rs
├── test_borrow.rs
├── test_de.rs
├── test_de_error.rs
├── test_deprecated.rs
├── test_enum_adjacently_tagged.rs
├── test_enum_internally_tagged.rs
├── test_enum_untagged.rs
├── test_gen.rs
├── test_identifier.rs
├── test_ignored_any.rs
├── test_macros.rs
├── test_remote.rs
├── test_roundtrip.rs
├── test_self.rs
├── test_ser.rs
├── test_serde_path.rs
├── test_unstable.rs
├── test_value.rs
├── ui/
│ ├── borrow/
│ │ ├── bad_lifetimes.rs
│ │ ├── bad_lifetimes.stderr
│ │ ├── duplicate_lifetime.rs
│ │ ├── duplicate_lifetime.stderr
│ │ ├── duplicate_variant.rs
│ │ ├── duplicate_variant.stderr
│ │ ├── empty_lifetimes.rs
│ │ ├── empty_lifetimes.stderr
│ │ ├── no_lifetimes.rs
│ │ ├── no_lifetimes.stderr
│ │ ├── struct_variant.rs
│ │ ├── struct_variant.stderr
│ │ ├── wrong_lifetime.rs
│ │ └── wrong_lifetime.stderr
│ ├── conflict/
│ │ ├── adjacent-tag.rs
│ │ ├── adjacent-tag.stderr
│ │ ├── alias-enum.rs
│ │ ├── alias-enum.stderr
│ │ ├── alias.rs
│ │ ├── alias.stderr
│ │ ├── flatten-newtype-struct.rs
│ │ ├── flatten-newtype-struct.stderr
│ │ ├── flatten-tuple-struct.rs
│ │ ├── flatten-tuple-struct.stderr
│ │ ├── from-try-from.rs
│ │ ├── from-try-from.stderr
│ │ ├── internal-tag-alias.rs
│ │ ├── internal-tag-alias.stderr
│ │ ├── internal-tag.rs
│ │ └── internal-tag.stderr
│ ├── default-attribute/
│ │ ├── enum.rs
│ │ ├── enum.stderr
│ │ ├── enum_path.rs
│ │ ├── enum_path.stderr
│ │ ├── incorrect_type_enum_adjacently_tagged.rs
│ │ ├── incorrect_type_enum_adjacently_tagged.stderr
│ │ ├── incorrect_type_enum_externally_tagged.rs
│ │ ├── incorrect_type_enum_externally_tagged.stderr
│ │ ├── incorrect_type_enum_internally_tagged.rs
│ │ ├── incorrect_type_enum_internally_tagged.stderr
│ │ ├── incorrect_type_enum_untagged.rs
│ │ ├── incorrect_type_enum_untagged.stderr
│ │ ├── incorrect_type_newtype.rs
│ │ ├── incorrect_type_newtype.stderr
│ │ ├── incorrect_type_struct.rs
│ │ ├── incorrect_type_struct.stderr
│ │ ├── incorrect_type_tuple.rs
│ │ ├── incorrect_type_tuple.stderr
│ │ ├── tuple_struct.rs
│ │ ├── tuple_struct.stderr
│ │ ├── tuple_struct_path.rs
│ │ ├── tuple_struct_path.stderr
│ │ ├── union.rs
│ │ ├── union.stderr
│ │ ├── union_path.rs
│ │ ├── union_path.stderr
│ │ ├── unit.rs
│ │ ├── unit.stderr
│ │ ├── unit_path.rs
│ │ └── unit_path.stderr
│ ├── deprecated/
│ │ ├── deprecated_de_with.rs
│ │ ├── deprecated_de_with.stderr
│ │ ├── deprecated_ser_with.rs
│ │ └── deprecated_ser_with.stderr
│ ├── duplicate-attribute/
│ │ ├── rename-and-ser.rs
│ │ ├── rename-and-ser.stderr
│ │ ├── rename-ser-rename-ser.rs
│ │ ├── rename-ser-rename-ser.stderr
│ │ ├── rename-ser-rename.rs
│ │ ├── rename-ser-rename.stderr
│ │ ├── rename-ser-ser.rs
│ │ ├── rename-ser-ser.stderr
│ │ ├── two-rename-ser.rs
│ │ ├── two-rename-ser.stderr
│ │ ├── with-and-serialize-with.rs
│ │ └── with-and-serialize-with.stderr
│ ├── enum-representation/
│ │ ├── content-no-tag.rs
│ │ ├── content-no-tag.stderr
│ │ ├── internal-tuple-variant.rs
│ │ ├── internal-tuple-variant.stderr
│ │ ├── partially_tagged_wrong_order.rs
│ │ ├── partially_tagged_wrong_order.stderr
│ │ ├── untagged-and-adjacent.rs
│ │ ├── untagged-and-adjacent.stderr
│ │ ├── untagged-and-content.rs
│ │ ├── untagged-and-content.stderr
│ │ ├── untagged-and-internal.rs
│ │ ├── untagged-and-internal.stderr
│ │ ├── untagged-struct.rs
│ │ └── untagged-struct.stderr
│ ├── expected-string/
│ │ ├── boolean.rs
│ │ ├── boolean.stderr
│ │ ├── byte_character.rs
│ │ ├── byte_character.stderr
│ │ ├── byte_string.rs
│ │ ├── byte_string.stderr
│ │ ├── character.rs
│ │ ├── character.stderr
│ │ ├── float.rs
│ │ ├── float.stderr
│ │ ├── integer.rs
│ │ └── integer.stderr
│ ├── identifier/
│ │ ├── both.rs
│ │ ├── both.stderr
│ │ ├── field_struct.rs
│ │ ├── field_struct.stderr
│ │ ├── field_tuple.rs
│ │ ├── field_tuple.stderr
│ │ ├── newtype_not_last.rs
│ │ ├── newtype_not_last.stderr
│ │ ├── not_unit.rs
│ │ ├── not_unit.stderr
│ │ ├── other_not_last.rs
│ │ ├── other_not_last.stderr
│ │ ├── other_untagged.rs
│ │ ├── other_untagged.stderr
│ │ ├── other_variant.rs
│ │ ├── other_variant.stderr
│ │ ├── variant_struct.rs
│ │ ├── variant_struct.stderr
│ │ ├── variant_tuple.rs
│ │ └── variant_tuple.stderr
│ ├── malformed/
│ │ ├── bound.rs
│ │ ├── bound.stderr
│ │ ├── cut_off.rs
│ │ ├── cut_off.stderr
│ │ ├── not_list.rs
│ │ ├── not_list.stderr
│ │ ├── rename.rs
│ │ ├── rename.stderr
│ │ ├── str_suffix.rs
│ │ ├── str_suffix.stderr
│ │ ├── trailing_expr.rs
│ │ └── trailing_expr.stderr
│ ├── precondition/
│ │ ├── deserialize_de_lifetime.rs
│ │ ├── deserialize_de_lifetime.stderr
│ │ ├── deserialize_dst.rs
│ │ ├── deserialize_dst.stderr
│ │ ├── serialize_field_identifier.rs
│ │ ├── serialize_field_identifier.stderr
│ │ ├── serialize_variant_identifier.rs
│ │ └── serialize_variant_identifier.stderr
│ ├── remote/
│ │ ├── bad_getter.rs
│ │ ├── bad_getter.stderr
│ │ ├── bad_remote.rs
│ │ ├── bad_remote.stderr
│ │ ├── double_generic.rs
│ │ ├── double_generic.stderr
│ │ ├── enum_getter.rs
│ │ ├── enum_getter.stderr
│ │ ├── missing_field.rs
│ │ ├── missing_field.stderr
│ │ ├── nonremote_getter.rs
│ │ ├── nonremote_getter.stderr
│ │ ├── unknown_field.rs
│ │ ├── unknown_field.stderr
│ │ ├── wrong_de.rs
│ │ ├── wrong_de.stderr
│ │ ├── wrong_getter.rs
│ │ ├── wrong_getter.stderr
│ │ ├── wrong_ser.rs
│ │ └── wrong_ser.stderr
│ ├── rename/
│ │ ├── container_unknown_rename_rule.rs
│ │ ├── container_unknown_rename_rule.stderr
│ │ ├── variant_unknown_rename_rule.rs
│ │ └── variant_unknown_rename_rule.stderr
│ ├── struct-representation/
│ │ ├── internally-tagged-tuple.rs
│ │ ├── internally-tagged-tuple.stderr
│ │ ├── internally-tagged-unit.rs
│ │ └── internally-tagged-unit.stderr
│ ├── transparent/
│ │ ├── at_most_one.rs
│ │ ├── at_most_one.stderr
│ │ ├── de_at_least_one.rs
│ │ ├── de_at_least_one.stderr
│ │ ├── enum.rs
│ │ ├── enum.stderr
│ │ ├── ser_at_least_one.rs
│ │ ├── ser_at_least_one.stderr
│ │ ├── unit_struct.rs
│ │ ├── unit_struct.stderr
│ │ ├── with_from.rs
│ │ ├── with_from.stderr
│ │ ├── with_into.rs
│ │ ├── with_into.stderr
│ │ ├── with_try_from.rs
│ │ └── with_try_from.stderr
│ ├── type-attribute/
│ │ ├── from.rs
│ │ ├── from.stderr
│ │ ├── into.rs
│ │ ├── into.stderr
│ │ ├── try_from.rs
│ │ └── try_from.stderr
│ ├── unexpected-literal/
│ │ ├── container.rs
│ │ ├── container.stderr
│ │ ├── field.rs
│ │ ├── field.stderr
│ │ ├── variant.rs
│ │ └── variant.stderr
│ ├── unimplemented/
│ │ ├── required_by_dependency.rs
│ │ ├── required_by_dependency.stderr
│ │ ├── required_locally.rs
│ │ └── required_locally.stderr
│ ├── unknown-attribute/
│ │ ├── container.rs
│ │ ├── container.stderr
│ │ ├── field.rs
│ │ ├── field.stderr
│ │ ├── variant.rs
│ │ └── variant.stderr
│ ├── unsupported/
│ │ ├── union_de.rs
│ │ ├── union_de.stderr
│ │ ├── union_ser.rs
│ │ └── union_ser.stderr
│ ├── with/
│ │ ├── incorrect_type.rs
│ │ └── incorrect_type.stderr
│ └── with-variant/
│ ├── skip_de_newtype_field.rs
│ ├── skip_de_newtype_field.stderr
│ ├── skip_de_struct_field.rs
│ ├── skip_de_struct_field.stderr
│ ├── skip_de_tuple_field.rs
│ ├── skip_de_tuple_field.stderr
│ ├── skip_de_whole_variant.rs
│ ├── skip_de_whole_variant.stderr
│ ├── skip_ser_newtype_field.rs
│ ├── skip_ser_newtype_field.stderr
│ ├── skip_ser_newtype_field_if.rs
│ ├── skip_ser_newtype_field_if.stderr
│ ├── skip_ser_struct_field.rs
│ ├── skip_ser_struct_field.stderr
│ ├── skip_ser_struct_field_if.rs
│ ├── skip_ser_struct_field_if.stderr
│ ├── skip_ser_tuple_field.rs
│ ├── skip_ser_tuple_field.stderr
│ ├── skip_ser_tuple_field_if.rs
│ ├── skip_ser_tuple_field_if.stderr
│ ├── skip_ser_whole_variant.rs
│ └── skip_ser_whole_variant.stderr
└── unstable/
└── mod.rs
Showing preview only (209K chars total). Download the full file or copy to clipboard to get everything.
SYMBOL INDEX (2524 symbols across 197 files)
FILE: serde/build.rs
constant PRIVATE (line 7) | const PRIVATE: &str = "\
function main (line 19) | fn main() {
function rustc_minor_version (line 60) | fn rustc_minor_version() -> Option<u32> {
FILE: serde/src/private/de.rs
function missing_field (line 24) | pub fn missing_field<'de, V, E>(field: &'static str) -> Result<V, E>
function borrow_cow_str (line 64) | pub fn borrow_cow_str<'de: 'a, 'a, D, R>(deserializer: D) -> Result<R, D...
function borrow_cow_bytes (line 138) | pub fn borrow_cow_bytes<'de: 'a, 'a, D, R>(deserializer: D) -> Result<R,...
function content_as_str (line 222) | pub fn content_as_str<'a, 'de>(content: &'a Content<'de>) -> Option<&'a ...
function content_clone (line 232) | fn content_clone<'de>(content: &Content<'de>) -> Content<'de> {
function content_unexpected (line 264) | fn content_unexpected<'a, 'de>(content: &'a Content<'de>) -> Unexpected<...
type ContentVisitor (line 290) | pub struct ContentVisitor<'de> {
function new (line 295) | pub fn new() -> Self {
type Value (line 302) | type Value = Content<'de>;
function deserialize (line 304) | fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
type Value (line 314) | type Value = Content<'de>;
function expecting (line 316) | fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
function visit_bool (line 320) | fn visit_bool<F>(self, value: bool) -> Result<Self::Value, F>
function visit_i8 (line 327) | fn visit_i8<F>(self, value: i8) -> Result<Self::Value, F>
function visit_i16 (line 334) | fn visit_i16<F>(self, value: i16) -> Result<Self::Value, F>
function visit_i32 (line 341) | fn visit_i32<F>(self, value: i32) -> Result<Self::Value, F>
function visit_i64 (line 348) | fn visit_i64<F>(self, value: i64) -> Result<Self::Value, F>
function visit_u8 (line 355) | fn visit_u8<F>(self, value: u8) -> Result<Self::Value, F>
function visit_u16 (line 362) | fn visit_u16<F>(self, value: u16) -> Result<Self::Value, F>
function visit_u32 (line 369) | fn visit_u32<F>(self, value: u32) -> Result<Self::Value, F>
function visit_u64 (line 376) | fn visit_u64<F>(self, value: u64) -> Result<Self::Value, F>
function visit_f32 (line 383) | fn visit_f32<F>(self, value: f32) -> Result<Self::Value, F>
function visit_f64 (line 390) | fn visit_f64<F>(self, value: f64) -> Result<Self::Value, F>
function visit_char (line 397) | fn visit_char<F>(self, value: char) -> Result<Self::Value, F>
function visit_str (line 404) | fn visit_str<F>(self, value: &str) -> Result<Self::Value, F>
function visit_borrowed_str (line 411) | fn visit_borrowed_str<F>(self, value: &'de str) -> Result<Self::Value, F>
function visit_string (line 418) | fn visit_string<F>(self, value: String) -> Result<Self::Value, F>
function visit_bytes (line 425) | fn visit_bytes<F>(self, value: &[u8]) -> Result<Self::Value, F>
function visit_borrowed_bytes (line 432) | fn visit_borrowed_bytes<F>(self, value: &'de [u8]) -> Result<Self::Value...
function visit_byte_buf (line 439) | fn visit_byte_buf<F>(self, value: Vec<u8>) -> Result<Self::Value, F>
function visit_unit (line 446) | fn visit_unit<F>(self) -> Result<Self::Value, F>
function visit_none (line 453) | fn visit_none<F>(self) -> Result<Self::Value, F>
function visit_some (line 460) | fn visit_some<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
function visit_newtype_struct (line 468) | fn visit_newtype_struct<D>(self, deserializer: D) -> Result<Self::Value,...
function visit_seq (line 476) | fn visit_seq<V>(self, mut visitor: V) -> Result<Self::Value, V::Error>
function visit_map (line 488) | fn visit_map<V>(self, mut visitor: V) -> Result<Self::Value, V::Error>
function visit_enum (line 504) | fn visit_enum<V>(self, _visitor: V) -> Result<Self::Value, V::Error>
type TagOrContent (line 517) | pub enum TagOrContent<'de> {
type TagOrContentVisitor (line 524) | struct TagOrContentVisitor<'de> {
function new (line 530) | fn new(name: &'static str) -> Self {
type Value (line 540) | type Value = TagOrContent<'de>;
function deserialize (line 542) | fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
type Value (line 554) | type Value = TagOrContent<'de>;
function expecting (line 556) | fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
function visit_bool (line 560) | fn visit_bool<F>(self, value: bool) -> Result<Self::Value, F>
function visit_i8 (line 569) | fn visit_i8<F>(self, value: i8) -> Result<Self::Value, F>
function visit_i16 (line 578) | fn visit_i16<F>(self, value: i16) -> Result<Self::Value, F>
function visit_i32 (line 587) | fn visit_i32<F>(self, value: i32) -> Result<Self::Value, F>
function visit_i64 (line 596) | fn visit_i64<F>(self, value: i64) -> Result<Self::Value, F>
function visit_u8 (line 605) | fn visit_u8<F>(self, value: u8) -> Result<Self::Value, F>
function visit_u16 (line 614) | fn visit_u16<F>(self, value: u16) -> Result<Self::Value, F>
function visit_u32 (line 623) | fn visit_u32<F>(self, value: u32) -> Result<Self::Value, F>
function visit_u64 (line 632) | fn visit_u64<F>(self, value: u64) -> Result<Self::Value, F>
function visit_f32 (line 641) | fn visit_f32<F>(self, value: f32) -> Result<Self::Value, F>
function visit_f64 (line 650) | fn visit_f64<F>(self, value: f64) -> Result<Self::Value, F>
function visit_char (line 659) | fn visit_char<F>(self, value: char) -> Result<Self::Value, F>
function visit_str (line 668) | fn visit_str<F>(self, value: &str) -> Result<Self::Value, F>
function visit_borrowed_str (line 681) | fn visit_borrowed_str<F>(self, value: &'de str) -> Result<Self::Value, F>
function visit_string (line 694) | fn visit_string<F>(self, value: String) -> Result<Self::Value, F>
function visit_bytes (line 707) | fn visit_bytes<F>(self, value: &[u8]) -> Result<Self::Value, F>
function visit_borrowed_bytes (line 720) | fn visit_borrowed_bytes<F>(self, value: &'de [u8]) -> Result<Self::Value...
function visit_byte_buf (line 733) | fn visit_byte_buf<F>(self, value: Vec<u8>) -> Result<Self::Value, F>
function visit_unit (line 746) | fn visit_unit<F>(self) -> Result<Self::Value, F>
function visit_none (line 755) | fn visit_none<F>(self) -> Result<Self::Value, F>
function visit_some (line 764) | fn visit_some<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
function visit_newtype_struct (line 773) | fn visit_newtype_struct<D>(self, deserializer: D) -> Result<Self::Value,...
function visit_seq (line 782) | fn visit_seq<V>(self, visitor: V) -> Result<Self::Value, V::Error>
function visit_map (line 791) | fn visit_map<V>(self, visitor: V) -> Result<Self::Value, V::Error>
function visit_enum (line 800) | fn visit_enum<V>(self, visitor: V) -> Result<Self::Value, V::Error>
type TaggedContentVisitor (line 816) | pub struct TaggedContentVisitor<T> {
function new (line 825) | pub fn new(name: &'static str, expecting: &'static str) -> Self {
type Value (line 839) | type Value = (T, Content<'de>);
function expecting (line 841) | fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
function visit_seq (line 845) | fn visit_seq<S>(self, mut seq: S) -> Result<Self::Value, S::Error>
function visit_map (line 859) | fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
type TagOrContentField (line 892) | pub enum TagOrContentField {
type TagOrContentFieldVisitor (line 898) | pub struct TagOrContentFieldVisitor {
type Value (line 907) | type Value = TagOrContentField;
method deserialize (line 909) | fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
type Value (line 919) | type Value = TagOrContentField;
method expecting (line 921) | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
method visit_u64 (line 925) | fn visit_u64<E>(self, field_index: u64) -> Result<Self::Value, E>
method visit_str (line 939) | fn visit_str<E>(self, field: &str) -> Result<Self::Value, E>
method visit_bytes (line 952) | fn visit_bytes<E>(self, field: &[u8]) -> Result<Self::Value, E>
type TagContentOtherField (line 970) | pub enum TagContentOtherField {
type TagContentOtherFieldVisitor (line 977) | pub struct TagContentOtherFieldVisitor {
type Value (line 986) | type Value = TagContentOtherField;
method deserialize (line 988) | fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
type Value (line 998) | type Value = TagContentOtherField;
method expecting (line 1000) | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
method visit_u64 (line 1008) | fn visit_u64<E>(self, field_index: u64) -> Result<Self::Value, E>
method visit_str (line 1019) | fn visit_str<E>(self, field: &str) -> Result<Self::Value, E>
method visit_bytes (line 1026) | fn visit_bytes<E>(self, field: &[u8]) -> Result<Self::Value, E>
type ContentDeserializer (line 1041) | pub struct ContentDeserializer<'de, E> {
function invalid_type (line 1051) | fn invalid_type(self, exp: &dyn Expected) -> E {
function deserialize_integer (line 1055) | fn deserialize_integer<V>(self, visitor: V) -> Result<V::Value, E>
function deserialize_float (line 1072) | fn deserialize_float<V>(self, visitor: V) -> Result<V::Value, E>
function visit_content_seq (line 1092) | fn visit_content_seq<'de, V, E>(content: Vec<Content<'de>>, visitor: V) ...
function visit_content_map (line 1103) | fn visit_content_map<'de, V, E>(
type Error (line 1124) | type Error = E;
function deserialize_any (line 1126) | fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_bool (line 1156) | fn deserialize_bool<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_i8 (line 1166) | fn deserialize_i8<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_i16 (line 1173) | fn deserialize_i16<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_i32 (line 1180) | fn deserialize_i32<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_i64 (line 1187) | fn deserialize_i64<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_u8 (line 1194) | fn deserialize_u8<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_u16 (line 1201) | fn deserialize_u16<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_u32 (line 1208) | fn deserialize_u32<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_u64 (line 1215) | fn deserialize_u64<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_f32 (line 1222) | fn deserialize_f32<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_f64 (line 1229) | fn deserialize_f64<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_char (line 1236) | fn deserialize_char<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_str (line 1248) | fn deserialize_str<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_string (line 1255) | fn deserialize_string<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_bytes (line 1268) | fn deserialize_bytes<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_byte_buf (line 1275) | fn deserialize_byte_buf<V>(self, visitor: V) -> Result<V::Value, Self::E...
function deserialize_option (line 1289) | fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_unit (line 1301) | fn deserialize_unit<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_unit_struct (line 1322) | fn deserialize_unit_struct<V>(
function deserialize_newtype_struct (line 1351) | fn deserialize_newtype_struct<V>(
function deserialize_seq (line 1365) | fn deserialize_seq<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_tuple (line 1375) | fn deserialize_tuple<V>(self, _len: usize, visitor: V) -> Result<V::Valu...
function deserialize_tuple_struct (line 1382) | fn deserialize_tuple_struct<V>(
function deserialize_map (line 1394) | fn deserialize_map<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_struct (line 1404) | fn deserialize_struct<V>(
function deserialize_enum (line 1420) | fn deserialize_enum<V>(
function deserialize_identifier (line 1462) | fn deserialize_identifier<V>(self, visitor: V) -> Result<V::Value, Self:...
function deserialize_ignored_any (line 1477) | fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value, Self...
function __deserialize_content_v1 (line 1485) | fn __deserialize_content_v1<V>(self, visitor: V) -> Result<V::Value, Sel...
function new (line 1496) | pub fn new(content: Content<'de>) -> Self {
type SeqDeserializer (line 1504) | struct SeqDeserializer<'de, E> {
function new (line 1511) | fn new(content: Vec<Content<'de>>) -> Self {
function end (line 1524) | fn end(self) -> Result<(), E> {
type Error (line 1544) | type Error = E;
function deserialize_any (line 1546) | fn deserialize_any<V>(mut self, visitor: V) -> Result<V::Value, Self::Er...
type Error (line 1567) | type Error = E;
function next_element_seed (line 1569) | fn next_element_seed<V>(&mut self, seed: V) -> Result<Option<V::Value>, ...
function size_hint (line 1582) | fn size_hint(&self) -> Option<usize> {
type ExpectedInSeq (line 1587) | struct ExpectedInSeq(usize);
method fmt (line 1591) | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
type MapDeserializer (line 1600) | struct MapDeserializer<'de, E> {
function new (line 1608) | fn new(content: Vec<(Content<'de>, Content<'de>)>) -> Self {
function end (line 1622) | fn end(self) -> Result<(), E> {
function next_pair (line 1638) | fn next_pair(&mut self) -> Option<(Content<'de>, Content<'de>)> {
type Error (line 1654) | type Error = E;
function deserialize_any (line 1656) | fn deserialize_any<V>(mut self, visitor: V) -> Result<V::Value, Self::Er...
function deserialize_seq (line 1665) | fn deserialize_seq<V>(mut self, visitor: V) -> Result<V::Value, Self::Er...
function deserialize_tuple (line 1674) | fn deserialize_tuple<V>(self, len: usize, visitor: V) -> Result<V::Value...
type Error (line 1694) | type Error = E;
function next_key_seed (line 1696) | fn next_key_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self...
function next_value_seed (line 1709) | fn next_value_seed<T>(&mut self, seed: T) -> Result<T::Value, Self::Error>
function next_entry_seed (line 1720) | fn next_entry_seed<TK, TV>(
function size_hint (line 1739) | fn size_hint(&self) -> Option<usize> {
type Error (line 1749) | type Error = E;
function next_element_seed (line 1751) | fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, ...
function size_hint (line 1764) | fn size_hint(&self) -> Option<usize> {
type PairDeserializer (line 1769) | struct PairDeserializer<'de, E>(Content<'de>, Content<'de>, PhantomData<...
type Error (line 1776) | type Error = E;
function deserialize_any (line 1784) | fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_seq (line 1791) | fn deserialize_seq<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_tuple (line 1807) | fn deserialize_tuple<V>(self, len: usize, visitor: V) -> Result<V::Value...
type PairVisitor (line 1821) | struct PairVisitor<'de, E>(Option<Content<'de>>, Option<Content<'de>>, P...
type Error (line 1828) | type Error = E;
function next_element_seed (line 1830) | fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, ...
function size_hint (line 1843) | fn size_hint(&self) -> Option<usize> {
type ExpectedInMap (line 1854) | struct ExpectedInMap(usize);
method fmt (line 1858) | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
type EnumDeserializer (line 1867) | pub struct EnumDeserializer<'de, E>
function new (line 1880) | pub fn new(variant: Content<'de>, value: Option<Content<'de>>) -> EnumDe...
type Error (line 1894) | type Error = E;
type Variant (line 1895) | type Variant = VariantDeserializer<'de, Self::Error>;
function variant_seed (line 1897) | fn variant_seed<V>(self, seed: V) -> Result<(V::Value, Self::Variant), E>
type VariantDeserializer (line 1910) | pub struct VariantDeserializer<'de, E>
type Error (line 1923) | type Error = E;
function unit_variant (line 1925) | fn unit_variant(self) -> Result<(), E> {
function newtype_variant_seed (line 1932) | fn newtype_variant_seed<T>(self, seed: T) -> Result<T::Value, E>
function tuple_variant (line 1945) | fn tuple_variant<V>(self, _len: usize, visitor: V) -> Result<V::Value, S...
function struct_variant (line 1964) | fn struct_variant<V>(
type ContentRefDeserializer (line 1992) | pub struct ContentRefDeserializer<'a, 'de: 'a, E> {
function invalid_type (line 2002) | fn invalid_type(self, exp: &dyn Expected) -> E {
function deserialize_integer (line 2006) | fn deserialize_integer<V>(self, visitor: V) -> Result<V::Value, E>
function deserialize_float (line 2023) | fn deserialize_float<V>(self, visitor: V) -> Result<V::Value, E>
function visit_content_seq_ref (line 2043) | fn visit_content_seq_ref<'a, 'de, V, E>(
function visit_content_map_ref (line 2057) | fn visit_content_map_ref<'a, 'de, V, E>(
type Error (line 2078) | type Error = E;
function deserialize_any (line 2080) | fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, E>
function deserialize_bool (line 2112) | fn deserialize_bool<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_i8 (line 2122) | fn deserialize_i8<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_i16 (line 2129) | fn deserialize_i16<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_i32 (line 2136) | fn deserialize_i32<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_i64 (line 2143) | fn deserialize_i64<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_u8 (line 2150) | fn deserialize_u8<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_u16 (line 2157) | fn deserialize_u16<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_u32 (line 2164) | fn deserialize_u32<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_u64 (line 2171) | fn deserialize_u64<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_f32 (line 2178) | fn deserialize_f32<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_f64 (line 2185) | fn deserialize_f64<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_char (line 2192) | fn deserialize_char<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_str (line 2204) | fn deserialize_str<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_string (line 2217) | fn deserialize_string<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_bytes (line 2224) | fn deserialize_bytes<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_byte_buf (line 2238) | fn deserialize_byte_buf<V>(self, visitor: V) -> Result<V::Value, Self::E...
function deserialize_option (line 2245) | fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, E>
function deserialize_unit (line 2266) | fn deserialize_unit<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_unit_struct (line 2276) | fn deserialize_unit_struct<V>(
function deserialize_newtype_struct (line 2287) | fn deserialize_newtype_struct<V>(self, _name: &str, visitor: V) -> Resul...
function deserialize_seq (line 2310) | fn deserialize_seq<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_tuple (line 2320) | fn deserialize_tuple<V>(self, _len: usize, visitor: V) -> Result<V::Valu...
function deserialize_tuple_struct (line 2327) | fn deserialize_tuple_struct<V>(
function deserialize_map (line 2339) | fn deserialize_map<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_struct (line 2349) | fn deserialize_struct<V>(
function deserialize_enum (line 2365) | fn deserialize_enum<V>(
function deserialize_identifier (line 2411) | fn deserialize_identifier<V>(self, visitor: V) -> Result<V::Value, Self:...
function deserialize_ignored_any (line 2426) | fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value, Self...
function __deserialize_content_v1 (line 2433) | fn __deserialize_content_v1<V>(self, visitor: V) -> Result<V::Value, Sel...
function new (line 2444) | pub fn new(content: &'a Content<'de>) -> Self {
method clone (line 2457) | fn clone(&self) -> Self {
type SeqRefDeserializer (line 2462) | struct SeqRefDeserializer<'a, 'de, E> {
function new (line 2469) | fn new(content: &'a [Content<'de>]) -> Self {
function end (line 2482) | fn end(self) -> Result<(), E> {
type Error (line 2502) | type Error = E;
function deserialize_any (line 2504) | fn deserialize_any<V>(mut self, visitor: V) -> Result<V::Value, Self::Er...
type Error (line 2525) | type Error = E;
function next_element_seed (line 2527) | fn next_element_seed<V>(&mut self, seed: V) -> Result<Option<V::Value>, ...
function size_hint (line 2541) | fn size_hint(&self) -> Option<usize> {
type MapRefDeserializer (line 2546) | struct MapRefDeserializer<'a, 'de, E> {
function new (line 2554) | fn new(content: &'a [(Content<'de>, Content<'de>)]) -> Self {
function end (line 2568) | fn end(self) -> Result<(), E> {
function next_pair (line 2584) | fn next_pair(&mut self) -> Option<(&'a Content<'de>, &'a Content<'de>)> {
type Error (line 2600) | type Error = E;
function deserialize_any (line 2602) | fn deserialize_any<V>(mut self, visitor: V) -> Result<V::Value, Self::Er...
function deserialize_seq (line 2611) | fn deserialize_seq<V>(mut self, visitor: V) -> Result<V::Value, Self::Er...
function deserialize_tuple (line 2620) | fn deserialize_tuple<V>(self, len: usize, visitor: V) -> Result<V::Value...
type Error (line 2640) | type Error = E;
function next_key_seed (line 2642) | fn next_key_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self...
function next_value_seed (line 2655) | fn next_value_seed<T>(&mut self, seed: T) -> Result<T::Value, Self::Error>
function next_entry_seed (line 2666) | fn next_entry_seed<TK, TV>(
function size_hint (line 2685) | fn size_hint(&self) -> Option<usize> {
type Error (line 2695) | type Error = E;
function next_element_seed (line 2697) | fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, ...
function size_hint (line 2710) | fn size_hint(&self) -> Option<usize> {
type PairRefDeserializer (line 2715) | struct PairRefDeserializer<'a, 'de, E>(&'a Content<'de>, &'a Content<'de...
type Error (line 2722) | type Error = E;
function deserialize_any (line 2730) | fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_seq (line 2737) | fn deserialize_seq<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_tuple (line 2753) | fn deserialize_tuple<V>(self, len: usize, visitor: V) -> Result<V::Value...
type PairRefVisitor (line 2767) | struct PairRefVisitor<'a, 'de, E>(
type Error (line 2778) | type Error = E;
function next_element_seed (line 2780) | fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, ...
function size_hint (line 2793) | fn size_hint(&self) -> Option<usize> {
type EnumRefDeserializer (line 2804) | struct EnumRefDeserializer<'a, 'de: 'a, E>
type Error (line 2818) | type Error = E;
type Variant (line 2819) | type Variant = VariantRefDeserializer<'a, 'de, Self::Error>;
function variant_seed (line 2821) | fn variant_seed<V>(self, seed: V) -> Result<(V::Value, Self::Variant), S...
type VariantRefDeserializer (line 2834) | struct VariantRefDeserializer<'a, 'de: 'a, E>
type Error (line 2847) | type Error = E;
function unit_variant (line 2849) | fn unit_variant(self) -> Result<(), E> {
function newtype_variant_seed (line 2860) | fn newtype_variant_seed<T>(self, seed: T) -> Result<T::Value, E>
function tuple_variant (line 2878) | fn tuple_variant<V>(self, _len: usize, visitor: V) -> Result<V::Value, S...
function struct_variant (line 2901) | fn struct_variant<V>(
type Deserializer (line 2934) | type Deserializer = Self;
function into_deserializer (line 2936) | fn into_deserializer(self) -> Self {
type Deserializer (line 2946) | type Deserializer = Self;
function into_deserializer (line 2948) | fn into_deserializer(self) -> Self {
type InternallyTaggedUnitVisitor (line 2956) | pub struct InternallyTaggedUnitVisitor<'a> {
function new (line 2963) | pub fn new(type_name: &'a str, variant_name: &'a str) -> Self {
type Value (line 2973) | type Value = ();
function expecting (line 2975) | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
function visit_seq (line 2983) | fn visit_seq<S>(self, _: S) -> Result<(), S::Error>
function visit_map (line 2990) | fn visit_map<M>(self, mut access: M) -> Result<(), M::Error>
type UntaggedUnitVisitor (line 3002) | pub struct UntaggedUnitVisitor<'a> {
function new (line 3009) | pub fn new(type_name: &'a str, variant_name: &'a str) -> Self {
type Value (line 3019) | type Value = ();
function expecting (line 3021) | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
function visit_unit (line 3029) | fn visit_unit<E>(self) -> Result<(), E>
function visit_none (line 3036) | fn visit_none<E>(self) -> Result<(), E>
type IdentifierDeserializer (line 3057) | pub trait IdentifierDeserializer<'de, E: Error> {
method from (line 3060) | fn from(self) -> Self::Deserializer;
type Borrowed (line 3063) | pub struct Borrowed<'de, T: 'de + ?Sized>(pub &'de T);
type Deserializer (line 3070) | type Deserializer = <u64 as IntoDeserializer<'de, E>>::Deserializer;
function from (line 3072) | fn from(self) -> Self::Deserializer {
type StrDeserializer (line 3077) | pub struct StrDeserializer<'a, E> {
type Error (line 3087) | type Error = E;
function deserialize_any (line 3089) | fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
type BorrowedStrDeserializer (line 3103) | pub struct BorrowedStrDeserializer<'de, E> {
type Error (line 3113) | type Error = E;
function deserialize_any (line 3115) | fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
type Deserializer (line 3134) | type Deserializer = StrDeserializer<'a, E>;
function from (line 3136) | fn from(self) -> Self::Deserializer {
type Deserializer (line 3149) | type Deserializer = BorrowedStrDeserializer<'de, E>;
function from (line 3151) | fn from(self) -> Self::Deserializer {
type Deserializer (line 3164) | type Deserializer = BytesDeserializer<'a, E>;
function from (line 3166) | fn from(self) -> Self::Deserializer {
type Deserializer (line 3176) | type Deserializer = BorrowedBytesDeserializer<'de, E>;
function from (line 3178) | fn from(self) -> Self::Deserializer {
type FlatMapDeserializer (line 3184) | pub struct FlatMapDeserializer<'a, 'de: 'a, E>(
function deserialize_other (line 3194) | fn deserialize_other<V>() -> Result<V, E> {
type Error (line 3219) | type Error = E;
function deserialize_any (line 3221) | fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_enum (line 3228) | fn deserialize_enum<V>(
function deserialize_map (line 3249) | fn deserialize_map<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_struct (line 3260) | fn deserialize_struct<V>(
function deserialize_newtype_struct (line 3277) | fn deserialize_newtype_struct<V>(self, _name: &str, visitor: V) -> Resul...
function deserialize_option (line 3284) | fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_unit (line 3294) | fn deserialize_unit<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_unit_struct (line 3301) | fn deserialize_unit_struct<V>(
function deserialize_ignored_any (line 3312) | fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value, Self...
type FlatMapAccess (line 3344) | struct FlatMapAccess<'a, 'de: 'a, E> {
type Error (line 3356) | type Error = E;
function next_key_seed (line 3358) | fn next_key_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self...
function next_value_seed (line 3376) | fn next_value_seed<T>(&mut self, seed: T) -> Result<T::Value, Self::Error>
type FlatStructAccess (line 3388) | struct FlatStructAccess<'a, 'de: 'a, E> {
type Error (line 3401) | type Error = E;
function next_key_seed (line 3403) | fn next_key_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self...
function next_value_seed (line 3416) | fn next_value_seed<T>(&mut self, seed: T) -> Result<T::Value, Self::Error>
function flat_map_take_entry (line 3430) | fn flat_map_take_entry<'de>(
type AdjacentlyTaggedEnumVariantSeed (line 3449) | pub struct AdjacentlyTaggedEnumVariantSeed<F> {
type AdjacentlyTaggedEnumVariantVisitor (line 3455) | pub struct AdjacentlyTaggedEnumVariantVisitor<F> {
type Value (line 3465) | type Value = F;
function expecting (line 3467) | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
function visit_enum (line 3471) | fn visit_enum<A>(self, data: A) -> Result<Self::Value, A::Error>
type Value (line 3486) | type Value = F;
function deserialize (line 3488) | fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
FILE: serde/src/private/ser.rs
function constrain (line 12) | pub fn constrain<T: ?Sized>(t: &T) -> &T {
function serialize_tagged_newtype (line 17) | pub fn serialize_tagged_newtype<S, T>(
type TaggedSerializer (line 38) | struct TaggedSerializer<S> {
type Unsupported (line 46) | enum Unsupported {
method fmt (line 63) | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
function bad_type (line 85) | fn bad_type(self, what: Unsupported) -> S::Error {
type Ok (line 98) | type Ok = S::Ok;
type Error (line 99) | type Error = S::Error;
type SerializeSeq (line 101) | type SerializeSeq = Impossible<S::Ok, S::Error>;
type SerializeTuple (line 102) | type SerializeTuple = Impossible<S::Ok, S::Error>;
type SerializeTupleStruct (line 103) | type SerializeTupleStruct = Impossible<S::Ok, S::Error>;
type SerializeMap (line 104) | type SerializeMap = S::SerializeMap;
type SerializeStruct (line 105) | type SerializeStruct = S::SerializeStruct;
type SerializeTupleVariant (line 108) | type SerializeTupleVariant = Impossible<S::Ok, S::Error>;
type SerializeTupleVariant (line 110) | type SerializeTupleVariant = SerializeTupleVariantAsMapValue<S::Serializ...
type SerializeStructVariant (line 113) | type SerializeStructVariant = Impossible<S::Ok, S::Error>;
type SerializeStructVariant (line 115) | type SerializeStructVariant = SerializeStructVariantAsMapValue<S::Serial...
method serialize_bool (line 117) | fn serialize_bool(self, _: bool) -> Result<Self::Ok, Self::Error> {
method serialize_i8 (line 121) | fn serialize_i8(self, _: i8) -> Result<Self::Ok, Self::Error> {
method serialize_i16 (line 125) | fn serialize_i16(self, _: i16) -> Result<Self::Ok, Self::Error> {
method serialize_i32 (line 129) | fn serialize_i32(self, _: i32) -> Result<Self::Ok, Self::Error> {
method serialize_i64 (line 133) | fn serialize_i64(self, _: i64) -> Result<Self::Ok, Self::Error> {
method serialize_u8 (line 137) | fn serialize_u8(self, _: u8) -> Result<Self::Ok, Self::Error> {
method serialize_u16 (line 141) | fn serialize_u16(self, _: u16) -> Result<Self::Ok, Self::Error> {
method serialize_u32 (line 145) | fn serialize_u32(self, _: u32) -> Result<Self::Ok, Self::Error> {
method serialize_u64 (line 149) | fn serialize_u64(self, _: u64) -> Result<Self::Ok, Self::Error> {
method serialize_f32 (line 153) | fn serialize_f32(self, _: f32) -> Result<Self::Ok, Self::Error> {
method serialize_f64 (line 157) | fn serialize_f64(self, _: f64) -> Result<Self::Ok, Self::Error> {
method serialize_char (line 161) | fn serialize_char(self, _: char) -> Result<Self::Ok, Self::Error> {
method serialize_str (line 165) | fn serialize_str(self, _: &str) -> Result<Self::Ok, Self::Error> {
method serialize_bytes (line 169) | fn serialize_bytes(self, _: &[u8]) -> Result<Self::Ok, Self::Error> {
method serialize_none (line 173) | fn serialize_none(self) -> Result<Self::Ok, Self::Error> {
method serialize_some (line 177) | fn serialize_some<T>(self, _: &T) -> Result<Self::Ok, Self::Error>
method serialize_unit (line 184) | fn serialize_unit(self) -> Result<Self::Ok, Self::Error> {
method serialize_unit_struct (line 190) | fn serialize_unit_struct(self, _: &'static str) -> Result<Self::Ok, Self...
method serialize_unit_variant (line 196) | fn serialize_unit_variant(
method serialize_newtype_struct (line 208) | fn serialize_newtype_struct<T>(
method serialize_newtype_variant (line 219) | fn serialize_newtype_variant<T>(
method serialize_seq (line 235) | fn serialize_seq(self, _: Option<usize>) -> Result<Self::SerializeSeq, S...
method serialize_tuple (line 239) | fn serialize_tuple(self, _: usize) -> Result<Self::SerializeTuple, Self:...
method serialize_tuple_struct (line 243) | fn serialize_tuple_struct(
method serialize_tuple_variant (line 252) | fn serialize_tuple_variant(
method serialize_tuple_variant (line 265) | fn serialize_tuple_variant(
method serialize_map (line 282) | fn serialize_map(self, len: Option<usize>) -> Result<Self::SerializeMap,...
method serialize_struct (line 288) | fn serialize_struct(
method serialize_struct_variant (line 299) | fn serialize_struct_variant(
method serialize_struct_variant (line 312) | fn serialize_struct_variant(
method collect_str (line 330) | fn collect_str<T>(self, _: &T) -> Result<Self::Ok, Self::Error>
type SerializeTupleVariantAsMapValue (line 344) | pub struct SerializeTupleVariantAsMapValue<M> {
function new (line 351) | pub fn new(map: M, name: &'static str, len: usize) -> Self {
type Ok (line 365) | type Ok = M::Ok;
type Error (line 366) | type Error = M::Error;
function serialize_field (line 368) | fn serialize_field<T>(&mut self, value: &T) -> Result<(), M::Error>
function end (line 377) | fn end(mut self) -> Result<M::Ok, M::Error> {
type SerializeStructVariantAsMapValue (line 385) | pub struct SerializeStructVariantAsMapValue<M> {
function new (line 392) | pub fn new(map: M, name: &'static str, len: usize) -> Self {
type Ok (line 406) | type Ok = M::Ok;
type Error (line 407) | type Error = M::Error;
function serialize_field (line 409) | fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result...
function end (line 418) | fn end(mut self) -> Result<M::Ok, M::Error> {
type Content (line 426) | pub enum Content {
method serialize (line 471) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
type ContentSerializer (line 552) | pub struct ContentSerializer<E> {
function new (line 557) | pub fn new() -> Self {
type Ok (line 567) | type Ok = Content;
type Error (line 568) | type Error = E;
type SerializeSeq (line 570) | type SerializeSeq = SerializeSeq<E>;
type SerializeTuple (line 571) | type SerializeTuple = SerializeTuple<E>;
type SerializeTupleStruct (line 572) | type SerializeTupleStruct = SerializeTupleStruct<E>;
type SerializeTupleVariant (line 573) | type SerializeTupleVariant = SerializeTupleVariant<E>;
type SerializeMap (line 574) | type SerializeMap = SerializeMap<E>;
type SerializeStruct (line 575) | type SerializeStruct = SerializeStruct<E>;
type SerializeStructVariant (line 576) | type SerializeStructVariant = SerializeStructVariant<E>;
method serialize_bool (line 578) | fn serialize_bool(self, v: bool) -> Result<Content, E> {
method serialize_i8 (line 582) | fn serialize_i8(self, v: i8) -> Result<Content, E> {
method serialize_i16 (line 586) | fn serialize_i16(self, v: i16) -> Result<Content, E> {
method serialize_i32 (line 590) | fn serialize_i32(self, v: i32) -> Result<Content, E> {
method serialize_i64 (line 594) | fn serialize_i64(self, v: i64) -> Result<Content, E> {
method serialize_u8 (line 598) | fn serialize_u8(self, v: u8) -> Result<Content, E> {
method serialize_u16 (line 602) | fn serialize_u16(self, v: u16) -> Result<Content, E> {
method serialize_u32 (line 606) | fn serialize_u32(self, v: u32) -> Result<Content, E> {
method serialize_u64 (line 610) | fn serialize_u64(self, v: u64) -> Result<Content, E> {
method serialize_f32 (line 614) | fn serialize_f32(self, v: f32) -> Result<Content, E> {
method serialize_f64 (line 618) | fn serialize_f64(self, v: f64) -> Result<Content, E> {
method serialize_char (line 622) | fn serialize_char(self, v: char) -> Result<Content, E> {
method serialize_str (line 626) | fn serialize_str(self, value: &str) -> Result<Content, E> {
method serialize_bytes (line 630) | fn serialize_bytes(self, value: &[u8]) -> Result<Content, E> {
method serialize_none (line 634) | fn serialize_none(self) -> Result<Content, E> {
method serialize_some (line 638) | fn serialize_some<T>(self, value: &T) -> Result<Content, E>
method serialize_unit (line 645) | fn serialize_unit(self) -> Result<Content, E> {
method serialize_unit_struct (line 649) | fn serialize_unit_struct(self, name: &'static str) -> Result<Content, E> {
method serialize_unit_variant (line 653) | fn serialize_unit_variant(
method serialize_newtype_struct (line 662) | fn serialize_newtype_struct<T>(self, name: &'static str, value: &T) -> R...
method serialize_newtype_variant (line 672) | fn serialize_newtype_variant<T>(
method serialize_seq (line 690) | fn serialize_seq(self, len: Option<usize>) -> Result<Self::SerializeSeq,...
method serialize_tuple (line 697) | fn serialize_tuple(self, len: usize) -> Result<Self::SerializeTuple, E> {
method serialize_tuple_struct (line 704) | fn serialize_tuple_struct(
method serialize_tuple_variant (line 716) | fn serialize_tuple_variant(
method serialize_map (line 732) | fn serialize_map(self, len: Option<usize>) -> Result<Self::SerializeMap,...
method serialize_struct (line 740) | fn serialize_struct(
method serialize_struct_variant (line 752) | fn serialize_struct_variant(
type SerializeSeq (line 769) | pub struct SerializeSeq<E> {
type Ok (line 779) | type Ok = Content;
type Error (line 780) | type Error = E;
function serialize_element (line 782) | fn serialize_element<T>(&mut self, value: &T) -> Result<(), E>
function end (line 791) | fn end(self) -> Result<Content, E> {
type SerializeTuple (line 796) | pub struct SerializeTuple<E> {
type Ok (line 806) | type Ok = Content;
type Error (line 807) | type Error = E;
function serialize_element (line 809) | fn serialize_element<T>(&mut self, value: &T) -> Result<(), E>
function end (line 818) | fn end(self) -> Result<Content, E> {
type SerializeTupleStruct (line 823) | pub struct SerializeTupleStruct<E> {
type Ok (line 834) | type Ok = Content;
type Error (line 835) | type Error = E;
function serialize_field (line 837) | fn serialize_field<T>(&mut self, value: &T) -> Result<(), E>
function end (line 846) | fn end(self) -> Result<Content, E> {
type SerializeTupleVariant (line 851) | pub struct SerializeTupleVariant<E> {
type Ok (line 864) | type Ok = Content;
type Error (line 865) | type Error = E;
function serialize_field (line 867) | fn serialize_field<T>(&mut self, value: &T) -> Result<(), E>
function end (line 876) | fn end(self) -> Result<Content, E> {
type SerializeMap (line 886) | pub struct SerializeMap<E> {
type Ok (line 897) | type Ok = Content;
type Error (line 898) | type Error = E;
function serialize_key (line 900) | fn serialize_key<T>(&mut self, key: &T) -> Result<(), E>
function serialize_value (line 909) | fn serialize_value<T>(&mut self, value: &T) -> Result<(), E>
function end (line 922) | fn end(self) -> Result<Content, E> {
function serialize_entry (line 926) | fn serialize_entry<K, V>(&mut self, key: &K, value: &V) -> Result<(), E>
type SerializeStruct (line 938) | pub struct SerializeStruct<E> {
type Ok (line 949) | type Ok = Content;
type Error (line 950) | type Error = E;
function serialize_field (line 952) | fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result...
function end (line 961) | fn end(self) -> Result<Content, E> {
type SerializeStructVariant (line 966) | pub struct SerializeStructVariant<E> {
type Ok (line 979) | type Ok = Content;
type Error (line 980) | type Error = E;
function serialize_field (line 982) | fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result...
function end (line 991) | fn end(self) -> Result<Content, E> {
type FlatMapSerializer (line 1003) | pub struct FlatMapSerializer<'a, M: 'a>(pub &'a mut M);
function bad_type (line 1010) | fn bad_type(what: Unsupported) -> M::Error {
type Ok (line 1024) | type Ok = ();
type Error (line 1025) | type Error = M::Error;
type SerializeSeq (line 1027) | type SerializeSeq = Impossible<Self::Ok, M::Error>;
type SerializeTuple (line 1028) | type SerializeTuple = Impossible<Self::Ok, M::Error>;
type SerializeTupleStruct (line 1029) | type SerializeTupleStruct = Impossible<Self::Ok, M::Error>;
type SerializeMap (line 1030) | type SerializeMap = FlatMapSerializeMap<'a, M>;
type SerializeStruct (line 1031) | type SerializeStruct = FlatMapSerializeStruct<'a, M>;
type SerializeTupleVariant (line 1032) | type SerializeTupleVariant = FlatMapSerializeTupleVariantAsMapValue<'a, M>;
type SerializeStructVariant (line 1033) | type SerializeStructVariant = FlatMapSerializeStructVariantAsMapValue<'a...
method serialize_bool (line 1035) | fn serialize_bool(self, _: bool) -> Result<Self::Ok, Self::Error> {
method serialize_i8 (line 1039) | fn serialize_i8(self, _: i8) -> Result<Self::Ok, Self::Error> {
method serialize_i16 (line 1043) | fn serialize_i16(self, _: i16) -> Result<Self::Ok, Self::Error> {
method serialize_i32 (line 1047) | fn serialize_i32(self, _: i32) -> Result<Self::Ok, Self::Error> {
method serialize_i64 (line 1051) | fn serialize_i64(self, _: i64) -> Result<Self::Ok, Self::Error> {
method serialize_u8 (line 1055) | fn serialize_u8(self, _: u8) -> Result<Self::Ok, Self::Error> {
method serialize_u16 (line 1059) | fn serialize_u16(self, _: u16) -> Result<Self::Ok, Self::Error> {
method serialize_u32 (line 1063) | fn serialize_u32(self, _: u32) -> Result<Self::Ok, Self::Error> {
method serialize_u64 (line 1067) | fn serialize_u64(self, _: u64) -> Result<Self::Ok, Self::Error> {
method serialize_f32 (line 1071) | fn serialize_f32(self, _: f32) -> Result<Self::Ok, Self::Error> {
method serialize_f64 (line 1075) | fn serialize_f64(self, _: f64) -> Result<Self::Ok, Self::Error> {
method serialize_char (line 1079) | fn serialize_char(self, _: char) -> Result<Self::Ok, Self::Error> {
method serialize_str (line 1083) | fn serialize_str(self, _: &str) -> Result<Self::Ok, Self::Error> {
method serialize_bytes (line 1087) | fn serialize_bytes(self, _: &[u8]) -> Result<Self::Ok, Self::Error> {
method serialize_none (line 1091) | fn serialize_none(self) -> Result<Self::Ok, Self::Error> {
method serialize_some (line 1095) | fn serialize_some<T>(self, value: &T) -> Result<Self::Ok, Self::Error>
method serialize_unit (line 1102) | fn serialize_unit(self) -> Result<Self::Ok, Self::Error> {
method serialize_unit_struct (line 1106) | fn serialize_unit_struct(self, _: &'static str) -> Result<Self::Ok, Self...
method serialize_unit_variant (line 1110) | fn serialize_unit_variant(
method serialize_newtype_struct (line 1119) | fn serialize_newtype_struct<T>(
method serialize_newtype_variant (line 1130) | fn serialize_newtype_variant<T>(
method serialize_seq (line 1143) | fn serialize_seq(self, _: Option<usize>) -> Result<Self::SerializeSeq, S...
method serialize_tuple (line 1147) | fn serialize_tuple(self, _: usize) -> Result<Self::SerializeTuple, Self:...
method serialize_tuple_struct (line 1151) | fn serialize_tuple_struct(
method serialize_tuple_variant (line 1159) | fn serialize_tuple_variant(
method serialize_map (line 1170) | fn serialize_map(self, _: Option<usize>) -> Result<Self::SerializeMap, S...
method serialize_struct (line 1174) | fn serialize_struct(
method serialize_struct_variant (line 1182) | fn serialize_struct_variant(
type FlatMapSerializeMap (line 1198) | pub struct FlatMapSerializeMap<'a, M: 'a>(&'a mut M);
type Ok (line 1206) | type Ok = ();
type Error (line 1207) | type Error = M::Error;
function serialize_key (line 1209) | fn serialize_key<T>(&mut self, key: &T) -> Result<(), Self::Error>
function serialize_value (line 1216) | fn serialize_value<T>(&mut self, value: &T) -> Result<(), Self::Error>
function serialize_entry (line 1223) | fn serialize_entry<K, V>(&mut self, key: &K, value: &V) -> Result<(), Se...
function end (line 1231) | fn end(self) -> Result<(), Self::Error> {
type FlatMapSerializeStruct (line 1237) | pub struct FlatMapSerializeStruct<'a, M: 'a>(&'a mut M);
type Ok (line 1245) | type Ok = ();
type Error (line 1246) | type Error = M::Error;
function serialize_field (line 1248) | fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result...
function end (line 1255) | fn end(self) -> Result<(), Self::Error> {
type FlatMapSerializeTupleVariantAsMapValue (line 1263) | pub struct FlatMapSerializeTupleVariantAsMapValue<'a, M: 'a> {
function new (line 1273) | fn new(map: &'a mut M) -> Self {
type Ok (line 1287) | type Ok = ();
type Error (line 1288) | type Error = M::Error;
function serialize_field (line 1290) | fn serialize_field<T>(&mut self, value: &T) -> Result<(), Self::Error>
function end (line 1299) | fn end(self) -> Result<(), Self::Error> {
type FlatMapSerializeStructVariantAsMapValue (line 1308) | pub struct FlatMapSerializeStructVariantAsMapValue<'a, M: 'a> {
function new (line 1319) | fn new(map: &'a mut M, name: &'static str) -> FlatMapSerializeStructVari...
type Ok (line 1334) | type Ok = ();
type Error (line 1335) | type Error = M::Error;
function serialize_field (line 1337) | fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result...
function end (line 1346) | fn end(self) -> Result<(), Self::Error> {
type AdjacentlyTaggedEnumVariant (line 1354) | pub struct AdjacentlyTaggedEnumVariant {
method serialize (line 1362) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
type CannotSerializeVariant (line 1372) | pub struct CannotSerializeVariant<T>(pub T);
method fmt (line 1379) | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
FILE: serde_core/build.rs
constant PRIVATE (line 7) | const PRIVATE: &str = "\
function main (line 18) | fn main() {
function rustc_minor_version (line 104) | fn rustc_minor_version() -> Option<u32> {
FILE: serde_core/src/de/ignored_any.rs
type IgnoredAny (line 111) | pub struct IgnoredAny;
type Value (line 114) | type Value = IgnoredAny;
method expecting (line 116) | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
method visit_bool (line 121) | fn visit_bool<E>(self, x: bool) -> Result<Self::Value, E> {
method visit_i64 (line 127) | fn visit_i64<E>(self, x: i64) -> Result<Self::Value, E> {
method visit_i128 (line 133) | fn visit_i128<E>(self, x: i128) -> Result<Self::Value, E> {
method visit_u64 (line 139) | fn visit_u64<E>(self, x: u64) -> Result<Self::Value, E> {
method visit_u128 (line 145) | fn visit_u128<E>(self, x: u128) -> Result<Self::Value, E> {
method visit_f64 (line 151) | fn visit_f64<E>(self, x: f64) -> Result<Self::Value, E> {
method visit_str (line 157) | fn visit_str<E>(self, s: &str) -> Result<Self::Value, E>
method visit_none (line 166) | fn visit_none<E>(self) -> Result<Self::Value, E> {
method visit_some (line 171) | fn visit_some<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
method visit_newtype_struct (line 179) | fn visit_newtype_struct<D>(self, deserializer: D) -> Result<Self::Valu...
method visit_unit (line 187) | fn visit_unit<E>(self) -> Result<Self::Value, E> {
method visit_seq (line 192) | fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
method visit_map (line 203) | fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error>
method visit_bytes (line 214) | fn visit_bytes<E>(self, bytes: &[u8]) -> Result<Self::Value, E>
method visit_enum (line 222) | fn visit_enum<A>(self, data: A) -> Result<Self::Value, A::Error>
method deserialize (line 232) | fn deserialize<D>(deserializer: D) -> Result<IgnoredAny, D::Error>
FILE: serde_core/src/de/impls.rs
type UnitVisitor (line 14) | struct UnitVisitor;
type Value (line 17) | type Value = ();
method expecting (line 19) | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
method visit_unit (line 23) | fn visit_unit<E>(self) -> Result<Self::Value, E>
function deserialize (line 32) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
function deserialize (line 43) | fn deserialize<D>(_deserializer: D) -> Result<Self, D::Error>
type BoolVisitor (line 53) | struct BoolVisitor;
type Value (line 56) | type Value = bool;
method expecting (line 58) | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
method visit_bool (line 62) | fn visit_bool<E>(self, v: bool) -> Result<Self::Value, E>
function deserialize (line 71) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
type CharVisitor (line 537) | struct CharVisitor;
type Value (line 540) | type Value = char;
method expecting (line 542) | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
method visit_char (line 547) | fn visit_char<E>(self, v: char) -> Result<Self::Value, E>
method visit_str (line 555) | fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
function deserialize (line 569) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
type StringVisitor (line 580) | struct StringVisitor;
type Value (line 586) | type Value = String;
method expecting (line 588) | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
method visit_str (line 592) | fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
method visit_string (line 599) | fn visit_string<E>(self, v: String) -> Result<Self::Value, E>
method visit_bytes (line 606) | fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
method visit_byte_buf (line 616) | fn visit_byte_buf<E>(self, v: Vec<u8>) -> Result<Self::Value, E>
type StringInPlaceVisitor (line 582) | struct StringInPlaceVisitor<'a>(&'a mut String);
type Value (line 632) | type Value = ();
function expecting (line 634) | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
function visit_str (line 638) | fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
function visit_string (line 647) | fn visit_string<E>(self, v: String) -> Result<Self::Value, E>
function visit_bytes (line 655) | fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
function visit_byte_buf (line 669) | fn visit_byte_buf<E>(self, v: Vec<u8>) -> Result<Self::Value, E>
method deserialize (line 689) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
method deserialize_in_place (line 696) | fn deserialize_in_place<D>(deserializer: D, place: &mut Self) -> Result<...
type StrVisitor (line 706) | struct StrVisitor;
type Value (line 709) | type Value = &'a str;
method expecting (line 711) | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
method visit_borrowed_str (line 715) | fn visit_borrowed_str<E>(self, v: &'a str) -> Result<Self::Value, E>
method visit_borrowed_bytes (line 722) | fn visit_borrowed_bytes<E>(self, v: &'a [u8]) -> Result<Self::Value, E>
function deserialize (line 731) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
type BytesVisitor (line 741) | struct BytesVisitor;
type Value (line 744) | type Value = &'a [u8];
method expecting (line 746) | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
method visit_borrowed_bytes (line 750) | fn visit_borrowed_bytes<E>(self, v: &'a [u8]) -> Result<Self::Value, E>
method visit_borrowed_str (line 757) | fn visit_borrowed_str<E>(self, v: &'a str) -> Result<Self::Value, E>
function deserialize (line 766) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
type CStringVisitor (line 777) | struct CStringVisitor;
type Value (line 781) | type Value = CString;
method expecting (line 783) | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
method visit_seq (line 787) | fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
method visit_bytes (line 801) | fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
method visit_byte_buf (line 808) | fn visit_byte_buf<E>(self, v: Vec<u8>) -> Result<Self::Value, E>
method visit_str (line 815) | fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
method visit_string (line 822) | fn visit_string<E>(self, v: String) -> Result<Self::Value, E>
method deserialize (line 833) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
type OptionVisitor (line 870) | struct OptionVisitor<T> {
type Value (line 878) | type Value = Option<T>;
function expecting (line 880) | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
function visit_unit (line 885) | fn visit_unit<E>(self) -> Result<Self::Value, E>
function visit_none (line 893) | fn visit_none<E>(self) -> Result<Self::Value, E>
function visit_some (line 901) | fn visit_some<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
function __private_visit_untagged_option (line 908) | fn __private_visit_untagged_option<D>(self, deserializer: D) -> Result<S...
function deserialize (line 920) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
type PhantomDataVisitor (line 938) | struct PhantomDataVisitor<T: ?Sized> {
type Value (line 946) | type Value = PhantomData<T>;
function expecting (line 948) | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
function visit_unit (line 953) | fn visit_unit<E>(self) -> Result<Self::Value, E>
function deserialize (line 965) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
function nop_reserve (line 1074) | fn nop_reserve<T>(_seq: T, _n: usize) {}
function deserialize (line 1139) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
function deserialize_in_place (line 1178) | fn deserialize_in_place<D>(deserializer: D, place: &mut Self) -> Result<...
type ArrayVisitor (line 1228) | struct ArrayVisitor<A> {
type ArrayInPlaceVisitor (line 1231) | struct ArrayInPlaceVisitor<'a, A: 'a>(&'a mut A);
function new (line 1234) | fn new() -> Self {
type Value (line 1242) | type Value = [T; 0];
function expecting (line 1244) | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
function visit_seq (line 1249) | fn visit_seq<A>(self, _: A) -> Result<Self::Value, A::Error>
function deserialize (line 1259) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
function deserialize (line 1707) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
function deserialize (line 1753) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
type PathVisitor (line 1785) | struct PathVisitor;
type Value (line 1789) | type Value = &'a Path;
method expecting (line 1791) | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
method visit_borrowed_str (line 1795) | fn visit_borrowed_str<E>(self, v: &'a str) -> Result<Self::Value, E>
method visit_borrowed_bytes (line 1802) | fn visit_borrowed_bytes<E>(self, v: &'a [u8]) -> Result<Self::Value, E>
function deserialize (line 1815) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
type PathBufVisitor (line 1824) | struct PathBufVisitor;
type Value (line 1828) | type Value = PathBuf;
method expecting (line 1830) | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
method visit_str (line 1834) | fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
method visit_string (line 1841) | fn visit_string<E>(self, v: String) -> Result<Self::Value, E>
method visit_bytes (line 1848) | fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
method visit_byte_buf (line 1857) | fn visit_byte_buf<E>(self, v: Vec<u8>) -> Result<Self::Value, E>
method deserialize (line 1870) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
type OsStringVisitor (line 1898) | struct OsStringVisitor;
type Value (line 1902) | type Value = OsString;
method expecting (line 1904) | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
method visit_enum (line 1909) | fn visit_enum<A>(self, data: A) -> Result<Self::Value, A::Error>
method visit_enum (line 1924) | fn visit_enum<A>(self, data: A) -> Result<Self::Value, A::Error>
method deserialize (line 1944) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
function deserialize (line 1986) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
function deserialize (line 2009) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
function deserialize (line 2031) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
function deserialize (line 2095) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
method deserialize (line 2130) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
method deserialize (line 2272) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
function deserialize (line 2427) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
function deserialize (line 2447) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
constant FIELDS (line 2469) | pub const FIELDS: &[&str] = &["start", "end"];
type Field (line 2475) | enum Field {
method deserialize (line 2481) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
method deserialize (line 2639) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
method deserialize (line 2778) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
type RangeVisitor (line 2524) | pub struct RangeVisitor<Idx> {
type Value (line 2533) | type Value = (Idx, Idx);
function expecting (line 2535) | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
function visit_seq (line 2539) | fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
function visit_map (line 2558) | fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error>
function deserialize (line 2606) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
constant FIELDS (line 2628) | pub const FIELDS: &[&str] = &["start"];
type Field (line 2634) | enum Field {
method deserialize (line 2481) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
method deserialize (line 2639) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
method deserialize (line 2778) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
type RangeFromVisitor (line 2680) | pub struct RangeFromVisitor<Idx> {
type Value (line 2689) | type Value = Idx;
function expecting (line 2691) | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
function visit_seq (line 2695) | fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
function visit_map (line 2708) | fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error>
function deserialize (line 2745) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
constant FIELDS (line 2767) | pub const FIELDS: &[&str] = &["end"];
type Field (line 2773) | enum Field {
method deserialize (line 2481) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
method deserialize (line 2639) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
method deserialize (line 2778) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
type RangeToVisitor (line 2819) | pub struct RangeToVisitor<Idx> {
type Value (line 2828) | type Value = Idx;
function expecting (line 2830) | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
function visit_seq (line 2834) | fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
function visit_map (line 2847) | fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error>
function deserialize (line 2877) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
function deserialize (line 2987) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
function deserialize (line 3094) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
type FromStrVisitor (line 3140) | struct FromStrVisitor<T> {
function new (line 3147) | fn new(expecting: &'static str) -> Self {
type Value (line 3161) | type Value = T;
function expecting (line 3163) | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
function visit_str (line 3167) | fn visit_str<E>(self, s: &str) -> Result<Self::Value, E>
FILE: serde_core/src/de/mod.rs
type Unexpected (line 338) | pub enum Unexpected<'a> {
function fmt (line 402) | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
type Expected (line 484) | pub trait Expected {
method fmt (line 487) | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result;
method fmt (line 494) | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
method fmt (line 500) | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
method fmt (line 506) | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
type Deserialize (line 554) | pub trait Deserialize<'de>: Sized {
method deserialize (line 561) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
method deserialize_in_place (line 585) | fn deserialize_in_place<D>(deserializer: D, place: &mut Self) -> Resul...
type DeserializeOwned (line 632) | pub trait DeserializeOwned: for<'de> Deserialize<'de> {}
type DeserializeSeed (line 803) | pub trait DeserializeSeed<'de>: Sized {
method deserialize (line 809) | fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
type Value (line 818) | type Value = T;
function deserialize (line 821) | fn deserialize<D>(self, deserializer: D) -> Result<T, D::Error>
type Deserializer (line 945) | pub trait Deserializer<'de>: Sized {
method deserialize_any (line 959) | fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
method deserialize_bool (line 964) | fn deserialize_bool<V>(self, visitor: V) -> Result<V::Value, Self::Error>
method deserialize_i8 (line 969) | fn deserialize_i8<V>(self, visitor: V) -> Result<V::Value, Self::Error>
method deserialize_i16 (line 974) | fn deserialize_i16<V>(self, visitor: V) -> Result<V::Value, Self::Error>
method deserialize_i32 (line 979) | fn deserialize_i32<V>(self, visitor: V) -> Result<V::Value, Self::Error>
method deserialize_i64 (line 984) | fn deserialize_i64<V>(self, visitor: V) -> Result<V::Value, Self::Error>
method deserialize_i128 (line 991) | fn deserialize_i128<V>(self, visitor: V) -> Result<V::Value, Self::Error>
method deserialize_u8 (line 1000) | fn deserialize_u8<V>(self, visitor: V) -> Result<V::Value, Self::Error>
method deserialize_u16 (line 1005) | fn deserialize_u16<V>(self, visitor: V) -> Result<V::Value, Self::Error>
method deserialize_u32 (line 1010) | fn deserialize_u32<V>(self, visitor: V) -> Result<V::Value, Self::Error>
method deserialize_u64 (line 1015) | fn deserialize_u64<V>(self, visitor: V) -> Result<V::Value, Self::Error>
method deserialize_u128 (line 1022) | fn deserialize_u128<V>(self, visitor: V) -> Result<V::Value, Self::Error>
method deserialize_f32 (line 1031) | fn deserialize_f32<V>(self, visitor: V) -> Result<V::Value, Self::Error>
method deserialize_f64 (line 1036) | fn deserialize_f64<V>(self, visitor: V) -> Result<V::Value, Self::Error>
method deserialize_char (line 1041) | fn deserialize_char<V>(self, visitor: V) -> Result<V::Value, Self::Error>
method deserialize_str (line 1052) | fn deserialize_str<V>(self, visitor: V) -> Result<V::Value, Self::Error>
method deserialize_string (line 1063) | fn deserialize_string<V>(self, visitor: V) -> Result<V::Value, Self::E...
method deserialize_bytes (line 1074) | fn deserialize_bytes<V>(self, visitor: V) -> Result<V::Value, Self::Er...
method deserialize_byte_buf (line 1085) | fn deserialize_byte_buf<V>(self, visitor: V) -> Result<V::Value, Self:...
method deserialize_option (line 1094) | fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, Self::E...
method deserialize_unit (line 1099) | fn deserialize_unit<V>(self, visitor: V) -> Result<V::Value, Self::Error>
method deserialize_unit_struct (line 1105) | fn deserialize_unit_struct<V>(
method deserialize_newtype_struct (line 1115) | fn deserialize_newtype_struct<V>(
method deserialize_seq (line 1124) | fn deserialize_seq<V>(self, visitor: V) -> Result<V::Value, Self::Error>
method deserialize_tuple (line 1130) | fn deserialize_tuple<V>(self, len: usize, visitor: V) -> Result<V::Val...
method deserialize_tuple_struct (line 1136) | fn deserialize_tuple_struct<V>(
method deserialize_map (line 1146) | fn deserialize_map<V>(self, visitor: V) -> Result<V::Value, Self::Error>
method deserialize_struct (line 1152) | fn deserialize_struct<V>(
method deserialize_enum (line 1163) | fn deserialize_enum<V>(
method deserialize_identifier (line 1174) | fn deserialize_identifier<V>(self, visitor: V) -> Result<V::Value, Sel...
method deserialize_ignored_any (line 1182) | fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value, Se...
method is_human_readable (line 1253) | fn is_human_readable(&self) -> bool {
method __deserialize_content_v1 (line 1260) | fn __deserialize_content_v1<V>(self, visitor: V) -> Result<V::Value, S...
type Visitor (line 1317) | pub trait Visitor<'de>: Sized {
method expecting (line 1343) | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result;
method visit_bool (line 1348) | fn visit_bool<E>(self, v: bool) -> Result<Self::Value, E>
method visit_i8 (line 1360) | fn visit_i8<E>(self, v: i8) -> Result<Self::Value, E>
method visit_i16 (line 1372) | fn visit_i16<E>(self, v: i16) -> Result<Self::Value, E>
method visit_i32 (line 1384) | fn visit_i32<E>(self, v: i32) -> Result<Self::Value, E>
method visit_i64 (line 1394) | fn visit_i64<E>(self, v: i64) -> Result<Self::Value, E>
method visit_i128 (line 1404) | fn visit_i128<E>(self, v: i128) -> Result<Self::Value, E>
method visit_u8 (line 1422) | fn visit_u8<E>(self, v: u8) -> Result<Self::Value, E>
method visit_u16 (line 1434) | fn visit_u16<E>(self, v: u16) -> Result<Self::Value, E>
method visit_u32 (line 1446) | fn visit_u32<E>(self, v: u32) -> Result<Self::Value, E>
method visit_u64 (line 1456) | fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
method visit_u128 (line 1466) | fn visit_u128<E>(self, v: u128) -> Result<Self::Value, E>
method visit_f32 (line 1484) | fn visit_f32<E>(self, v: f32) -> Result<Self::Value, E>
method visit_f64 (line 1494) | fn visit_f64<E>(self, v: f64) -> Result<Self::Value, E>
method visit_char (line 1508) | fn visit_char<E>(self, v: char) -> Result<Self::Value, E>
method visit_str (line 1526) | fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
method visit_borrowed_str (line 1543) | fn visit_borrowed_str<E>(self, v: &'de str) -> Result<Self::Value, E>
method visit_string (line 1568) | fn visit_string<E>(self, v: String) -> Result<Self::Value, E>
method visit_bytes (line 1586) | fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
method visit_borrowed_bytes (line 1602) | fn visit_borrowed_bytes<E>(self, v: &'de [u8]) -> Result<Self::Value, E>
method visit_byte_buf (line 1627) | fn visit_byte_buf<E>(self, v: Vec<u8>) -> Result<Self::Value, E>
method visit_none (line 1637) | fn visit_none<E>(self) -> Result<Self::Value, E>
method visit_some (line 1647) | fn visit_some<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
method visit_unit (line 1658) | fn visit_unit<E>(self) -> Result<Self::Value, E>
method visit_newtype_struct (line 1671) | fn visit_newtype_struct<D>(self, deserializer: D) -> Result<Self::Valu...
method visit_seq (line 1682) | fn visit_seq<A>(self, seq: A) -> Result<Self::Value, A::Error>
method visit_map (line 1693) | fn visit_map<A>(self, map: A) -> Result<Self::Value, A::Error>
method visit_enum (line 1704) | fn visit_enum<A>(self, data: A) -> Result<Self::Value, A::Error>
method __private_visit_untagged_option (line 1714) | fn __private_visit_untagged_option<D>(self, _: D) -> Result<Self::Valu...
type SeqAccess (line 1749) | pub trait SeqAccess<'de> {
method next_element_seed (line 1759) | fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>...
method next_element (line 1769) | fn next_element<T>(&mut self) -> Result<Option<T>, Self::Error>
method size_hint (line 1778) | fn size_hint(&self) -> Option<usize> {
type Error (line 1787) | type Error = A::Error;
function next_element_seed (line 1790) | fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, ...
function next_element (line 1798) | fn next_element<T>(&mut self) -> Result<Option<T>, Self::Error>
function size_hint (line 1806) | fn size_hint(&self) -> Option<usize> {
type MapAccess (line 1837) | pub trait MapAccess<'de> {
method next_key_seed (line 1847) | fn next_key_seed<K>(&mut self, seed: K) -> Result<Option<K::Value>, Se...
method next_value_seed (line 1860) | fn next_value_seed<V>(&mut self, seed: V) -> Result<V::Value, Self::Er...
method next_entry_seed (line 1873) | fn next_entry_seed<K, V>(
method next_key (line 1897) | fn next_key<K>(&mut self) -> Result<Option<K>, Self::Error>
method next_value (line 1914) | fn next_value<V>(&mut self) -> Result<V, Self::Error>
method next_entry (line 1927) | fn next_entry<K, V>(&mut self) -> Result<Option<(K, V)>, Self::Error>
method size_hint (line 1937) | fn size_hint(&self) -> Option<usize> {
type Error (line 1946) | type Error = A::Error;
function next_key_seed (line 1949) | fn next_key_seed<K>(&mut self, seed: K) -> Result<Option<K::Value>, Self...
function next_value_seed (line 1957) | fn next_value_seed<V>(&mut self, seed: V) -> Result<V::Value, Self::Error>
function next_entry_seed (line 1965) | fn next_entry_seed<K, V>(
function next_entry (line 1978) | fn next_entry<K, V>(&mut self) -> Result<Option<(K, V)>, Self::Error>
function next_key (line 1987) | fn next_key<K>(&mut self) -> Result<Option<K>, Self::Error>
function next_value (line 1995) | fn next_value<V>(&mut self) -> Result<V, Self::Error>
function size_hint (line 2003) | fn size_hint(&self) -> Option<usize> {
type EnumAccess (line 2035) | pub trait EnumAccess<'de>: Sized {
method variant_seed (line 2047) | fn variant_seed<V>(self, seed: V) -> Result<(V::Value, Self::Variant),...
method variant (line 2056) | fn variant<V>(self) -> Result<(V, Self::Variant), Self::Error>
type VariantAccess (line 2088) | pub trait VariantAccess<'de>: Sized {
method unit_variant (line 2128) | fn unit_variant(self) -> Result<(), Self::Error>;
method newtype_variant_seed (line 2170) | fn newtype_variant_seed<T>(self, seed: T) -> Result<T::Value, Self::Er...
method newtype_variant (line 2180) | fn newtype_variant<T>(self) -> Result<T, Self::Error>
method tuple_variant (line 2226) | fn tuple_variant<V>(self, len: usize, visitor: V) -> Result<V::Value, ...
method struct_variant (line 2273) | fn struct_variant<V>(
type IntoDeserializer (line 2316) | pub trait IntoDeserializer<'de, E: Error = value::Error> {
method into_deserializer (line 2321) | fn into_deserializer(self) -> Self::Deserializer;
type OneOf (line 2333) | struct OneOf {
method fmt (line 2338) | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
type WithDecimalPoint (line 2357) | struct WithDecimalPoint(f64);
method fmt (line 2360) | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
FILE: serde_core/src/de/value.rs
type Error (line 52) | pub struct Error {
method custom (line 64) | fn custom<T>(msg: T) -> Self
method custom (line 75) | fn custom<T>(msg: T) -> Self
method custom (line 86) | fn custom<T>(msg: T) -> Self
method description (line 118) | fn description(&self) -> &str {
type ErrorImpl (line 57) | type ErrorImpl = Box<str>;
type ErrorImpl (line 59) | type ErrorImpl = ();
method fmt (line 96) | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
method fmt (line 101) | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
method fmt (line 107) | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
type Deserializer (line 129) | type Deserializer = UnitDeserializer<E>;
function into_deserializer (line 131) | fn into_deserializer(self) -> UnitDeserializer<E> {
type UnitDeserializer (line 137) | pub struct UnitDeserializer<E> {
function new (line 145) | pub fn new() -> Self {
type Error (line 156) | type Error = E;
method custom (line 64) | fn custom<T>(msg: T) -> Self
method custom (line 75) | fn custom<T>(msg: T) -> Self
method custom (line 86) | fn custom<T>(msg: T) -> Self
method description (line 118) | fn description(&self) -> &str {
function deserialize_any (line 164) | fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_option (line 171) | fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, Self::Error>
type Deserializer (line 183) | type Deserializer = Self;
function into_deserializer (line 185) | fn into_deserializer(self) -> Self {
method fmt (line 191) | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
type NeverDeserializer (line 201) | pub struct NeverDeserializer<E> {
type Deserializer (line 212) | type Deserializer = NeverDeserializer<E>;
function into_deserializer (line 214) | fn into_deserializer(self) -> Self::Deserializer {
type Error (line 224) | type Error = E;
method custom (line 64) | fn custom<T>(msg: T) -> Self
method custom (line 75) | fn custom<T>(msg: T) -> Self
method custom (line 86) | fn custom<T>(msg: T) -> Self
method description (line 118) | fn description(&self) -> &str {
function deserialize_any (line 226) | fn deserialize_any<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
type Deserializer (line 245) | type Deserializer = Self;
function into_deserializer (line 247) | fn into_deserializer(self) -> Self {
type U32Deserializer (line 345) | pub struct U32Deserializer<E> {
type Deserializer (line 356) | type Deserializer = U32Deserializer<E>;
function into_deserializer (line 358) | fn into_deserializer(self) -> U32Deserializer<E> {
function new (line 365) | pub fn new(value: u32) -> Self {
type Error (line 377) | type Error = E;
method custom (line 64) | fn custom<T>(msg: T) -> Self
method custom (line 75) | fn custom<T>(msg: T) -> Self
method custom (line 86) | fn custom<T>(msg: T) -> Self
method description (line 118) | fn description(&self) -> &str {
function deserialize_any (line 385) | fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_enum (line 392) | fn deserialize_enum<V>(
type Deserializer (line 411) | type Deserializer = Self;
function into_deserializer (line 413) | fn into_deserializer(self) -> Self {
type Error (line 422) | type Error = E;
method custom (line 64) | fn custom<T>(msg: T) -> Self
method custom (line 75) | fn custom<T>(msg: T) -> Self
method custom (line 86) | fn custom<T>(msg: T) -> Self
method description (line 118) | fn description(&self) -> &str {
type Variant (line 423) | type Variant = private::UnitOnly<E>;
function variant_seed (line 425) | fn variant_seed<T>(self, seed: T) -> Result<(T::Value, Self::Variant), S...
method fmt (line 434) | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
type StrDeserializer (line 445) | pub struct StrDeserializer<'a, E> {
type Deserializer (line 456) | type Deserializer = StrDeserializer<'a, E>;
function into_deserializer (line 458) | fn into_deserializer(self) -> StrDeserializer<'a, E> {
function new (line 465) | pub fn new(value: &'a str) -> Self {
type Error (line 477) | type Error = E;
method custom (line 64) | fn custom<T>(msg: T) -> Self
method custom (line 75) | fn custom<T>(msg: T) -> Self
method custom (line 86) | fn custom<T>(msg: T) -> Self
method description (line 118) | fn description(&self) -> &str {
function deserialize_any (line 479) | fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_enum (line 486) | fn deserialize_enum<V>(
type Deserializer (line 511) | type Deserializer = Self;
function into_deserializer (line 513) | fn into_deserializer(self) -> Self {
type Error (line 522) | type Error = E;
method custom (line 64) | fn custom<T>(msg: T) -> Self
method custom (line 75) | fn custom<T>(msg: T) -> Self
method custom (line 86) | fn custom<T>(msg: T) -> Self
method description (line 118) | fn description(&self) -> &str {
type Variant (line 523) | type Variant = private::UnitOnly<E>;
function variant_seed (line 525) | fn variant_seed<T>(self, seed: T) -> Result<(T::Value, Self::Variant), S...
method fmt (line 534) | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
type BorrowedStrDeserializer (line 546) | pub struct BorrowedStrDeserializer<'de, E> {
function new (line 555) | pub fn new(value: &'de str) -> BorrowedStrDeserializer<'de, E> {
type Error (line 567) | type Error = E;
method custom (line 64) | fn custom<T>(msg: T) -> Self
method custom (line 75) | fn custom<T>(msg: T) -> Self
method custom (line 86) | fn custom<T>(msg: T) -> Self
method description (line 118) | fn description(&self) -> &str {
function deserialize_any (line 569) | fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_enum (line 576) | fn deserialize_enum<V>(
type Deserializer (line 601) | type Deserializer = Self;
function into_deserializer (line 603) | fn into_deserializer(self) -> Self {
type Error (line 612) | type Error = E;
method custom (line 64) | fn custom<T>(msg: T) -> Self
method custom (line 75) | fn custom<T>(msg: T) -> Self
method custom (line 86) | fn custom<T>(msg: T) -> Self
method description (line 118) | fn description(&self) -> &str {
type Variant (line 613) | type Variant = private::UnitOnly<E>;
function variant_seed (line 615) | fn variant_seed<T>(self, seed: T) -> Result<(T::Value, Self::Variant), S...
method fmt (line 624) | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
type StringDeserializer (line 637) | pub struct StringDeserializer<E> {
method clone (line 644) | fn clone(&self) -> Self {
type Deserializer (line 658) | type Deserializer = StringDeserializer<E>;
method into_deserializer (line 660) | fn into_deserializer(self) -> StringDeserializer<E> {
function new (line 668) | pub fn new(value: String) -> Self {
type Error (line 681) | type Error = E;
method custom (line 64) | fn custom<T>(msg: T) -> Self
method custom (line 75) | fn custom<T>(msg: T) -> Self
method custom (line 86) | fn custom<T>(msg: T) -> Self
method description (line 118) | fn description(&self) -> &str {
function deserialize_any (line 683) | fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_enum (line 690) | fn deserialize_enum<V>(
type Deserializer (line 716) | type Deserializer = Self;
function into_deserializer (line 718) | fn into_deserializer(self) -> Self {
type Error (line 728) | type Error = E;
method custom (line 64) | fn custom<T>(msg: T) -> Self
method custom (line 75) | fn custom<T>(msg: T) -> Self
method custom (line 86) | fn custom<T>(msg: T) -> Self
method description (line 118) | fn description(&self) -> &str {
type Variant (line 729) | type Variant = private::UnitOnly<E>;
function variant_seed (line 731) | fn variant_seed<T>(self, seed: T) -> Result<(T::Value, Self::Variant), S...
method fmt (line 741) | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
type CowStrDeserializer (line 754) | pub struct CowStrDeserializer<'a, E> {
method clone (line 761) | fn clone(&self) -> Self {
type Deserializer (line 775) | type Deserializer = CowStrDeserializer<'a, E>;
function into_deserializer (line 777) | fn into_deserializer(self) -> CowStrDeserializer<'a, E> {
function new (line 785) | pub fn new(value: Cow<'a, str>) -> Self {
type Error (line 798) | type Error = E;
method custom (line 64) | fn custom<T>(msg: T) -> Self
method custom (line 75) | fn custom<T>(msg: T) -> Self
method custom (line 86) | fn custom<T>(msg: T) -> Self
method description (line 118) | fn description(&self) -> &str {
function deserialize_any (line 800) | fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_enum (line 810) | fn deserialize_enum<V>(
type Deserializer (line 836) | type Deserializer = Self;
function into_deserializer (line 838) | fn into_deserializer(self) -> Self {
type Error (line 848) | type Error = E;
method custom (line 64) | fn custom<T>(msg: T) -> Self
method custom (line 75) | fn custom<T>(msg: T) -> Self
method custom (line 86) | fn custom<T>(msg: T) -> Self
method description (line 118) | fn description(&self) -> &str {
type Variant (line 849) | type Variant = private::UnitOnly<E>;
function variant_seed (line 851) | fn variant_seed<T>(self, seed: T) -> Result<(T::Value, Self::Variant), S...
method fmt (line 861) | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
type BytesDeserializer (line 872) | pub struct BytesDeserializer<'a, E> {
function new (line 879) | pub fn new(value: &'a [u8]) -> Self {
type Deserializer (line 893) | type Deserializer = BytesDeserializer<'a, E>;
function into_deserializer (line 895) | fn into_deserializer(self) -> BytesDeserializer<'a, E> {
type Error (line 904) | type Error = E;
method custom (line 64) | fn custom<T>(msg: T) -> Self
method custom (line 75) | fn custom<T>(msg: T) -> Self
method custom (line 86) | fn custom<T>(msg: T) -> Self
method description (line 118) | fn description(&self) -> &str {
function deserialize_any (line 906) | fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
type Deserializer (line 924) | type Deserializer = Self;
function into_deserializer (line 926) | fn into_deserializer(self) -> Self {
method fmt (line 932) | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
type BorrowedBytesDeserializer (line 942) | pub struct BorrowedBytesDeserializer<'de, E> {
function new (line 949) | pub fn new(value: &'de [u8]) -> Self {
type Error (line 963) | type Error = E;
method custom (line 64) | fn custom<T>(msg: T) -> Self
method custom (line 75) | fn custom<T>(msg: T) -> Self
method custom (line 86) | fn custom<T>(msg: T) -> Self
method description (line 118) | fn description(&self) -> &str {
function deserialize_any (line 965) | fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
type Deserializer (line 983) | type Deserializer = Self;
function into_deserializer (line 985) | fn into_deserializer(self) -> Self {
method fmt (line 991) | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
type SeqDeserializer (line 1003) | pub struct SeqDeserializer<I, E> {
function new (line 1014) | pub fn new(iter: I) -> Self {
function end (line 1030) | pub fn end(self) -> Result<(), E> {
type Error (line 1051) | type Error = E;
method custom (line 64) | fn custom<T>(msg: T) -> Self
method custom (line 75) | fn custom<T>(msg: T) -> Self
method custom (line 86) | fn custom<T>(msg: T) -> Self
method description (line 118) | fn description(&self) -> &str {
function deserialize_any (line 1053) | fn deserialize_any<V>(mut self, visitor: V) -> Result<V::Value, Self::Er...
type Deserializer (line 1075) | type Deserializer = Self;
function into_deserializer (line 1077) | fn into_deserializer(self) -> Self {
type Error (line 1088) | type Error = E;
method custom (line 64) | fn custom<T>(msg: T) -> Self
method custom (line 75) | fn custom<T>(msg: T) -> Self
method custom (line 86) | fn custom<T>(msg: T) -> Self
method description (line 118) | fn description(&self) -> &str {
function next_element_seed (line 1090) | fn next_element_seed<V>(&mut self, seed: V) -> Result<Option<V::Value>, ...
function size_hint (line 1103) | fn size_hint(&self) -> Option<usize> {
type ExpectedInSeq (line 1108) | struct ExpectedInSeq(usize);
method fmt (line 1111) | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
method fmt (line 1124) | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
type Deserializer (line 1142) | type Deserializer = SeqDeserializer<<Self as IntoIterator>::IntoIter, E>;
function into_deserializer (line 1144) | fn into_deserializer(self) -> Self::Deserializer {
type Deserializer (line 1156) | type Deserializer = SeqDeserializer<<Self as IntoIterator>::IntoIter, E>;
function into_deserializer (line 1158) | fn into_deserializer(self) -> Self::Deserializer {
type Deserializer (line 1171) | type Deserializer = SeqDeserializer<<Self as IntoIterator>::IntoIter, E>;
function into_deserializer (line 1173) | fn into_deserializer(self) -> Self::Deserializer {
type SeqAccessDeserializer (line 1182) | pub struct SeqAccessDeserializer<A> {
function new (line 1188) | pub fn new(seq: A) -> Self {
type Error (line 1197) | type Error = A::Error;
method custom (line 64) | fn custom<T>(msg: T) -> Self
method custom (line 75) | fn custom<T>(msg: T) -> Self
method custom (line 86) | fn custom<T>(msg: T) -> Self
method description (line 118) | fn description(&self) -> &str {
function deserialize_any (line 1199) | fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
type Deserializer (line 1217) | type Deserializer = Self;
function into_deserializer (line 1219) | fn into_deserializer(self) -> Self {
type MapDeserializer (line 1227) | pub struct MapDeserializer<'de, I, E>
function new (line 1245) | pub fn new(iter: I) -> Self {
function end (line 1264) | pub fn end(self) -> Result<(), E> {
function next_pair (line 1284) | fn next_pair(&mut self) -> Option<(First<I::Item>, Second<I::Item>)> {
type Error (line 1303) | type Error = E;
method custom (line 64) | fn custom<T>(msg: T) -> Self
method custom (line 75) | fn custom<T>(msg: T) -> Self
method custom (line 86) | fn custom<T>(msg: T) -> Self
method description (line 118) | fn description(&self) -> &str {
function deserialize_any (line 1305) | fn deserialize_any<V>(mut self, visitor: V) -> Result<V::Value, Self::Er...
function deserialize_seq (line 1314) | fn deserialize_seq<V>(mut self, visitor: V) -> Result<V::Value, Self::Er...
function deserialize_tuple (line 1323) | fn deserialize_tuple<V>(self, len: usize, visitor: V) -> Result<V::Value...
type Deserializer (line 1346) | type Deserializer = Self;
function into_deserializer (line 1348) | fn into_deserializer(self) -> Self {
type Error (line 1361) | type Error = E;
method custom (line 64) | fn custom<T>(msg: T) -> Self
method custom (line 75) | fn custom<T>(msg: T) -> Self
method custom (line 86) | fn custom<T>(msg: T) -> Self
method description (line 118) | fn description(&self) -> &str {
function next_key_seed (line 1363) | fn next_key_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self...
function next_value_seed (line 1376) | fn next_value_seed<T>(&mut self, seed: T) -> Result<T::Value, Self::Error>
function next_entry_seed (line 1387) | fn next_entry_seed<TK, TV>(
function size_hint (line 1406) | fn size_hint(&self) -> Option<usize> {
type Error (line 1419) | type Error = E;
method custom (line 64) | fn custom<T>(msg: T) -> Self
method custom (line 75) | fn custom<T>(msg: T) -> Self
method custom (line 86) | fn custom<T>(msg: T) -> Self
method description (line 118) | fn description(&self) -> &str {
function next_element_seed (line 1421) | fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, ...
function size_hint (line 1434) | fn size_hint(&self) -> Option<usize> {
method clone (line 1446) | fn clone(&self) -> Self {
method fmt (line 1463) | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
type PairDeserializer (line 1475) | struct PairDeserializer<A, B, E>(A, B, PhantomData<E>);
type Error (line 1483) | type Error = E;
method custom (line 64) | fn custom<T>(msg: T) -> Self
method custom (line 75) | fn custom<T>(msg: T) -> Self
method custom (line 86) | fn custom<T>(msg: T) -> Self
method description (line 118) | fn description(&self) -> &str {
function deserialize_any (line 1491) | fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_seq (line 1498) | fn deserialize_seq<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_tuple (line 1514) | fn deserialize_tuple<V>(self, len: usize, visitor: V) -> Result<V::Value...
type PairVisitor (line 1528) | struct PairVisitor<A, B, E>(Option<A>, Option<B>, PhantomData<E>);
type Error (line 1536) | type Error = E;
method custom (line 64) | fn custom<T>(msg: T) -> Self
method custom (line 75) | fn custom<T>(msg: T) -> Self
method custom (line 86) | fn custom<T>(msg: T) -> Self
method description (line 118) | fn description(&self) -> &str {
function next_element_seed (line 1538) | fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, ...
function size_hint (line 1551) | fn size_hint(&self) -> Option<usize> {
type ExpectedInMap (line 1562) | struct ExpectedInMap(usize);
method fmt (line 1565) | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
type Deserializer (line 1584) | type Deserializer = MapDeserializer<'de, <Self as IntoIterator>::IntoIte...
function into_deserializer (line 1586) | fn into_deserializer(self) -> Self::Deserializer {
type Deserializer (line 1600) | type Deserializer = MapDeserializer<'de, <Self as IntoIterator>::IntoIte...
function into_deserializer (line 1602) | fn into_deserializer(self) -> Self::Deserializer {
type MapAccessDeserializer (line 1611) | pub struct MapAccessDeserializer<A> {
function new (line 1617) | pub fn new(map: A) -> Self {
type Error (line 1626) | type Error = A::Error;
method custom (line 64) | fn custom<T>(msg: T) -> Self
method custom (line 75) | fn custom<T>(msg: T) -> Self
method custom (line 86) | fn custom<T>(msg: T) -> Self
method description (line 118) | fn description(&self) -> &str {
function deserialize_any (line 1628) | fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
function deserialize_enum (line 1635) | fn deserialize_enum<V>(
type Deserializer (line 1658) | type Deserializer = Self;
function into_deserializer (line 1660) | fn into_deserializer(self) -> Self {
type Error (line 1669) | type Error = A::Error;
method custom (line 64) | fn custom<T>(msg: T) -> Self
method custom (line 75) | fn custom<T>(msg: T) -> Self
method custom (line 86) | fn custom<T>(msg: T) -> Self
method description (line 118) | fn description(&self) -> &str {
type Variant (line 1670) | type Variant = private::MapAsEnum<A>;
function variant_seed (line 1672) | fn variant_seed<T>(mut self, seed: T) -> Result<(T::Value, Self::Variant...
type EnumAccessDeserializer (line 1687) | pub struct EnumAccessDeserializer<A> {
function new (line 1693) | pub fn new(access: A) -> Self {
type Error (line 1702) | type Error = A::Error;
method custom (line 64) | fn custom<T>(msg: T) -> Self
method custom (line 75) | fn custom<T>(msg: T) -> Self
method custom (line 86) | fn custom<T>(msg: T) -> Self
method description (line 118) | fn description(&self) -> &str {
function deserialize_any (line 1704) | fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
type Deserializer (line 1722) | type Deserializer = Self;
function into_deserializer (line 1724) | fn into_deserializer(self) -> Self {
type UnitOnly (line 1738) | pub struct UnitOnly<E> {
function unit_only (line 1742) | pub fn unit_only<T, E>(t: T) -> (T, UnitOnly<E>) {
type Error (line 1755) | type Error = E;
method custom (line 64) | fn custom<T>(msg: T) -> Self
method custom (line 75) | fn custom<T>(msg: T) -> Self
method custom (line 86) | fn custom<T>(msg: T) -> Self
method description (line 118) | fn description(&self) -> &str {
function unit_variant (line 1757) | fn unit_variant(self) -> Result<(), Self::Error> {
function newtype_variant_seed (line 1761) | fn newtype_variant_seed<T>(self, _seed: T) -> Result<T::Value, Self::Error>
function tuple_variant (line 1771) | fn tuple_variant<V>(self, _len: usize, _visitor: V) -> Result<V::Value, ...
function struct_variant (line 1781) | fn struct_variant<V>(
type MapAsEnum (line 1796) | pub struct MapAsEnum<A> {
function map_as_enum (line 1800) | pub fn map_as_enum<A>(map: A) -> MapAsEnum<A> {
type Error (line 1808) | type Error = A::Error;
method custom (line 64) | fn custom<T>(msg: T) -> Self
method custom (line 75) | fn custom<T>(msg: T) -> Self
method custom (line 86) | fn custom<T>(msg: T) -> Self
method description (line 118) | fn description(&self) -> &str {
function unit_variant (line 1810) | fn unit_variant(mut self) -> Result<(), Self::Error> {
function newtype_variant_seed (line 1814) | fn newtype_variant_seed<T>(mut self, seed: T) -> Result<T::Value, Self::...
function tuple_variant (line 1821) | fn tuple_variant<V>(mut self, len: usize, visitor: V) -> Result<V::Value...
function struct_variant (line 1828) | fn struct_variant<V>(
type SeedTupleVariant (line 1840) | struct SeedTupleVariant<V> {
type Value (line 1849) | type Value = V::Value;
function deserialize (line 1851) | fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
type SeedStructVariant (line 1859) | struct SeedStructVariant<V> {
type Value (line 1867) | type Value = V::Value;
function deserialize (line 1869) | fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
type Pair (line 1879) | pub trait Pair {
method split (line 1882) | fn split(self) -> (Self::First, Self::Second);
type First (line 1886) | type First = A;
type Second (line 1887) | type Second = B;
method split (line 1888) | fn split(self) -> (A, B) {
type First (line 1893) | pub type First<T> = <T as Pair>::First;
type Second (line 1894) | pub type Second<T> = <T as Pair>::Second;
FILE: serde_core/src/format.rs
type Buf (line 4) | pub(super) struct Buf<'a> {
function new (line 10) | pub fn new(bytes: &'a mut [u8]) -> Self {
function as_str (line 14) | pub fn as_str(&self) -> &str {
method write_str (line 21) | fn write_str(&mut self, s: &str) -> fmt::Result {
FILE: serde_core/src/private/content.rs
type Content (line 10) | pub enum Content<'de> {
FILE: serde_core/src/private/doc.rs
type Error (line 9) | pub struct Error;
method custom (line 13) | fn custom<T>(_: T) -> Self
method description (line 24) | fn description(&self) -> &str {
method fmt (line 31) | fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result {
FILE: serde_core/src/private/seed.rs
type InPlaceSeed (line 6) | pub struct InPlaceSeed<'a, T: 'a>(pub &'a mut T);
type Value (line 13) | type Value = ();
function deserialize (line 14) | fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
FILE: serde_core/src/private/size_hint.rs
function from_bounds (line 4) | pub fn from_bounds<I>(iter: &I) -> Option<usize>
function cautious (line 12) | pub fn cautious<Element>(hint: Option<usize>) -> usize {
function helper (line 25) | fn helper(bounds: (usize, Option<usize>)) -> Option<usize> {
FILE: serde_core/src/private/string.rs
function from_utf8_lossy (line 5) | pub fn from_utf8_lossy(bytes: &[u8]) -> Cow<'_, str> {
function from_utf8_lossy (line 18) | pub fn from_utf8_lossy(bytes: &[u8]) -> &str {
FILE: serde_core/src/ser/fmt.rs
method custom (line 5) | fn custom<T: Display>(_msg: T) -> Self {
type Ok (line 39) | type Ok = ();
type Error (line 40) | type Error = fmt::Error;
type SerializeSeq (line 41) | type SerializeSeq = Impossible<(), fmt::Error>;
type SerializeTuple (line 42) | type SerializeTuple = Impossible<(), fmt::Error>;
type SerializeTupleStruct (line 43) | type SerializeTupleStruct = Impossible<(), fmt::Error>;
type SerializeTupleVariant (line 44) | type SerializeTupleVariant = Impossible<(), fmt::Error>;
type SerializeMap (line 45) | type SerializeMap = Impossible<(), fmt::Error>;
type SerializeStruct (line 46) | type SerializeStruct = Impossible<(), fmt::Error>;
type SerializeStructVariant (line 47) | type SerializeStructVariant = Impossible<(), fmt::Error>;
method serialize_unit_variant (line 68) | fn serialize_unit_variant(
method serialize_newtype_struct (line 77) | fn serialize_newtype_struct<T>(self, _name: &'static str, value: &T) -> ...
method serialize_bytes (line 84) | fn serialize_bytes(self, _v: &[u8]) -> fmt::Result {
method serialize_none (line 88) | fn serialize_none(self) -> fmt::Result {
method serialize_some (line 92) | fn serialize_some<T>(self, _value: &T) -> fmt::Result
method serialize_unit (line 99) | fn serialize_unit(self) -> fmt::Result {
method serialize_newtype_variant (line 103) | fn serialize_newtype_variant<T>(
method serialize_seq (line 116) | fn serialize_seq(self, _len: Option<usize>) -> Result<Self::SerializeSeq...
method serialize_tuple (line 120) | fn serialize_tuple(self, _len: usize) -> Result<Self::SerializeTuple, fm...
method serialize_tuple_struct (line 124) | fn serialize_tuple_struct(
method serialize_tuple_variant (line 132) | fn serialize_tuple_variant(
method serialize_map (line 142) | fn serialize_map(self, _len: Option<usize>) -> Result<Self::SerializeMap...
method serialize_struct (line 146) | fn serialize_struct(
method serialize_struct_variant (line 154) | fn serialize_struct_variant(
method collect_str (line 164) | fn collect_str<T>(self, value: &T) -> fmt::Result
FILE: serde_core/src/ser/impls.rs
method serialize (line 42) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 54) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 63) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 77) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 89) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 104) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 122) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 135) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 180) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 251) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 269) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 286) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 304) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 321) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 341) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 352) | fn serialize<S>(&self, _serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 540) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 560) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 604) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 616) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 633) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 650) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 670) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 686) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 703) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 737) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
constant DEC_DIGITS_LUT (line 760) | const DEC_DIGITS_LUT: &[u8] = b"\
function format_u8 (line 769) | fn format_u8(mut n: u8, out: &mut [u8]) -> usize {
function test_format_u8 (line 790) | fn test_format_u8() {
method serialize (line 807) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 831) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 847) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 871) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 887) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 909) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 923) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 935) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 944) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 957) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 972) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 986) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method serialize (line 999) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
FILE: serde_core/src/ser/impossible.rs
type Impossible (line 60) | pub struct Impossible<Ok, Error> {
type Void (line 66) | enum Void {}
type Ok (line 72) | type Ok = Ok;
type Error (line 73) | type Error = Error;
method serialize_element (line 75) | fn serialize_element<T>(&mut self, value: &T) -> Result<(), Error>
method end (line 83) | fn end(self) -> Result<Ok, Error> {
type Ok (line 92) | type Ok = Ok;
type Error (line 93) | type Error = Error;
method serialize_element (line 95) | fn serialize_element<T>(&mut self, value: &T) -> Result<(), Error>
method end (line 103) | fn end(self) -> Result<Ok, Error> {
type Ok (line 112) | type Ok = Ok;
type Error (line 113) | type Error = Error;
method serialize_field (line 115) | fn serialize_field<T>(&mut self, value: &T) -> Result<(), Error>
method end (line 123) | fn end(self) -> Result<Ok, Error> {
type Ok (line 132) | type Ok = Ok;
type Error (line 133) | type Error = Error;
method serialize_field (line 135) | fn serialize_field<T>(&mut self, value: &T) -> Result<(), Error>
method end (line 143) | fn end(self) -> Result<Ok, Error> {
type Ok (line 152) | type Ok = Ok;
type Error (line 153) | type Error = Error;
method serialize_key (line 155) | fn serialize_key<T>(&mut self, key: &T) -> Result<(), Error>
method serialize_value (line 163) | fn serialize_value<T>(&mut self, value: &T) -> Result<(), Error>
method end (line 171) | fn end(self) -> Result<Ok, Error> {
type Ok (line 180) | type Ok = Ok;
type Error (line 181) | type Error = Error;
method serialize_field (line 183) | fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result...
method end (line 192) | fn end(self) -> Result<Ok, Error> {
type Ok (line 201) | type Ok = Ok;
type Error (line 202) | type Error = Error;
method serialize_field (line 204) | fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result...
method end (line 213) | fn end(self) -> Result<Ok, Error> {
FILE: serde_core/src/ser/mod.rs
type Serialize (line 234) | pub trait Serialize {
method serialize (line 265) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
type Serializer (line 355) | pub trait Serializer: Sized {
method serialize_bool (line 427) | fn serialize_bool(self, v: bool) -> Result<Self::Ok, Self::Error>;
method serialize_i8 (line 449) | fn serialize_i8(self, v: i8) -> Result<Self::Ok, Self::Error>;
method serialize_i16 (line 471) | fn serialize_i16(self, v: i16) -> Result<Self::Ok, Self::Error>;
method serialize_i32 (line 493) | fn serialize_i32(self, v: i32) -> Result<Self::Ok, Self::Error>;
method serialize_i64 (line 511) | fn serialize_i64(self, v: i64) -> Result<Self::Ok, Self::Error>;
method serialize_i128 (line 531) | fn serialize_i128(self, v: i128) -> Result<Self::Ok, Self::Error> {
method serialize_u8 (line 556) | fn serialize_u8(self, v: u8) -> Result<Self::Ok, Self::Error>;
method serialize_u16 (line 578) | fn serialize_u16(self, v: u16) -> Result<Self::Ok, Self::Error>;
method serialize_u32 (line 600) | fn serialize_u32(self, v: u32) -> Result<Self::Ok, Self::Error>;
method serialize_u64 (line 618) | fn serialize_u64(self, v: u64) -> Result<Self::Ok, Self::Error>;
method serialize_u128 (line 638) | fn serialize_u128(self, v: u128) -> Result<Self::Ok, Self::Error> {
method serialize_f32 (line 663) | fn serialize_f32(self, v: f32) -> Result<Self::Ok, Self::Error>;
method serialize_f64 (line 681) | fn serialize_f64(self, v: f64) -> Result<Self::Ok, Self::Error>;
method serialize_char (line 702) | fn serialize_char(self, v: char) -> Result<Self::Ok, Self::Error>;
method serialize_str (line 720) | fn serialize_str(self, v: &str) -> Result<Self::Ok, Self::Error>;
method serialize_bytes (line 755) | fn serialize_bytes(self, v: &[u8]) -> Result<Self::Ok, Self::Error>;
method serialize_none (line 788) | fn serialize_none(self) -> Result<Self::Ok, Self::Error>;
method serialize_some (line 821) | fn serialize_some<T>(self, value: &T) -> Result<Self::Ok, Self::Error>
method serialize_unit (line 841) | fn serialize_unit(self) -> Result<Self::Ok, Self::Error>;
method serialize_unit_struct (line 861) | fn serialize_unit_struct(self, name: &'static str) -> Result<Self::Ok,...
method serialize_unit_variant (line 889) | fn serialize_unit_variant(
method serialize_newtype_struct (line 916) | fn serialize_newtype_struct<T>(
method serialize_newtype_variant (line 950) | fn serialize_newtype_variant<T>(
method serialize_seq (line 1006) | fn serialize_seq(self, len: Option<usize>) -> Result<Self::SerializeSe...
method serialize_tuple (line 1062) | fn serialize_tuple(self, len: usize) -> Result<Self::SerializeTuple, S...
method serialize_tuple_struct (line 1089) | fn serialize_tuple_struct(
method serialize_tuple_variant (line 1134) | fn serialize_tuple_variant(
method serialize_map (line 1188) | fn serialize_map(self, len: Option<usize>) -> Result<Self::SerializeMa...
method serialize_struct (line 1220) | fn serialize_struct(
method serialize_struct_variant (line 1264) | fn serialize_struct_variant(
method collect_seq (line 1296) | fn collect_seq<I>(self, iter: I) -> Result<Self::Ok, Self::Error>
method collect_map (line 1333) | fn collect_map<K, V, I>(self, iter: I) -> Result<Self::Ok, Self::Error>
method collect_str (line 1373) | fn collect_str<T>(self, value: &T) -> Result<Self::Ok, Self::Error>
method collect_str (line 1406) | fn collect_str<T>(self, value: &T) -> Result<Self::Ok, Self::Error>
method is_human_readable (line 1459) | fn is_human_readable(&self) -> bool {
type SerializeSeq (line 1518) | pub trait SerializeSeq {
method serialize_element (line 1526) | fn serialize_element<T>(&mut self, value: &T) -> Result<(), Self::Error>
method end (line 1531) | fn end(self) -> Result<Self::Ok, Self::Error>;
type SerializeTuple (line 1624) | pub trait SerializeTuple {
method serialize_element (line 1632) | fn serialize_element<T>(&mut self, value: &T) -> Result<(), Self::Error>
method end (line 1637) | fn end(self) -> Result<Self::Ok, Self::Error>;
type SerializeTupleStruct (line 1675) | pub trait SerializeTupleStruct {
method serialize_field (line 1683) | fn serialize_field<T>(&mut self, value: &T) -> Result<(), Self::Error>
method end (line 1688) | fn end(self) -> Result<Self::Ok, Self::Error>;
type SerializeTupleVariant (line 1739) | pub trait SerializeTupleVariant {
method serialize_field (line 1747) | fn serialize_field<T>(&mut self, value: &T) -> Result<(), Self::Error>
method end (line 1752) | fn end(self) -> Result<Self::Ok, Self::Error>;
type SerializeMap (line 1811) | pub trait SerializeMap {
method serialize_key (line 1824) | fn serialize_key<T>(&mut self, key: &T) -> Result<(), Self::Error>
method serialize_value (line 1834) | fn serialize_value<T>(&mut self, value: &T) -> Result<(), Self::Error>
method serialize_entry (line 1855) | fn serialize_entry<K, V>(&mut self, key: &K, value: &V) -> Result<(), ...
method end (line 1865) | fn end(self) -> Result<Self::Ok, Self::Error>;
type SerializeStruct (line 1907) | pub trait SerializeStruct {
method serialize_field (line 1915) | fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Resu...
method skip_field (line 1923) | fn skip_field(&mut self, key: &'static str) -> Result<(), Self::Error> {
method end (line 1929) | fn end(self) -> Result<Self::Ok, Self::Error>;
type SerializeStructVariant (line 1977) | pub trait SerializeStructVariant {
method serialize_field (line 1985) | fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Resu...
method skip_field (line 1993) | fn skip_field(&mut self, key: &'static str) -> Result<(), Self::Error> {
method end (line 1999) | fn end(self) -> Result<Self::Ok, Self::Error>;
function iterator_len_hint (line 2002) | fn iterator_len_hint<I>(iter: &I) -> Option<usize>
FILE: serde_core/src/std_error.rs
type Error (line 43) | pub trait Error: Debug + Display {
method source (line 45) | fn source(&self) -> Option<&(dyn Error + 'static)> {
FILE: serde_derive/build.rs
function main (line 1) | fn main() {
FILE: serde_derive/src/bound.rs
function without_defaults (line 11) | pub fn without_defaults(generics: &syn::Generics) -> syn::Generics {
function with_where_predicates (line 29) | pub fn with_where_predicates(
function with_where_predicates_from_fields (line 42) | pub fn with_where_predicates_from_fields(
function with_where_predicates_from_variants (line 61) | pub fn with_where_predicates_from_variants(
function with_bound (line 98) | pub fn with_bound(
function with_self_bound (line 327) | pub fn with_self_bound(
function with_lifetime_bound (line 354) | pub fn with_lifetime_bound(generics: &syn::Generics, lifetime: &str) -> ...
function type_of_item (line 387) | fn type_of_item(cont: &Container) -> syn::Type {
FILE: serde_derive/src/de.rs
function expand_derive_deserialize (line 25) | pub fn expand_derive_deserialize(input: &mut syn::DeriveInput) -> syn::R...
function precondition (line 84) | fn precondition(cx: &Ctxt, cont: &Container) {
function precondition_sized (line 89) | fn precondition_sized(cx: &Ctxt, cont: &Container) {
function precondition_no_de_lifetime (line 102) | fn precondition_no_de_lifetime(cx: &Ctxt, cont: &Container) {
type Parameters (line 116) | struct Parameters {
method new (line 145) | fn new(cont: &Container) -> Self {
method type_name (line 167) | fn type_name(&self) -> String {
method generics_with_de_lifetime (line 174) | fn generics_with_de_lifetime(
function build_generics (line 192) | fn build_generics(cont: &Container, borrowed: &BorrowedLifetimes) -> syn...
function needs_deserialize_bound (line 236) | fn needs_deserialize_bound(field: &attr::Field, variant: Option<&attr::V...
function requires_default (line 249) | fn requires_default(field: &attr::Field, _variant: Option<&attr::Variant...
type BorrowedLifetimes (line 257) | enum BorrowedLifetimes {
method de_lifetime (line 263) | fn de_lifetime(&self) -> syn::Lifetime {
method de_lifetime_param (line 270) | fn de_lifetime_param(&self) -> Option<syn::LifetimeParam> {
function borrowed_lifetimes (line 292) | fn borrowed_lifetimes(cont: &Container) -> BorrowedLifetimes {
function deserialize_body (line 306) | fn deserialize_body(cont: &Container, params: &Parameters) -> Fragment {
function deserialize_in_place_body (line 333) | fn deserialize_in_place_body(cont: &Container, params: &Parameters) -> O...
function deserialize_in_place_body (line 378) | fn deserialize_in_place_body(_cont: &Container, _params: &Parameters) ->...
function deserialize_transparent (line 383) | fn deserialize_transparent(cont: &Container, params: &Parameters) -> Fra...
function deserialize_from (line 426) | fn deserialize_from(type_from: &syn::Type) -> Fragment {
function deserialize_try_from (line 435) | fn deserialize_try_from(type_try_from: &syn::Type) -> Fragment {
type TupleForm (line 443) | enum TupleForm<'a> {
function deserialize_seq (line 451) | fn deserialize_seq(
function deserialize_seq_in_place (line 555) | fn deserialize_seq_in_place(
type StructForm (line 643) | enum StructForm<'a> {
type FieldWithAliases (line 653) | struct FieldWithAliases<'a> {
function field_i (line 658) | pub(crate) fn field_i(i: usize) -> Ident {
function wrap_deserialize_with (line 664) | fn wrap_deserialize_with(
function wrap_deserialize_field_with (line 710) | fn wrap_deserialize_field_with(
function unwrap_to_variant_closure (line 719) | fn unwrap_to_variant_closure(
function expr_is_missing (line 766) | fn expr_is_missing(field: &Field, cattrs: &attr::Container) -> Fragment {
function expr_is_missing_seq (line 808) | fn expr_is_missing_seq(
function effective_style (line 841) | fn effective_style(variant: &Variant) -> Style {
function has_flatten (line 850) | fn has_flatten(fields: &[Field]) -> bool {
type DeImplGenerics (line 856) | struct DeImplGenerics<'a>(&'a Parameters);
type InPlaceImplGenerics (line 858) | struct InPlaceImplGenerics<'a>(&'a Parameters);
method to_tokens (line 861) | fn to_tokens(&self, tokens: &mut TokenStream) {
method to_tokens (line 876) | fn to_tokens(&self, tokens: &mut TokenStream) {
function in_place (line 911) | fn in_place(self) -> InPlaceImplGenerics<'a> {
type DeTypeGenerics (line 916) | struct DeTypeGenerics<'a>(&'a Parameters);
type InPlaceTypeGenerics (line 918) | struct InPlaceTypeGenerics<'a>(&'a Parameters);
function de_type_generics_to_tokens (line 920) | fn de_type_generics_to_tokens(
method to_tokens (line 943) | fn to_tokens(&self, tokens: &mut TokenStream) {
method to_tokens (line 950) | fn to_tokens(&self, tokens: &mut TokenStream) {
function in_place (line 963) | fn in_place(self) -> InPlaceTypeGenerics<'a> {
function place_lifetime (line 969) | fn place_lifetime() -> syn::LifetimeParam {
FILE: serde_derive/src/de/enum_.rs
function deserialize (line 15) | pub(super) fn deserialize(
function deserialize_homogeneous_enum (line 39) | fn deserialize_homogeneous_enum(
function prepare_enum_variant_enum (line 56) | pub fn prepare_enum_variant_enum(variants: &[Variant]) -> (TokenStream, ...
FILE: serde_derive/src/de/enum_adjacently.rs
function deserialize (line 19) | pub(super) fn deserialize(
FILE: serde_derive/src/de/enum_externally.rs
function deserialize (line 23) | pub(super) fn deserialize(
function deserialize_externally_tagged_variant (line 118) | fn deserialize_externally_tagged_variant(
function wrap_deserialize_variant_with (line 163) | fn wrap_deserialize_variant_with(
function deserialize_externally_tagged_newtype_variant (line 177) | fn deserialize_externally_tagged_newtype_variant(
FILE: serde_derive/src/de/enum_internally.rs
function deserialize (line 21) | pub(super) fn deserialize(
function deserialize_internally_tagged_variant (line 67) | fn deserialize_internally_tagged_variant(
FILE: serde_derive/src/de/enum_untagged.rs
function deserialize (line 22) | pub(super) fn deserialize(
function deserialize_variant (line 62) | pub(super) fn deserialize_variant(
function deserialize_newtype_variant (line 113) | pub(super) fn deserialize_newtype_variant(
FILE: serde_derive/src/de/identifier.rs
function deserialize_custom (line 14) | pub(super) fn deserialize_custom(
function deserialize_generated (line 125) | pub(super) fn deserialize_generated(
function deserialize_identifier (line 185) | fn deserialize_identifier(
FILE: serde_derive/src/de/struct_.rs
function deserialize (line 17) | pub(super) fn deserialize(
function deserialize_map (line 199) | fn deserialize_map(
function deserialize_in_place (line 423) | pub(super) fn deserialize_in_place(
function deserialize_map_in_place (line 513) | fn deserialize_map_in_place(
function deserialize_field_identifier (line 673) | fn deserialize_field_identifier(
FILE: serde_derive/src/de/tuple.rs
function deserialize (line 13) | pub(super) fn deserialize(
function deserialize_newtype_struct (line 135) | fn deserialize_newtype_struct(
function deserialize_in_place (line 186) | pub(super) fn deserialize_in_place(
FILE: serde_derive/src/de/unit.rs
function deserialize (line 8) | pub(super) fn deserialize(params: &Parameters, cattrs: &attr::Container)...
FILE: serde_derive/src/deprecated.rs
function allow_deprecated (line 4) | pub fn allow_deprecated(input: &syn::DeriveInput) -> Option<TokenStream> {
function should_allow_deprecated (line 18) | fn should_allow_deprecated(input: &syn::DeriveInput) -> bool {
function contains_deprecated (line 35) | fn contains_deprecated(attrs: &[syn::Attribute]) -> bool {
FILE: serde_derive/src/dummy.rs
function wrap_in_const (line 4) | pub fn wrap_in_const(serde_path: Option<&syn::Path>, code: TokenStream) ...
FILE: serde_derive/src/fragment.rs
type Fragment (line 5) | pub enum Fragment {
method as_ref (line 68) | fn as_ref(&self) -> &TokenStream {
type Expr (line 27) | pub struct Expr(pub Fragment);
method to_tokens (line 29) | fn to_tokens(&self, out: &mut TokenStream) {
type Stmts (line 40) | pub struct Stmts(pub Fragment);
method to_tokens (line 42) | fn to_tokens(&self, out: &mut TokenStream) {
type Match (line 52) | pub struct Match(pub Fragment);
method to_tokens (line 54) | fn to_tokens(&self, out: &mut TokenStream) {
FILE: serde_derive/src/internals/ast.rs
type Container (line 10) | pub struct Container<'a> {
type Data (line 26) | pub enum Data<'a> {
type Variant (line 32) | pub struct Variant<'a> {
type Field (line 41) | pub struct Field<'a> {
type Style (line 49) | pub enum Style {
function from_ast (line 62) | pub fn from_ast(
function all_fields (line 119) | pub fn all_fields(&'a self) -> Box<dyn Iterator<Item = &'a Field<'a>> + ...
function has_getter (line 128) | pub fn has_getter(&self) -> bool {
function enum_from_ast (line 133) | fn enum_from_ast<'a>(
function struct_from_ast (line 174) | fn struct_from_ast<'a>(
function fields_from_ast (line 198) | fn fields_from_ast<'a>(
FILE: serde_derive/src/internals/attr.rs
type Attr (line 24) | pub(crate) struct Attr<'c, T> {
function none (line 32) | fn none(cx: &'c Ctxt, name: Symbol) -> Self {
function set (line 41) | fn set<A: ToTokens>(&mut self, obj: A, value: T) {
function set_opt (line 53) | fn set_opt<A: ToTokens>(&mut self, obj: A, value: Option<T>) {
function set_if_none (line 59) | fn set_if_none(&mut self, value: T) {
function get (line 65) | pub(crate) fn get(self) -> Option<T> {
function get_with_tokens (line 69) | fn get_with_tokens(self) -> Option<(TokenStream, T)> {
type BoolAttr (line 77) | struct BoolAttr<'c>(Attr<'c, ()>);
function none (line 80) | fn none(cx: &'c Ctxt, name: Symbol) -> Self {
function set_true (line 84) | fn set_true<A: ToTokens>(&mut self, obj: A) {
function get (line 88) | fn get(&self) -> bool {
type VecAttr (line 93) | pub(crate) struct VecAttr<'c, T> {
function none (line 101) | fn none(cx: &'c Ctxt, name: Symbol) -> Self {
function insert (line 110) | fn insert<A: ToTokens>(&mut self, obj: A, value: T) {
function at_most_one (line 117) | fn at_most_one(mut self) -> Option<T> {
function get (line 128) | pub(crate) fn get(self) -> Vec<T> {
function unraw (line 133) | fn unraw(ident: &Ident) -> Ident {
type RenameAllRules (line 138) | pub struct RenameAllRules {
method or (line 146) | pub fn or(self, other_rules: Self) -> Self {
type Container (line 155) | pub struct Container {
method from_ast (line 237) | pub fn from_ast(cx: &Ctxt, item: &syn::DeriveInput) -> Self {
method name (line 547) | pub fn name(&self) -> &MultiName {
method rename_all_rules (line 551) | pub fn rename_all_rules(&self) -> RenameAllRules {
method rename_all_fields_rules (line 555) | pub fn rename_all_fields_rules(&self) -> RenameAllRules {
method transparent (line 559) | pub fn transparent(&self) -> bool {
method deny_unknown_fields (line 563) | pub fn deny_unknown_fields(&self) -> bool {
method default (line 567) | pub fn default(&self) -> &Default {
method ser_bound (line 571) | pub fn ser_bound(&self) -> Option<&[syn::WherePredicate]> {
method de_bound (line 575) | pub fn de_bound(&self) -> Option<&[syn::WherePredicate]> {
method tag (line 579) | pub fn tag(&self) -> &TagType {
method type_from (line 583) | pub fn type_from(&self) -> Option<&syn::Type> {
method type_try_from (line 587) | pub fn type_try_from(&self) -> Option<&syn::Type> {
method type_into (line 591) | pub fn type_into(&self) -> Option<&syn::Type> {
method remote (line 595) | pub fn remote(&self) -> Option<&syn::Path> {
method is_packed (line 599) | pub fn is_packed(&self) -> bool {
method identifier (line 603) | pub fn identifier(&self) -> Identifier {
method custom_serde_path (line 607) | pub fn custom_serde_path(&self) -> Option<&syn::Path> {
method expecting (line 613) | pub fn expecting(&self) -> Option<&str> {
method non_exhaustive (line 617) | pub fn non_exhaustive(&self) -> bool {
type TagType (line 178) | pub enum TagType {
type Identifier (line 211) | pub enum Identifier {
method is_some (line 227) | pub fn is_some(self) -> bool {
function decide_tag (line 622) | fn decide_tag(
function decide_identifier (line 683) | fn decide_identifier(
type Variant (line 728) | pub struct Variant {
method from_ast (line 748) | pub fn from_ast(cx: &Ctxt, variant: &syn::Variant) -> Self {
method name (line 917) | pub fn name(&self) -> &MultiName {
method aliases (line 921) | pub fn aliases(&self) -> &BTreeSet<Name> {
method rename_by_rules (line 925) | pub fn rename_by_rules(&mut self, rules: RenameAllRules) {
method rename_all_rules (line 940) | pub fn rename_all_rules(&self) -> RenameAllRules {
method ser_bound (line 944) | pub fn ser_bound(&self) -> Option<&[syn::WherePredicate]> {
method de_bound (line 948) | pub fn de_bound(&self) -> Option<&[syn::WherePredicate]> {
method skip_deserializing (line 952) | pub fn skip_deserializing(&self) -> bool {
method skip_serializing (line 956) | pub fn skip_serializing(&self) -> bool {
method other (line 960) | pub fn other(&self) -> bool {
method serialize_with (line 964) | pub fn serialize_with(&self) -> Option<&syn::ExprPath> {
method deserialize_with (line 968) | pub fn deserialize_with(&self) -> Option<&syn::ExprPath> {
method untagged (line 972) | pub fn untagged(&self) -> bool {
type BorrowAttribute (line 742) | struct BorrowAttribute {
type Field (line 978) | pub struct Field {
method from_ast (line 1015) | pub fn from_ast(
method name (line 1264) | pub fn name(&self) -> &MultiName {
method aliases (line 1268) | pub fn aliases(&self) -> &BTreeSet<Name> {
method rename_by_rules (line 1272) | pub fn rename_by_rules(&mut self, rules: RenameAllRules) {
method skip_serializing (line 1286) | pub fn skip_serializing(&self) -> bool {
method skip_deserializing (line 1290) | pub fn skip_deserializing(&self) -> bool {
method skip_serializing_if (line 1294) | pub fn skip_serializing_if(&self) -> Option<&syn::ExprPath> {
method default (line 1298) | pub fn default(&self) -> &Default {
method serialize_with (line 1302) | pub fn serialize_with(&self) -> Option<&syn::ExprPath> {
method deserialize_with (line 1306) | pub fn deserialize_with(&self) -> Option<&syn::ExprPath> {
method ser_bound (line 1310) | pub fn ser_bound(&self) -> Option<&[syn::WherePredicate]> {
method de_bound (line 1314) | pub fn de_bound(&self) -> Option<&[syn::WherePredicate]> {
method borrowed_lifetimes (line 1318) | pub fn borrowed_lifetimes(&self) -> &BTreeSet<syn::Lifetime> {
method getter (line 1322) | pub fn getter(&self) -> Option<&syn::ExprPath> {
method flatten (line 1326) | pub fn flatten(&self) -> bool {
method transparent (line 1330) | pub fn transparent(&self) -> bool {
method mark_transparent (line 1334) | pub fn mark_transparent(&mut self) {
type Default (line 995) | pub enum Default {
method is_none (line 1005) | pub fn is_none(&self) -> bool {
type SerAndDe (line 1339) | type SerAndDe<T> = (Option<T>, Option<T>);
function get_ser_and_de (line 1341) | fn get_ser_and_de<'c, T, F, R>(
function get_renames (line 1386) | fn get_renames(
function get_multiple_renames (line 1395) | fn get_multiple_renames(
function get_where_predicates (line 1403) | fn get_where_predicates(
function get_lit_str (line 1411) | fn get_lit_str(
function get_lit_str2 (line 1419) | fn get_lit_str2(
function parse_lit_into_path (line 1455) | fn parse_lit_into_path(
function parse_lit_into_expr_path (line 1476) | fn parse_lit_into_expr_path(
function parse_lit_into_where (line 1497) | fn parse_lit_into_where(
function parse_lit_into_ty (line 1518) | fn parse_lit_into_ty(
function parse_lit_into_lifetimes (line 1541) | fn parse_lit_into_lifetimes(
function is_implicitly_borrowed (line 1579) | fn is_implicitly_borrowed(ty: &syn::Type) -> bool {
function is_implicitly_borrowed_reference (line 1583) | fn is_implicitly_borrowed_reference(ty: &syn::Type) -> bool {
function is_cow (line 1609) | fn is_cow(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
function is_option (line 1633) | fn is_option(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
function is_reference (line 1677) | fn is_reference(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
function is_str (line 1684) | fn is_str(ty: &syn::Type) -> bool {
function is_slice_u8 (line 1688) | fn is_slice_u8(ty: &syn::Type) -> bool {
function is_primitive_type (line 1695) | fn is_primitive_type(ty: &syn::Type, primitive: &str) -> bool {
function is_primitive_path (line 1702) | fn is_primitive_path(path: &syn::Path, primitive: &str) -> bool {
function borrowable_lifetimes (line 1716) | fn borrowable_lifetimes(
function collect_lifetimes (line 1732) | fn collect_lifetimes(ty: &syn::Type, out: &mut BTreeSet<syn::Lifetime>) {
function collect_lifetimes_from_tokens (line 1799) | fn collect_lifetimes_from_tokens(tokens: TokenStream, out: &mut BTreeSet...
FILE: serde_derive/src/internals/case.rs
type RenameRule (line 9) | pub enum RenameRule {
method from_str (line 45) | pub fn from_str(rename_all_str: &str) -> Result<Self, ParseError> {
method apply_to_variant (line 57) | pub fn apply_to_variant(self, variant: &str) -> String {
method apply_to_field (line 82) | pub fn apply_to_field(self, field: &str) -> String {
method or (line 112) | pub fn or(self, rule_b: Self) -> Self {
type ParseError (line 120) | pub struct ParseError<'a> {
method fmt (line 125) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
function rename_variants (line 140) | fn rename_variants() {
function rename_fields (line 174) | fn rename_fields() {
FILE: serde_derive/src/internals/check.rs
function check (line 8) | pub fn check(cx: &Ctxt, cont: &mut Container, derive: Derive) {
function check_default_on_tuple (line 27) | fn check_default_on_tuple(cx: &Ctxt, cont: &Container) {
function check_remote_generic (line 66) | fn check_remote_generic(cx: &Ctxt, cont: &Container) {
function check_getter (line 78) | fn check_getter(cx: &Ctxt, cont: &Container) {
function check_flatten (line 100) | fn check_flatten(cx: &Ctxt, cont: &Container) {
function check_flatten_field (line 117) | fn check_flatten_field(cx: &Ctxt, style: Style, field: &Field) {
function check_identifier (line 144) | fn check_identifier(cx: &Ctxt, cont: &Container) {
function check_variant_skip_attrs (line 226) | fn check_variant_skip_attrs(cx: &Ctxt, cont: &Container) {
function check_internal_tag_field_name_conflict (line 300) | fn check_internal_tag_field_name_conflict(cx: &Ctxt, cont: &Container) {
function check_adjacent_tag_conflict (line 352) | fn check_adjacent_tag_conflict(cx: &Ctxt, cont: &Container) {
function check_transparent (line 370) | fn check_transparent(cx: &Ctxt, cont: &mut Container, derive: Derive) {
function member_message (line 448) | fn member_message(member: &Member) -> String {
function allow_transparent (line 455) | fn allow_transparent(field: &Field, derive: Derive) -> bool {
function check_from_and_try_from (line 470) | fn check_from_and_try_from(cx: &Ctxt, cont: &mut Container) {
FILE: serde_derive/src/internals/ctxt.rs
type Ctxt (line 12) | pub struct Ctxt {
method new (line 22) | pub fn new() -> Self {
method error_spanned_by (line 31) | pub fn error_spanned_by<A: ToTokens, T: Display>(&self, obj: A, msg: T) {
method syn_error (line 41) | pub fn syn_error(&self, err: syn::Error) {
method check (line 46) | pub fn check(self) -> syn::Result<()> {
method drop (line 62) | fn drop(&mut self) {
FILE: serde_derive/src/internals/mod.rs
type Derive (line 18) | pub enum Derive {
function ungroup (line 23) | pub fn ungroup(mut ty: &Type) -> &Type {
FILE: serde_derive/src/internals/name.rs
type MultiName (line 9) | pub struct MultiName {
method from_attrs (line 18) | pub(crate) fn from_attrs(
method serialize_name (line 45) | pub fn serialize_name(&self) -> &Name {
method deserialize_name (line 50) | pub fn deserialize_name(&self) -> &Name {
method deserialize_aliases (line 54) | pub(crate) fn deserialize_aliases(&self) -> &BTreeSet<Name> {
type Name (line 60) | pub struct Name {
method from (line 92) | fn from(ident: &Ident) -> Self {
method from (line 101) | fn from(lit: &LitStr) -> Self {
method to_tokens (line 66) | fn to_tokens(&self, tokens: &mut TokenStream) {
method cmp (line 72) | fn cmp(&self, other: &Self) -> Ordering {
method partial_cmp (line 78) | fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
method eq (line 86) | fn eq(&self, other: &Self) -> bool {
method fmt (line 110) | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
FILE: serde_derive/src/internals/receiver.rs
function replace_receiver (line 10) | pub fn replace_receiver(input: &mut DeriveInput) {
type ReplaceReceiver (line 21) | struct ReplaceReceiver<'a>(&'a TypePath);
function self_ty (line 24) | fn self_ty(&self, span: Span) -> TypePath {
function self_to_qself (line 30) | fn self_to_qself(&self, qself: &mut Option<QSelf>, path: &mut Path) {
function self_to_expr_path (line 55) | fn self_to_expr_path(&self, path: &mut Path) {
function visit_type_mut (line 74) | fn visit_type_mut(&mut self, ty: &mut Type) {
function visit_type_path_mut (line 90) | fn visit_type_path_mut(&mut self, ty: &mut TypePath) {
function visit_expr_path_mut (line 98) | fn visit_expr_path_mut(&mut self, expr: &mut ExprPath) {
function visit_type_mut_impl (line 107) | fn visit_type_mut_impl(&mut self, ty: &mut Type) {
function visit_type_path_mut_impl (line 154) | fn visit_type_path_mut_impl(&mut self, ty: &mut TypePath) {
function visit_expr_path_mut_impl (line 161) | fn visit_expr_path_mut_impl(&mut self, expr: &mut ExprPath) {
function visit_path_mut (line 168) | fn visit_path_mut(&mut self, path: &mut Path) {
function visit_path_arguments_mut (line 174) | fn visit_path_arguments_mut(&mut self, arguments: &mut PathArguments) {
function visit_return_type_mut (line 200) | fn visit_return_type_mut(&mut self, return_type: &mut ReturnType) {
function visit_type_param_bound_mut (line 207) | fn visit_type_param_bound_mut(&mut self, bound: &mut TypeParamBound) {
function visit_generics_mut (line 218) | fn visit_generics_mut(&mut self, generics: &mut Generics) {
function visit_data_mut (line 246) | fn visit_data_mut(&mut self, data: &mut Data) {
function visit_expr_mut (line 264) | fn visit_expr_mut(&mut self, expr: &mut Expr) {
function visit_macro_mut (line 292) | fn visit_macro_mut(&mut self, _mac: &mut Macro) {}
FILE: serde_derive/src/internals/respan.rs
function respan (line 3) | pub(crate) fn respan(stream: TokenStream, span: Span) -> TokenStream {
function respan_token (line 10) | fn respan_token(mut token: TokenTree, span: Span) -> TokenTree {
FILE: serde_derive/src/internals/symbol.rs
type Symbol (line 5) | pub struct Symbol(&'static str);
constant ALIAS (line 7) | pub const ALIAS: Symbol = Symbol("alias");
constant BORROW (line 8) | pub const BORROW: Symbol = Symbol("borrow");
constant BOUND (line 9) | pub const BOUND: Symbol = Symbol("bound");
constant CONTENT (line 10) | pub const CONTENT: Symbol = Symbol("content");
constant CRATE (line 11) | pub const CRATE: Symbol = Symbol("crate");
constant DEFAULT (line 12) | pub const DEFAULT: Symbol = Symbol("default");
constant DENY_UNKNOWN_FIELDS (line 13) | pub const DENY_UNKNOWN_FIELDS: Symbol = Symbol("deny_unknown_fields");
constant DESERIALIZE (line 14) | pub const DESERIALIZE: Symbol = Symbol("deserialize");
constant DESERIALIZE_WITH (line 15) | pub const DESERIALIZE_WITH: Symbol = Symbol("deserialize_with");
constant EXPECTING (line 16) | pub const EXPECTING: Symbol = Symbol("expecting");
constant FIELD_IDENTIFIER (line 17) | pub const FIELD_IDENTIFIER: Symbol = Symbol("field_identifier");
constant FLATTEN (line 18) | pub const FLATTEN: Symbol = Symbol("flatten");
constant FROM (line 19) | pub const FROM: Symbol = Symbol("from");
constant GETTER (line 20) | pub const GETTER: Symbol = Symbol("getter");
constant INTO (line 21) | pub const INTO: Symbol = Symbol("into");
constant NON_EXHAUSTIVE (line 22) | pub const NON_EXHAUSTIVE: Symbol = Symbol("non_exhaustive");
constant OTHER (line 23) | pub const OTHER: Symbol = Symbol("other");
constant REMOTE (line 24) | pub const REMOTE: Symbol = Symbol("remote");
constant RENAME (line 25) | pub const RENAME: Symbol = Symbol("rename");
constant RENAME_ALL (line 26) | pub const RENAME_ALL: Symbol = Symbol("rename_all");
constant RENAME_ALL_FIELDS (line 27) | pub const RENAME_ALL_FIELDS: Symbol = Symbol("rename_all_fields");
constant REPR (line 28) | pub const REPR: Symbol = Symbol("repr");
constant SERDE (line 29) | pub const SERDE: Symbol = Symbol("serde");
constant SERIALIZE (line 30) | pub const SERIALIZE: Symbol = Symbol("serialize");
constant SERIALIZE_WITH (line 31) | pub const SERIALIZE_WITH: Symbol = Symbol("serialize_with");
constant SKIP (line 32) | pub const SKIP: Symbol = Symbol("skip");
constant SKIP_DESERIALIZING (line 33) | pub const SKIP_DESERIALIZING: Symbol = Symbol("skip_deserializing");
constant SKIP_SERIALIZING (line 34) | pub const SKIP_SERIALIZING: Symbol = Symbol("skip_serializing");
constant SKIP_SERIALIZING_IF (line 35) | pub const SKIP_SERIALIZING_IF: Symbol = Symbol("skip_serializing_if");
constant TAG (line 36) | pub const TAG: Symbol = Symbol("tag");
constant TRANSPARENT (line 37) | pub const TRANSPARENT: Symbol = Symbol("transparent");
constant TRY_FROM (line 38) | pub const TRY_FROM: Symbol = Symbol("try_from");
constant UNTAGGED (line 39) | pub const UNTAGGED: Symbol = Symbol("untagged");
constant VARIANT_IDENTIFIER (line 40) | pub const VARIANT_IDENTIFIER: Symbol = Symbol("variant_identifier");
constant WITH (line 41) | pub const WITH: Symbol = Symbol("with");
method eq (line 44) | fn eq(&self, word: &Symbol) -> bool {
function eq (line 50) | fn eq(&self, word: &Symbol) -> bool {
method eq (line 56) | fn eq(&self, word: &Symbol) -> bool {
function eq (line 62) | fn eq(&self, word: &Symbol) -> bool {
method fmt (line 68) | fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
FILE: serde_derive/src/lib.rs
type private (line 96) | struct private;
method ident (line 99) | fn ident(&self) -> Ident {
method to_tokens (line 108) | fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
function derive_serialize (line 114) | pub fn derive_serialize(input: TokenStream) -> TokenStream {
function derive_deserialize (line 122) | pub fn derive_deserialize(input: TokenStream) -> TokenStream {
FILE: serde_derive/src/pretend.rs
function pretend_used (line 23) | pub fn pretend_used(cont: &Container, is_packed: bool) -> TokenStream {
function pretend_fields_used (line 65) | fn pretend_fields_used(cont: &Container, is_packed: bool) -> TokenStream {
function pretend_fields_used_struct (line 79) | fn pretend_fields_used_struct(cont: &Container, fields: &[Field]) -> Tok...
function pretend_fields_used_struct_packed (line 94) | fn pretend_fields_used_struct_packed(cont: &Container, fields: &[Field])...
function pretend_fields_used_enum (line 113) | fn pretend_fields_used_enum(cont: &Container, variants: &[Variant]) -> T...
function pretend_variants_used (line 150) | fn pretend_variants_used(cont: &Container) -> TokenStream {
FILE: serde_derive/src/ser.rs
function expand_derive_serialize (line 13) | pub fn expand_derive_serialize(input: &mut syn::DeriveInput) -> syn::Res...
function precondition (line 66) | fn precondition(cx: &Ctxt, cont: &Container) {
type Parameters (line 78) | struct Parameters {
method new (line 103) | fn new(cont: &Container) -> Self {
method type_name (line 128) | fn type_name(&self) -> String {
function build_generics (line 135) | fn build_generics(cont: &Container) -> syn::Generics {
function needs_serialize_bound (line 160) | fn needs_serialize_bound(field: &attr::Field, variant: Option<&attr::Var...
function serialize_body (line 171) | fn serialize_body(cont: &Container, params: &Parameters) -> Fragment {
function serialize_transparent (line 191) | fn serialize_transparent(cont: &Container, params: &Parameters) -> Fragm...
function serialize_into (line 214) | fn serialize_into(params: &Parameters, type_into: &syn::Type) -> Fragment {
function serialize_unit_struct (line 223) | fn serialize_unit_struct(cattrs: &attr::Container) -> Fragment {
function serialize_newtype_struct (line 231) | fn serialize_newtype_struct(
function serialize_tuple_struct (line 257) | fn serialize_tuple_struct(
function serialize_struct (line 296) | fn serialize_struct(params: &Parameters, fields: &[Field], cattrs: &attr...
function serialize_struct_tag_field (line 315) | fn serialize_struct_tag_field(cattrs: &attr::Container, struct_trait: &S...
function serialize_struct_as_struct (line 328) | fn serialize_struct_as_struct(
function serialize_struct_as_map (line 369) | fn serialize_struct_as_map(
function serialize_enum (line 395) | fn serialize_enum(params: &Parameters, variants: &[Variant], cattrs: &at...
function serialize_variant (line 421) | fn serialize_variant(
function serialize_externally_tagged_variant (line 502) | fn serialize_externally_tagged_variant(
function serialize_internally_tagged_variant (line 575) | fn serialize_internally_tagged_variant(
function serialize_adjacently_tagged_variant (line 641) | fn serialize_adjacently_tagged_variant(
function serialize_untagged_variant (line 765) | fn serialize_untagged_variant(
type TupleVariant (line 804) | enum TupleVariant<'a> {
function serialize_tuple_variant (line 813) | fn serialize_tuple_variant(
type StructVariant (line 872) | enum StructVariant<'a> {
function serialize_struct_variant (line 884) | fn serialize_struct_variant(
function serialize_struct_variant_with_flatten (line 968) | fn serialize_struct_variant_with_flatten(
function serialize_tuple_struct_visitor (line 1056) | fn serialize_tuple_struct_visitor(
function serialize_struct_visitor (line 1105) | fn serialize_struct_visitor(
function wrap_serialize_field_with (line 1173) | fn wrap_serialize_field_with(
function wrap_serialize_variant_with (line 1182) | fn wrap_serialize_variant_with(
function wrap_serialize_with (line 1207) | fn wrap_serialize_with(
function mut_if (line 1271) | fn mut_if(is_mut: bool) -> Option<TokenStream> {
function get_member (line 1279) | fn get_member(params: &Parameters, field: &Field, member: &Member) -> To...
function effective_style (line 1308) | fn effective_style(variant: &Variant) -> Style {
type StructTrait (line 1315) | enum StructTrait {
method serialize_field (line 1322) | fn serialize_field(&self, span: Span) -> TokenStream {
method skip_field (line 1336) | fn skip_field(&self, span: Span) -> Option<TokenStream> {
type TupleTrait (line 1349) | enum TupleTrait {
method serialize_element (line 1356) | fn serialize_element(&self, span: Span) -> TokenStream {
FILE: serde_derive/src/this.rs
function this_type (line 4) | pub fn this_type(cont: &Container) -> Path {
function this_value (line 18) | pub fn this_value(cont: &Container) -> Path {
FILE: serde_derive_internals/build.rs
function main (line 3) | fn main() {
FILE: test_suite/no_std/src/main.rs
function main (line 7) | extern "C" fn main(_argc: c_int, _argv: *const *const u8) -> c_int {
function panic (line 12) | fn panic(_info: &core::panic::PanicInfo) -> ! {
type Unit (line 23) | pub struct Unit;
type Newtype (line 26) | pub struct Newtype(u8);
type Tuple (line 29) | pub struct Tuple(u8, u8);
type Struct (line 32) | pub struct Struct {
type Enum (line 37) | pub enum Enum {
FILE: test_suite/tests/bytes/mod.rs
function deserialize (line 4) | pub fn deserialize<'de, D>(deserializer: D) -> Result<Vec<u8>, D::Error>
type ByteBufVisitor (line 11) | struct ByteBufVisitor;
type Value (line 14) | type Value = Vec<u8>;
method expecting (line 16) | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
method visit_seq (line 20) | fn visit_seq<V>(self, mut visitor: V) -> Result<Self::Value, V::Error>
method visit_bytes (line 31) | fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
method visit_byte_buf (line 38) | fn visit_byte_buf<E>(self, v: Vec<u8>) -> Result<Self::Value, E>
method visit_str (line 45) | fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
method visit_string (line 52) | fn visit_string<E>(self, v: String) -> Result<Self::Value, E>
FILE: test_suite/tests/compiletest.rs
function ui (line 6) | fn ui() {
FILE: test_suite/tests/macros/mod.rs
type SingleTokenIntoIterator (line 60) | pub trait SingleTokenIntoIterator {
method into_iter (line 61) | fn into_iter(self) -> iter::Once<Token>;
method into_iter (line 65) | fn into_iter(self) -> iter::Once<Token> {
FILE: test_suite/tests/regression/issue1904.rs
type Nested (line 6) | pub struct Nested;
type ExternallyTagged1 (line 9) | pub enum ExternallyTagged1 {
type ExternallyTagged2 (line 18) | pub enum ExternallyTagged2 {
type AdjacentlyTagged1 (line 30) | pub enum AdjacentlyTagged1 {
type AdjacentlyTagged2 (line 40) | pub enum AdjacentlyTagged2 {
type Untagged1 (line 50) | pub enum Untagged1 {
type Untagged2 (line 60) | pub enum Untagged2 {
FILE: test_suite/tests/regression/issue2371.rs
type Nested (line 6) | pub struct Nested;
type ExternallyTagged (line 9) | pub enum ExternallyTagged {
type InternallyTagged (line 21) | pub enum InternallyTagged {
type AdjacentlyTagged (line 33) | pub enum AdjacentlyTagged {
type UntaggedWorkaround (line 45) | pub enum UntaggedWorkaround {
FILE: test_suite/tests/regression/issue2415.rs
type S (line 6) | pub struct S;
FILE: test_suite/tests/regression/issue2565.rs
type Enum (line 5) | enum Enum {
function simple_variant (line 17) | fn simple_variant() {
function flatten_variant (line 34) | fn flatten_variant() {
FILE: test_suite/tests/regression/issue2792.rs
type A (line 7) | pub enum A {
type E (line 18) | pub struct E {}
FILE: test_suite/tests/regression/issue2844.rs
function serialize (line 20) | pub fn serialize<S>(_: &i32, _: S) -> Result<S::Ok, S::Error>
function deserialize (line 27) | pub fn deserialize<'de, D>(_: D) -> Result<i32, D::Error>
FILE: test_suite/tests/regression/issue2846.rs
function deserialize (line 21) | pub fn deserialize<'de, D>(_: D) -> Result<i32, D::Error>
FILE: test_suite/tests/test_annotations.rs
type MyDefault (line 25) | trait MyDefault: Sized {
method my_default (line 26) | fn my_default() -> Self;
method my_default (line 46) | fn my_default() -> Self {
method my_default (line 313) | fn my_default() -> Self {
method my_default (line 384) | fn my_default() -> Self {
type ShouldSkip (line 29) | trait ShouldSkip: Sized {
method should_skip (line 30) | fn should_skip(&self) -> bool;
method should_skip (line 52) | fn should_skip(&self) -> bool {
type SerializeWith (line 33) | trait SerializeWith: Sized {
method serialize_with (line 34) | fn serialize_with<S>(&self, ser: S) -> Result<S::Ok, S::Error>
method serialize_with (line 58) | fn serialize_with<S>(&self, ser: S) -> Result<S::Ok, S::Error>
method serialize_with (line 1021) | fn serialize_with<S>(&self, ser: S) -> Result<S::Ok, S::Error>
type DeserializeWith (line 39) | trait DeserializeWith: Sized {
method deserialize_with (line 40) | fn deserialize_with<'de, D>(de: D) -> Result<Self, D::Error>
method deserialize_with (line 71) | fn deserialize_with<'de, D>(de: D) -> Result<Self, D::Error>
method deserialize_with (line 369) | fn deserialize_with<'de, D>(_: D) -> Result<Self, D::Error>
type DefaultStruct (line 84) | struct DefaultStruct<A, B, C, D, E>
type DefaultTupleStruct (line 101) | struct DefaultTupleStruct<A, B, C>(
type CollectOther (line 110) | struct CollectOther {
function test_default_struct (line 118) | fn test_default_struct() {
function test_default_tuple (line 167) | fn test_default_tuple() {
type DefaultStructVariant (line 196) | enum DefaultStructVariant<A, B, C, D, E>
type DefaultTupleVariant (line 215) | enum DefaultTupleVariant<A, B, C>
function test_default_struct_variant (line 227) | fn test_default_struct_variant() {
function test_default_tuple_variant (line 278) | fn test_default_tuple_variant() {
type NoStdDefault (line 310) | struct NoStdDefault(i8);
type ContainsNoStdDefault (line 319) | struct ContainsNoStdDefault<A: MyDefault> {
function test_no_std_default (line 327) | fn test_no_std_default() {
type NotDeserializeStruct (line 360) | struct NotDeserializeStruct(i8);
method default (line 363) | fn default() -> Self {
type NotDeserializeEnum (line 379) | enum NotDeserializeEnum {
type ContainsNotDeserialize (line 390) | struct ContainsNotDeserialize<A, B, C: DeserializeWith, E: MyDefault> {
function test_elt_not_deserialize (line 405) | fn test_elt_not_deserialize() {
type DenyUnknown (line 425) | struct DenyUnknown {
function test_ignore_unknown (line 430) | fn test_ignore_unknown() {
type RenameStruct (line 479) | struct RenameStruct {
type RenameStructSerializeDeserialize (line 487) | struct RenameStructSerializeDeserialize {
type AliasStruct (line 495) | struct AliasStruct {
function test_rename_struct (line 504) | fn test_rename_struct() {
function test_unknown_field_rename_struct (line 594) | fn test_unknown_field_rename_struct() {
type RenameEnum (line 614) | enum RenameEnum {
type RenameEnumSerializeDeserialize (line 630) | enum RenameEnumSerializeDeserialize<A> {
type AliasEnum (line 642) | enum AliasEnum {
function test_rename_enum (line 654) | fn test_rename_enum() {
function test_unknown_field_rename_enum (line 778) | fn test_unknown_field_rename_enum() {
type SkipSerializingStruct (line 807) | struct SkipSerializingStruct<'a, B, C>
function test_skip_serializing_struct (line 819) | fn test_skip_serializing_struct() {
type SkipSerializingTupleStruct (line 855) | struct SkipSerializingTupleStruct<'a, B, C>(
function test_skip_serializing_tuple_struct (line 864) | fn test_skip_serializing_tuple_struct() {
type SkipStruct (line 893) | struct SkipStruct<B> {
function test_skip_struct (line 900) | fn test_skip_struct() {
type SkipSerializingEnum (line 929) | enum SkipSerializingEnum<'a, B, C>
function test_skip_serializing_enum (line 948) | fn test_skip_serializing_enum() {
type NotSerializeStruct (line 1013) | struct NotSerializeStruct(i8);
type NotSerializeEnum (line 1016) | enum NotSerializeEnum {
type ContainsNotSerialize (line 1030) | struct ContainsNotSerialize<'a, B, C, D>
function test_elt_not_serialize (line 1045) | fn test_elt_not_serialize() {
type SerializeWithStruct (line 1070) | struct SerializeWithStruct<'a, B>
function test_serialize_with_struct (line 1080) | fn test_serialize_with_struct() {
type SerializeWithEnum (line 1114) | enum SerializeWithEnum<'a, B>
function test_serialize_with_enum (line 1126) | fn test_serialize_with_enum() {
type WithVariant (line 1162) | enum WithVariant {
function serialize_unit_variant_as_i8 (line 1180) | fn serialize_unit_variant_as_i8<S>(serializer: S) -> Result<S::Ok, S::Er...
function deserialize_i8_as_unit_variant (line 1187) | fn deserialize_i8_as_unit_variant<'de, D>(deserializer: D) -> Result<(),...
function serialize_variant_as_string (line 1198) | fn serialize_variant_as_string<S>(f1: &str, f2: &u8, serializer: S) -> R...
function deserialize_string_as_variant (line 1205) | fn deserialize_string_as_variant<'de, D>(deserializer: D) -> Result<(Str...
function test_serialize_with_variant (line 1227) | fn test_serialize_with_variant() {
function test_deserialize_with_variant (line 1277) | fn test_deserialize_with_variant() {
type DeserializeWithStruct (line 1327) | struct DeserializeWithStruct<B>
function test_deserialize_with_struct (line 1337) | fn test_deserialize_with_struct() {
type DeserializeWithEnum (line 1370) | enum DeserializeWithEnum<B>
function test_deserialize_with_enum (line 1382) | fn test_deserialize_with_enum() {
function test_missing_renamed_field_struct (line 1417) | fn test_missing_renamed_field_struct() {
function test_missing_renamed_field_enum (line 1446) | fn test_missing_renamed_field_enum() {
type InvalidLengthEnum (line 1475) | enum InvalidLengthEnum {
function test_invalid_length_enum (line 1481) | fn test_invalid_length_enum() {
type StructFromEnum (line 1510) | struct StructFromEnum(Option<u32>);
method into (line 1513) | fn into(self) -> EnumToU32 {
method from (line 1521) | fn from(v: EnumToU32) -> Self {
type EnumToU32 (line 1528) | enum EnumToU32 {
method into (line 1537) | fn into(self) -> Option<u32> {
method from (line 1549) | fn from(v: Option<u32>) -> Self {
type TryFromU32 (line 1562) | enum TryFromU32 {
type Error (line 1568) | type Error = String;
method try_from (line 1570) | fn try_from(value: u32) -> Result<Self, Self::Error> {
function test_from_into_traits (line 1580) | fn test_from_into_traits() {
function test_collect_other (line 1592) | fn test_collect_other() {
function test_partially_untagged_enum (line 1611) | fn test_partially_untagged_enum() {
function test_partially_untagged_enum_generic (line 1642) | fn test_partially_untagged_enum_generic() {
function test_partially_untagged_enum_desugared (line 1681) | fn test_partially_untagged_enum_desugared() {
function test_partially_untagged_internally_tagged_enum (line 1767) | fn test_partially_untagged_internally_tagged_enum() {
function test_transparent_struct (line 1797) | fn test_transparent_struct() {
function test_transparent_tuple_struct (line 1821) | fn test_transparent_tuple_struct() {
function test_expecting_message (line 1835) | fn test_expecting_message() {
function test_expecting_message_externally_tagged_enum (line 1879) | fn test_expecting_message_externally_tagged_enum() {
function test_expecting_message_identifier_enum (line 1899) | fn test_expecting_message_identifier_enum() {
function complex (line 1949) | fn complex() {
function map_twice (line 2053) | fn map_twice() {
function unsupported_type (line 2096) | fn unsupported_type() {
function unknown_field (line 2130) | fn unknown_field() {
function non_string_keys (line 2168) | fn non_string_keys() {
function lifetime_propagation (line 2199) | fn lifetime_propagation() {
function enum_tuple_and_struct (line 2283) | fn enum_tuple_and_struct() {
function option (line 2332) | fn option() {
function ignored_any (line 2402) | fn ignored_any() {
function flatten_any_after_flatten_struct (line 2427) | fn flatten_any_after_flatten_struct() {
function alias (line 2488) | fn alias() {
function unit (line 2553) | fn unit() {
function unit_struct (line 2576) | fn unit_struct() {
function straightforward (line 2610) | fn straightforward() {
type Flatten (line 2648) | struct Flatten {
type Enum (line 2657) | enum Enum {
function unit (line 2665) | fn unit() {
function newtype (line 2699) | fn newtype() {
function tuple (line 2742) | fn tuple() {
function struct_from_seq (line 2785) | fn struct_from_seq() {
function struct_from_map (line 2831) | fn struct_from_map() {
type Flatten (line 2888) | struct Flatten {
type NewtypeWrapper (line 2896) | struct NewtypeWrapper(pub Enum);
type Enum (line 2900) | enum Enum {
type NewtypeVariant (line 2907) | struct NewtypeVariant {
function unit (line 2912) | fn unit() {
function newtype (line 3076) | fn newtype() {
function struct_ (line 3240) | fn struct_() {
function structs (line 3423) | fn structs() {
function unit_enum_with_unknown_fields (line 3487) | fn unit_enum_with_unknown_fields() {
type Flatten (line 3549) | struct Flatten {
type Enum (line 3556) | enum Enum {
function struct_ (line 3561) | fn struct_() {
FILE: test_suite/tests/test_borrow.rs
function test_borrowed_str (line 17) | fn test_borrowed_str() {
function test_borrowed_str_from_string (line 22) | fn test_borrowed_str_from_string() {
function test_borrowed_str_from_str (line 30) | fn test_borrowed_str_from_str() {
function test_string_from_borrowed_str (line 38) | fn test_string_from_borrowed_str() {
function test_borrowed_bytes (line 43) | fn test_borrowed_bytes() {
function test_borrowed_bytes_from_bytebuf (line 48) | fn test_borrowed_bytes_from_bytebuf() {
function test_borrowed_bytes_from_bytes (line 56) | fn test_borrowed_bytes_from_bytes() {
function test_tuple (line 64) | fn test_tuple() {
function test_struct (line 77) | fn test_struct() {
function test_field_identifier (line 104) | fn test_field_identifier() {
function test_cow (line 128) | fn test_cow() {
function test_lifetimes (line 166) | fn test_lifetimes() {
FILE: test_suite/tests/test_de.rs
type UnitStruct (line 45) | struct UnitStruct;
type GenericUnitStruct (line 48) | struct GenericUnitStruct<const N: u8>;
type NewtypeStruct (line 51) | struct NewtypeStruct(i32);
type TupleStruct (line 54) | struct TupleStruct(i32, i32, i32);
type Struct (line 57) | struct Struct {
type StructDefault (line 66) | struct StructDefault<T> {
method default (line 72) | fn default() -> Self {
type StructSkipAll (line 81) | struct StructSkipAll {
type StructSkipDefault (line 88) | struct StructSkipDefault {
type StructSkipDefaultGeneric (line 95) | pub struct StructSkipDefaultGeneric<T> {
method default (line 101) | fn default() -> Self {
type StructSkipAllDenyUnknown (line 108) | struct StructSkipAllDenyUnknown {
type NotDeserializable (line 114) | struct NotDeserializable;
type Enum (line 117) | enum Enum {
type EnumOther (line 133) | enum EnumOther {
type IgnoredAny (line 140) | struct IgnoredAny;
method deserialize (line 143) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
function test (line 155) | fn test<'de, T>(value: T, tokens: &'de [Token])
type SkipPartialEq (line 167) | struct SkipPartialEq<T>(T);
function deserialize (line 173) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
method eq (line 182) | fn eq(&self, _other: &Self) -> bool {
function assert_de_tokens_ignore (line 188) | fn assert_de_tokens_ignore(ignorable_tokens: &[Token]) {
function test_bool (line 214) | fn test_bool() {
function test_i8 (line 220) | fn test_i8() {
function test_i16 (line 245) | fn test_i16() {
function test_i32 (line 270) | fn test_i32() {
function test_i64 (line 295) | fn test_i64() {
function test_i128 (line 320) | fn test_i128() {
function test_isize (line 345) | fn test_isize() {
function test_u8 (line 370) | fn test_u8() {
function test_u16 (line 395) | fn test_u16() {
function test_u32 (line 420) | fn test_u32() {
function test_u64 (line 445) | fn test_u64() {
function test_u128 (line 470) | fn test_u128() {
function test_usize (line 495) | fn test_usize() {
function test_nonzero_i8 (line 520) | fn test_nonzero_i8() {
function test_nonzero_i16 (line 545) | fn test_nonzero_i16() {
function test_nonzero_i32 (line 570) | fn test_nonzero_i32() {
function test_nonzero_i64 (line 595) | fn test_nonzero_i64() {
function test_nonzero_i128 (line 620) | fn test_nonzero_i128() {
function test_nonzero_isize (line 645) | fn test_nonzero_isize() {
function test_nonzero_u8 (line 670) | fn test_nonzero_u8() {
function test_nonzero_u16 (line 695) | fn test_nonzero_u16() {
function test_nonzero_u32 (line 720) | fn test_nonzero_u32() {
function test_nonzero_u64 (line 745) | fn test_nonzero_u64() {
function test_nonzero_u128 (line 770) | fn test_nonzero_u128() {
function test_nonzero_usize (line 795) | fn test_nonzero_usize() {
function test_f32 (line 820) | fn test_f32() {
function test_f64 (line 828) | fn test_f64() {
function test_nan (line 836) | fn test_nan() {
function test_char (line 856) | fn test_char() {
function test_string (line 863) | fn test_string() {
function test_option (line 870) | fn test_option() {
function test_result (line 877) | fn test_result() {
function test_unit (line 897) | fn test_unit() {
function test_unit_struct (line 902) | fn test_unit_struct() {
function test_generic_unit_struct (line 908) | fn test_generic_unit_struct() {
function test_newtype_struct (line 919) | fn test_newtype_struct() {
function test_tuple_struct (line 932) | fn test_tuple_struct() {
function test_btreeset (line 982) | fn test_btreeset() {
function test_hashset (line 1016) | fn test_hashset() {
function test_vec (line 1054) | fn test_vec() {
function test_array (line 1089) | fn test_array() {
function test_tuple (line 1137) | fn test_tuple() {
function test_btreemap (line 1169) | fn test_btreemap() {
function test_hashmap (line 1224) | fn test_hashmap() {
function test_struct (line 1290) | fn test_struct() {
function test_struct_borrowed_keys (line 1395) | fn test_struct_borrowed_keys() {
function test_struct_owned_keys (line 1424) | fn test_struct_owned_keys() {
function test_struct_with_skip (line 1453) | fn test_struct_with_skip() {
function test_struct_skip_all (line 1505) | fn test_struct_skip_all() {
function test_struct_skip_default (line 1533) | fn test_struct_skip_default() {
function test_struct_skip_all_deny_unknown (line 1547) | fn test_struct_skip_all_deny_unknown() {
function test_struct_default (line 1561) | fn test_struct_default() {
function test_enum_unit (line 1595) | fn test_enum_unit() {
function test_enum_simple (line 1606) | fn test_enum_simple() {
function test_enum_simple_with_skipped (line 1620) | fn test_enum_simple_with_skipped() {
function test_enum_seq (line 1631) | fn test_enum_seq() {
function test_enum_map (line 1649) | fn test_enum_map() {
function test_enum_unit_usize (line 1670) | fn test_enum_unit_usize() {
function test_enum_unit_bytes (line 1678) | fn test_enum_unit_bytes() {
function test_enum_other_unit (line 1690) | fn test_enum_other_unit() {
function test_enum_other (line 1730) | fn test_enum_other() {
function test_box (line 1774) | fn test_box() {
function test_boxed_slice (line 1779) | fn test_boxed_slice() {
function test_duration (line 1793) | fn test_duration() {
function test_system_time (line 1820) | fn test_system_time() {
function test_range (line 1847) | fn test_range() {
function test_range_inclusive (line 1874) | fn test_range_inclusive() {
function test_range_from (line 1901) | fn test_range_from() {
function test_range_to (line 1921) | fn test_range_to() {
function test_bound (line 1941) | fn test_bound() {
function test_path (line 1969) | fn test_path() {
function test_path_buf (line 1981) | fn test_path_buf() {
function test_boxed_path (line 2001) | fn test_boxed_path() {
function test_cstring (line 2021) | fn test_cstring() {
function test_rc (line 2026) | fn test_rc() {
function test_rc_weak_some (line 2031) | fn test_rc_weak_some() {
function test_rc_weak_none (line 2039) | fn test_rc_weak_none() {
function test_arc (line 2044) | fn test_arc() {
function test_arc_weak_some (line 2049) | fn test_arc_weak_some() {
function test_arc_weak_none (line 2057) | fn test_arc_weak_none() {
function test_wrapping (line 2062) | fn test_wrapping() {
function test_saturating (line 2068) | fn test_saturating() {
function test_rc_dst (line 2105) | fn test_rc_dst() {
function test_arc_dst (line 2118) | fn test_arc_dst() {
function test_ignored_any (line 2131) | fn test_ignored_any() {
function test_net_ipv4addr_readable (line 2148) | fn test_net_ipv4addr_readable() {
function test_net_ipv6addr_readable (line 2156) | fn test_net_ipv6addr_readable() {
function test_net_ipaddr_readable (line 2164) | fn test_net_ipaddr_readable() {
function test_net_socketaddr_readable (line 2172) | fn test_net_socketaddr_readable() {
function test_net_ipv4addr_compact (line 2197) | fn test_net_ipv4addr_compact() {
function test_net_ipv6addr_compact (line 2209) | fn test_net_ipv6addr_compact() {
function test_net_ipaddr_compact (line 2221) | fn test_net_ipaddr_compact() {
function test_net_socketaddr_compact (line 2237) | fn test_net_socketaddr_compact() {
function test_never_result (line 2294) | fn test_never_result() {
function test_osstring (line 2309) | fn test_osstring() {
function test_osstring (line 2329) | fn test_osstring() {
function test_cstr (line 2348) | fn test_cstr() {
function test_atomics (line 2356) | fn test_atomics() {
FILE: test_suite/tests/test_de_error.rs
type UnitStruct (line 20) | struct UnitStruct;
type Struct (line 23) | struct Struct {
type StructDenyUnknown (line 32) | struct StructDenyUnknown {
type StructSkipAllDenyUnknown (line 40) | struct StructSkipAllDenyUnknown {
type NotDeserializable (line 46) | struct NotDeserializable;
type Enum (line 49) | enum Enum {
type EnumSkipAll (line 65) | enum EnumSkipAll {
function test_i8 (line 72) | fn test_i8() {
function test_i16 (line 121) | fn test_i16() {
function test_i32 (line 158) | fn test_i32() {
function test_i64 (line 183) | fn test_i64() {
function test_i128 (line 194) | fn test_i128() {
function test_u8 (line 204) | fn test_u8() {
function test_u16 (line 250) | fn test_u16() {
function test_u32 (line 291) | fn test_u32() {
function test_u64 (line 324) | fn test_u64() {
function test_u128 (line 354) | fn test_u128() {
function test_usize (line 384) | fn test_usize() {
function test_nonzero_i8 (line 407) | fn test_nonzero_i8() {
function test_nonzero_i16 (line 490) | fn test_nonzero_i16() {
function test_nonzero_i32 (line 561) | fn test_nonzero_i32() {
function test_nonzero_i64 (line 620) | fn test_nonzero_i64() {
function test_nonzero_i128 (line 665) | fn test_nonzero_i128() {
function test_nonzero_isize (line 704) | fn test_nonzero_isize() {
function test_nonzero_u8 (line 743) | fn test_nonzero_u8() {
function test_nonzero_u16 (line 826) | fn test_nonzero_u16() {
function test_nonzero_u32 (line 901) | fn test_nonzero_u32() {
function test_nonzero_u64 (line 968) | fn test_nonzero_u64() {
function test_nonzero_u128 (line 1025) | fn test_nonzero_u128() {
function test_nonzero_usize (line 1082) | fn test_nonzero_usize() {
function test_unknown_field (line 1139) | fn test_unknown_field() {
function test_skipped_field_is_unknown (line 1155) | fn test_skipped_field_is_unknown() {
function test_skip_all_deny_unknown (line 1169) | fn test_skip_all_deny_unknown() {
function test_unknown_variant (line 1183) | fn test_unknown_variant() {
function test_enum_skipped_variant (line 1193) | fn test_enum_skipped_variant() {
function test_enum_skip_all (line 1203) | fn test_enum_skip_all() {
function test_duplicate_field_struct (line 1214) | fn test_duplicate_field_struct() {
function test_duplicate_field_enum (line 1227) | fn test_duplicate_field_enum() {
function test_enum_out_of_range (line 1244) | fn test_enum_out_of_range() {
function test_short_tuple (line 1252) | fn test_short_tuple() {
function test_short_array (line 1260) | fn test_short_array() {
function test_cstring_internal_null (line 1268) | fn test_cstring_internal_null() {
function test_cstring_internal_null_end (line 1276) | fn test_cstring_internal_null_end() {
function test_unit_from_empty_seq (line 1284) | fn test_unit_from_empty_seq() {
function test_unit_from_empty_seq_without_len (line 1292) | fn test_unit_from_empty_seq_without_len() {
function test_unit_from_tuple_struct (line 1300) | fn test_unit_from_tuple_struct() {
function test_string_from_unit (line 1314) | fn test_string_from_unit() {
function test_btreeset_from_unit (line 1322) | fn test_btreeset_from_unit() {
function test_btreeset_from_unit_struct (line 1330) | fn test_btreeset_from_unit_struct() {
function test_hashset_from_unit (line 1338) | fn test_hashset_from_unit() {
function test_hashset_from_unit_struct (line 1346) | fn test_hashset_from_unit_struct() {
function test_vec_from_unit (line 1354) | fn test_vec_from_unit() {
function test_vec_from_unit_struct (line 1362) | fn test_vec_from_unit_struct() {
function test_zero_array_from_unit (line 1370) | fn test_zero_array_from_unit() {
function test_zero_array_from_unit_struct (line 1378) | fn test_zero_array_from_unit_struct() {
function test_btreemap_from_unit (line 1386) | fn test_btreemap_from_unit() {
function test_btreemap_from_unit_struct (line 1394) | fn test_btreemap_from_unit_struct() {
function test_hashmap_from_unit (line 1402) | fn test_hashmap_from_unit() {
function test_hashmap_from_unit_struct (line 1410) | fn test_hashmap_from_unit_struct() {
function test_bool_from_string (line 1418) | fn test_bool_from_string() {
function test_number_from_string (line 1426) | fn test_number_from_string() {
function test_integer_from_float (line 1434) | fn test_integer_from_float() {
function test_nan_no_decimal_point (line 1442) | fn test_nan_no_decimal_point() {
function test_unit_struct_from_seq (line 1450) | fn test_unit_struct_from_seq() {
function test_wrapping_overflow (line 1458) | fn test_wrapping_overflow() {
function test_duration_overflow_seq (line 1466) | fn test_duration_overflow_seq() {
function test_duration_overflow_struct (line 1479) | fn test_duration_overflow_struct() {
function test_systemtime_overflow_seq (line 1497) | fn test_systemtime_overflow_seq() {
function test_systemtime_overflow_struct (line 1510) | fn test_systemtime_overflow_struct() {
function test_systemtime_overflow (line 1528) | fn test_systemtime_overflow() {
function test_cstr_internal_null (line 1541) | fn test_cstr_internal_null() {
function test_cstr_internal_null_end (line 1549) | fn test_cstr_internal_null_end() {
function test_never_type (line 1558) | fn test_never_type() {
FILE: test_suite/tests/test_deprecated.rs
type DeprecatedEnum (line 8) | enum DeprecatedEnum {
type DeprecatedStruct (line 15) | struct DeprecatedStruct {
type DeprecatedVariant (line 20) | enum DeprecatedVariant {
type DeprecatedField (line 27) | struct DeprecatedField {
FILE: test_suite/tests/test_enum_adjacently_tagged.rs
type AdjacentlyTagged (line 14) | enum AdjacentlyTagged<T> {
function map_str_tag_only (line 25) | fn map_str_tag_only() {
function map_int_tag_only (line 62) | fn map_int_tag_only() {
function map_bytes_tag_only (line 82) | fn map_bytes_tag_only() {
function map_str_tag_content (line 119) | fn map_str_tag_content() {
function map_int_tag_content (line 184) | fn map_int_tag_content() {
function map_bytes_tag_content (line 225) | fn map_bytes_tag_content() {
function seq_tag_content (line 266) | fn seq_tag_content() {
function map_tag_only (line 309) | fn map_tag_only() {
function map_tag_content (line 329) | fn map_tag_content() {
function seq (line 372) | fn seq() {
function newtype_with_newtype (line 414) | fn newtype_with_newtype() {
function map (line 444) | fn map() {
function seq (line 493) | fn seq() {
function map (line 519) | fn map() {
function seq (line 574) | fn seq() {
function struct_with_flatten (line 600) | fn struct_with_flatten() {
function expecting_message (line 646) | fn expecting_message() {
function partially_untagged (line 672) | fn partially_untagged() {
function deny_unknown_fields (line 704) | fn deny_unknown_fields() {
FILE: test_suite/tests/test_enum_internally_tagged.rs
type Unit (line 17) | struct Unit;
type Newtype (line 20) | struct Newtype(BTreeMap<String, String>);
type Struct (line 23) | struct Struct {
type Enum (line 28) | enum Enum {
type InternallyTagged (line 37) | enum InternallyTagged {
function unit (line 50) | fn unit() {
function newtype_unit (line 114) | fn newtype_unit() {
function newtype_unit_struct (line 163) | fn newtype_unit_struct() {
function newtype_newtype (line 229) | fn newtype_newtype() {
function newtype_map (line 242) | fn newtype_map() {
function newtype_struct (line 331) | fn newtype_struct() {
function unit (line 418) | fn unit() {
function newtype (line 471) | fn newtype() {
function tuple (line 524) | fn tuple() {
function struct_ (line 604) | fn struct_() {
function struct_ (line 744) | fn struct_() {
function unit (line 879) | fn unit() {
function wrong_tag (line 1041) | fn wrong_tag() {
function untagged_variant (line 1068) | fn untagged_variant() {
type InternallyTagged (line 1166) | enum InternallyTagged {
function string_from_string (line 1177) | fn string_from_string() {
function string_from_bytes (line 1214) | fn string_from_bytes() {
function bytes_from_string (line 1251) | fn bytes_from_string() {
function bytes_from_bytes (line 1284) | fn bytes_from_bytes() {
function bytes_from_seq (line 1317) | fn bytes_from_seq() {
function borrow (line 1338) | fn borrow() {
function with_skipped_conflict (line 1362) | fn with_skipped_conflict() {
function containing_flatten (line 1395) | fn containing_flatten() {
function unit_variant_with_unknown_fields (line 1432) | fn unit_variant_with_unknown_fields() {
function expecting_message (line 1460) | fn expecting_message() {
FILE: test_suite/tests/test_enum_untagged.rs
function complex (line 16) | fn complex() {
function newtype_unit_and_empty_map (line 90) | fn newtype_unit_and_empty_map() {
function newtype_struct (line 109) | fn newtype_struct() {
type Outer (line 142) | enum Outer {
type Inner (line 147) | enum Inner {
function unit (line 158) | fn unit() {
function newtype (line 170) | fn newtype() {
function tuple0 (line 185) | fn tuple0() {
function tuple2 (line 201) | fn tuple2() {
function struct_from_map (line 220) | fn struct_from_map() {
function struct_from_seq (line 239) | fn struct_from_seq() {
function empty_struct_from_map (line 259) | fn empty_struct_from_map() {
function empty_struct_from_seq (line 278) | fn empty_struct_from_seq() {
type Enum (line 300) | enum Enum {
function some (line 306) | fn some() {
function some_without_marker (line 323) | fn some_without_marker() {
function none (line 339) | fn none() {
function unit (line 355) | fn unit() {
function string_and_bytes (line 369) | fn string_and_bytes() {
function contains_flatten (line 511) | fn contains_flatten() {
function contains_flatten_with_integer_key (line 546) | fn contains_flatten_with_integer_key() {
function expecting_message (line 574) | fn expecting_message() {
FILE: test_suite/tests/test_gen.rs
type Result (line 38) | struct Result;
type Ok (line 40) | struct Ok;
type Err (line 42) | struct Err;
type Option (line 44) | struct Option;
type Some (line 46) | struct Some;
type None (line 48) | struct None;
function test_gen (line 53) | fn test_gen() {
function assert (line 823) | fn assert<T: Serialize + DeserializeOwned>() {}
function assert_ser (line 824) | fn assert_ser<T: Serialize>() {}
type SerializeWith (line 826) | trait SerializeWith {
method serialize_with (line 827) | fn serialize_with<S: Serializer>(_: &Self, _: S) -> StdResult<S::Ok, S...
method serialize_with (line 850) | fn serialize_with<S: Serializer>(_: &Self, _: S) -> StdResult<S::Ok, S...
type DeserializeWith (line 830) | trait DeserializeWith: Sized {
method deserialize_with (line 831) | fn deserialize_with<'de, D: Deserializer<'de>>(_: D) -> StdResult<Self...
method deserialize_with (line 856) | fn deserialize_with<'de, D: Deserializer<'de>>(_: D) -> StdResult<Self...
type X (line 835) | pub struct X;
function ser_x (line 837) | pub fn ser_x<S: Serializer>(_: &X, _: S) -> StdResult<S::Ok, S::Error> {
function de_x (line 841) | pub fn de_x<'de, D: Deserializer<'de>>(_: D) -> StdResult<X, D::Error> {
function serialize_some_unit_variant (line 861) | pub fn serialize_some_unit_variant<S>(_: S) -> StdResult<S::Ok, S::Error>
function deserialize_some_unit_variant (line 868) | pub fn deserialize_some_unit_variant<'de, D>(_: D) -> StdResult<(), D::E...
function serialize_some_other_variant (line 875) | pub fn serialize_some_other_variant<S>(_: &str, _: &u8, _: S) -> StdResu...
function deserialize_some_other_variant (line 882) | pub fn deserialize_some_other_variant<'de, D>(_: D) -> StdResult<(String...
function is_zero (line 889) | pub fn is_zero(n: &u8) -> bool {
function vec_first_element (line 893) | fn vec_first_element<T, S>(vec: &[T], serializer: S) -> StdResult<S::Ok,...
type InternallyTagged (line 905) | pub enum InternallyTagged {
function deserialize_generic (line 916) | fn deserialize_generic<'de, T, D>(deserializer: D) -> StdResult<T, D::Er...
type RemotePacked (line 927) | pub struct RemotePacked {
type RemotePackedDef (line 935) | pub struct RemotePackedDef {
method drop (line 941) | fn drop(&mut self) {}
type RemotePackedNonCopy (line 945) | pub struct RemotePackedNonCopy {
type RemotePackedNonCopyDef (line 953) | pub struct RemotePackedNonCopyDef {
method drop (line 959) | fn drop(&mut self) {}
FILE: test_suite/tests/test_identifier.rs
type V (line 13) | enum V {
function variant1 (line 20) | fn variant1() {
function aliases (line 30) | fn aliases() {
function unknown (line 47) | fn unknown() {
type F (line 80) | enum F {
function field1 (line 87) | fn field1() {
function aliases (line 97) | fn aliases() {
function unknown (line 114) | fn unknown() {
function unit_fallthrough (line 142) | fn unit_fallthrough() {
function newtype_fallthrough (line 160) | fn newtype_fallthrough() {
function newtype_fallthrough_generic (line 173) | fn newtype_fallthrough_generic() {
FILE: test_suite/tests/test_ignored_any.rs
type Target (line 12) | enum Target {
type Enum (line 19) | struct Enum(&'static str);
type Error (line 22) | type Error = Error;
method deserialize_any (line 24) | fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
type Error (line 39) | type Error = Error;
type Variant (line 40) | type Variant = Self;
method variant_seed (line 42) | fn variant_seed<V>(self, seed: V) -> Result<(V::Value, Self::Variant),...
type Error (line 52) | type Error = Error;
method unit_variant (line 54) | fn unit_variant(self) -> Result<(), Self::Error> {
method newtype_variant_seed (line 58) | fn newtype_variant_seed<T>(self, seed: T) -> Result<T::Value, Self::Er...
method tuple_variant (line 65) | fn tuple_variant<V>(self, _len: usize, visitor: V) -> Result<V::Value,...
method struct_variant (line 73) | fn struct_variant<V>(
function test_deserialize_enum (line 87) | fn test_deserialize_enum() {
FILE: test_suite/tests/test_macros.rs
type Void (line 18) | enum Void {}
type NamedUnit (line 21) | struct NamedUnit;
type SerNamedTuple (line 24) | struct SerNamedTuple<'a, 'b, A: 'a, B: 'b, C>(&'a A, &'b mut B, C);
type DeNamedTuple (line 27) | struct DeNamedTuple<A, B, C>(A, B, C);
type SerNamedMap (line 30) | struct SerNamedMap<'a, 'b, A: 'a, B: 'b, C> {
type DeNamedMap (line 37) | struct DeNamedMap<A, B, C> {
type SerEnum (line 44) | enum SerEnum<'a, B: 'a, C: 'a, D>
type DeEnum (line 59) | enum DeEnum<B, C, D> {
type Lifetimes (line 71) | enum Lifetimes<'a> {
type GenericStruct (line 79) | pub struct GenericStruct<T> {
type GenericNewTypeStruct (line 84) | pub struct GenericNewTypeStruct<T>(T);
type GenericTupleStruct (line 87) | pub struct GenericTupleStruct<T, U>(T, U);
type GenericEnum (line 90) | pub enum GenericEnum<T, U> {
type AssociatedType (line 97) | trait AssociatedType {
type X (line 102) | type X = i32;
type DefaultTyParam (line 106) | struct DefaultTyParam<T: AssociatedType<X = i32> = i32> {
function test_named_unit (line 111) | fn test_named_unit() {
function test_ser_named_tuple (line 116) | fn test_ser_named_tuple() {
function test_de_named_tuple (line 136) | fn test_de_named_tuple() {
function test_ser_named_map (line 164) | fn test_ser_named_map() {
function test_de_named_map (line 192) | fn test_de_named_map() {
function test_ser_enum_unit (line 212) | fn test_ser_enum_unit() {
function test_ser_enum_seq (line 223) | fn test_ser_enum_seq() {
function test_ser_enum_map (line 247) | fn test_ser_enum_map() {
function test_de_enum_unit (line 280) | fn test_de_enum_unit() {
function test_de_enum_seq (line 291) | fn test_de_enum_seq() {
function test_de_enum_map (line 315) | fn test_de_enum_map() {
function test_lifetimes (line 348) | fn test_lifetimes() {
function test_generic_struct (line 403) | fn test_generic_struct() {
function test_generic_newtype_struct (line 419) | fn test_generic_newtype_struct() {
function test_generic_tuple_struct (line 432) | fn test_generic_tuple_struct() {
function test_generic_enum_unit (line 448) | fn test_generic_enum_unit() {
function test_generic_enum_newtype (line 459) | fn test_generic_enum_newtype() {
function test_generic_enum_seq (line 473) | fn test_generic_enum_seq() {
function test_generic_enum_map (line 490) | fn test_generic_enum_map() {
function test_default_ty_param (line 509) | fn test_default_ty_param() {
function test_enum_state_field (line 529) | fn test_enum_state_field() {
function test_internally_tagged_struct (line 556) | fn test_internally_tagged_struct() {
function test_internally_tagged_braced_struct_with_zero_fields (line 593) | fn test_internally_tagged_braced_struct_with_zero_fields() {
function test_internally_tagged_struct_with_flattened_field (line 610) | fn test_internally_tagged_struct_with_flattened_field() {
function test_rename_all (line 655) | fn test_rename_all() {
function test_rename_all_fields (line 782) | fn test_rename_all_fields() {
function test_packed_struct_can_derive_serialize (line 838) | fn test_packed_struct_can_derive_serialize() {
FILE: test_suite/tests/test_remote.rs
type Unit (line 6) | pub struct Unit;
type PrimitivePriv (line 8) | pub struct PrimitivePriv(u8);
method new (line 35) | pub fn new(a: u8) -> Self {
method get (line 39) | pub fn get(&self) -> u8 {
type PrimitivePub (line 11) | pub struct PrimitivePub(pub u8);
type NewtypePriv (line 13) | pub struct NewtypePriv(Unit);
method new (line 45) | pub fn new(a: Unit) -> Self {
method get (line 49) | pub fn get(&self) -> &Unit {
type NewtypePub (line 16) | pub struct NewtypePub(pub Unit);
type TuplePriv (line 18) | pub struct TuplePriv(u8, Unit);
method new (line 55) | pub fn new(a: u8, b: Unit) -> Self {
method first (line 59) | pub fn first(&self) -> u8 {
method second (line 63) | pub fn second(&self) -> &Unit {
type TuplePub (line 21) | pub struct TuplePub(pub u8, pub Unit);
type StructPriv (line 23) | pub struct StructPriv {
method new (line 69) | pub fn new(a: u8, b: Unit) -> Self {
method a (line 73) | pub fn a(&self) -> u8 {
method b (line 77) | pub fn b(&self) -> &Unit {
type StructPub (line 29) | pub struct StructPub {
type StructGeneric (line 82) | pub struct StructGeneric<T> {
function get_value (line 88) | pub fn get_value(&self) -> &T {
type EnumGeneric (line 94) | pub enum EnumGeneric<T> {
type Test (line 101) | struct Test {
type UnitDef (line 142) | struct UnitDef;
type PrimitivePrivDef (line 146) | struct PrimitivePrivDef(#[serde(getter = "remote::PrimitivePriv::get")] ...
type PrimitivePubDef (line 151) | struct PrimitivePubDef(u8);
type NewtypePrivDef (line 155) | struct NewtypePrivDef(#[serde(getter = "remote::NewtypePriv::get", with ...
type NewtypePubDef (line 160) | struct NewtypePubDef(#[serde(with = "UnitDef")] remote::Unit);
type TuplePrivDef (line 164) | struct TuplePrivDef(
type TuplePubDef (line 172) | struct TuplePubDef(u8, #[serde(with = "UnitDef")] remote::Unit);
type StructPrivDef (line 176) | struct StructPrivDef {
type StructPubDef (line 188) | struct StructPubDef {
type StructGenericWithGetterDef (line 197) | struct StructGenericWithGetterDef<T> {
type StructConcrete (line 205) | struct StructConcrete {
type EnumConcrete (line 212) | enum EnumConcrete {
type ErrorKind (line 218) | enum ErrorKind {
type ErrorKindDef (line 229) | enum ErrorKindDef {
function from (line 236) | fn from(def: PrimitivePrivDef) -> Self {
function from (line 242) | fn from(def: NewtypePrivDef) -> Self {
function from (line 248) | fn from(def: TuplePrivDef) -> Self {
function from (line 254) | fn from(def: StructPrivDef) -> Self {
function from (line 260) | fn from(def: StructGenericWithGetterDef<T>) -> Self {
FILE: test_suite/tests/test_roundtrip.rs
function ip_addr_roundtrip (line 9) | fn ip_addr_roundtrip() {
function socket_addr_roundtrip (line 25) | fn socket_addr_roundtrip() {
FILE: test_suite/tests/test_self.rs
function test_self (line 6) | fn test_self() {
FILE: test_suite/tests/test_ser.rs
type UnitStruct (line 31) | struct UnitStruct;
type TupleStruct (line 34) | struct TupleStruct(i32, i32, i32);
type Struct (line 37) | struct Struct {
type NotSerializable (line 44) | struct NotSerializable;
type Enum (line 47) | enum Enum {
function test_unit (line 72) | fn test_unit() {
function test_bool (line 77) | fn test_bool() {
function test_isizes (line 83) | fn test_isizes() {
function test_usizes (line 91) | fn test_usizes() {
function test_floats (line 99) | fn test_floats() {
function test_char (line 105) | fn test_char() {
function test_str (line 110) | fn test_str() {
function test_option (line 116) | fn test_option() {
function test_result (line 122) | fn test_result() {
function test_slice (line 146) | fn test_slice() {
function test_array (line 161) | fn test_array() {
function test_vec (line 176) | fn test_vec() {
function test_btreeset (line 200) | fn test_btreeset() {
function test_hashset (line 212) | fn test_hashset() {
function test_tuple (line 228) | fn test_tuple() {
function test_btreemap (line 246) | fn test_btreemap() {
function test_hashmap (line 287) | fn test_hashmap() {
function test_unit_struct (line 313) | fn test_unit_struct() {
function test_tuple_struct (line 318) | fn test_tuple_struct() {
function test_struct (line 335) | fn test_struct() {
function test_enum (line 355) | fn test_enum() {
function test_box (line 411) | fn test_box() {
function test_boxed_slice (line 416) | fn test_boxed_slice() {
function test_duration (line 430) | fn test_duration() {
function test_system_time (line 448) | fn test_system_time() {
function test_range (line 467) | fn test_range() {
function test_range_inclusive (line 485) | fn test_range_inclusive() {
function test_range_from (line 503) | fn test_range_from() {
function test_range_to (line 519) | fn test_range_to() {
function test_bound (line 535) | fn test_bound() {
function test_path (line 563) | fn test_path() {
function test_path_buf (line 571) | fn test_path_buf() {
function test_cstring (line 579) | fn test_cstring() {
function test_cstr (line 584) | fn test_cstr() {
function test_rc (line 590) | fn test_rc() {
function test_rc_weak_some (line 595) | fn test_rc_weak_some() {
function test_rc_weak_none (line 601) | fn test_rc_weak_none() {
function test_arc (line 606) | fn test_arc() {
function test_arc_weak_some (line 611) | fn test_arc_weak_some() {
function test_arc_weak_none (line 617) | fn test_arc_weak_none() {
function test_wrapping (line 622) | fn test_wrapping() {
function test_saturating (line 627) | fn test_saturating() {
function test_rc_dst (line 632) | fn test_rc_dst() {
function test_arc_dst (line 645) | fn test_arc_dst() {
function test_fmt_arguments (line 658) | fn test_fmt_arguments() {
function test_atomic (line 663) | fn test_atomic() {
function test_atomic64 (line 678) | fn test_atomic64() {
function test_net_ipv4addr_readable (line 690) | fn test_net_ipv4addr_readable() {
function test_net_ipv6addr_readable (line 698) | fn test_net_ipv6addr_readable() {
function test_net_ipaddr_readable (line 706) | fn test_net_ipaddr_readable() {
function test_net_socketaddr_readable (line 714) | fn test_net_socketaddr_readable() {
function test_net_ipv4addr_compact (line 739) | fn test_net_ipv4addr_compact() {
function test_net_ipv6addr_compact (line 751) | fn test_net_ipv6addr_compact() {
function test_net_ipaddr_compact (line 763) | fn test_net_ipaddr_compact() {
function test_net_socketaddr_compact (line 779) | fn test_net_socketaddr_compact() {
function test_never_result (line 821) | fn test_never_result() {
function test_cannot_serialize_paths (line 836) | fn test_cannot_serialize_paths() {
function test_cannot_serialize_mutably_borrowed_ref_cell (line 848) | fn test_cannot_serialize_mutably_borrowed_ref_cell() {
function test_enum_skipped (line 855) | fn test_enum_skipped() {
function test_integer128 (line 879) | fn test_integer128() {
function test_refcell_dst (line 886) | fn test_refcell_dst() {
function test_mutex_dst (line 898) | fn test_mutex_dst() {
function test_rwlock_dst (line 910) | fn test_rwlock_dst() {
FILE: test_suite/tests/test_serde_path.rs
function test_gen_custom_serde (line 9) | fn test_gen_custom_serde() {
function assert (line 25) | pub fn assert<T>()
type Serialize (line 33) | pub trait Serialize {
method serialize (line 34) | fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::...
type Deserialize (line 38) | pub trait Deserialize<'a>: Sized {
method deserialize (line 39) | fn deserialize<D: Deserializer<'a>>(deserializer: D) -> Result<Self, D...
type AssertNotSerdeSerialize (line 43) | pub trait AssertNotSerdeSerialize {}
type AssertNotSerdeDeserialize (line 47) | pub trait AssertNotSerdeDeserialize<'a> {}
FILE: test_suite/tests/test_value.rs
function test_u32_to_enum (line 10) | fn test_u32_to_enum() {
function test_integer128 (line 23) | fn test_integer128() {
function test_map_access_to_enum (line 41) | fn test_map_access_to_enum() {
FILE: test_suite/tests/ui/borrow/bad_lifetimes.rs
type Test (line 4) | struct Test<'a> {
function main (line 9) | fn main() {}
FILE: test_suite/tests/ui/borrow/duplicate_lifetime.rs
type Test (line 4) | struct Test<'a> {
function main (line 9) | fn main() {}
FILE: test_suite/tests/ui/borrow/duplicate_variant.rs
type Str (line 4) | struct Str<'a>(&'a str);
type Test (line 7) | enum Test<'a> {
function main (line 12) | fn main() {}
FILE: test_suite/tests/ui/borrow/empty_lifetimes.rs
type Test (line 4) | struct Test<'a> {
function main (line 11) | fn main() {}
FILE: test_suite/tests/ui/borrow/no_lifetimes.rs
type Test (line 4) | struct Test {
function main (line 9) | fn main() {}
FILE: test_suite/tests/ui/borrow/struct_variant.rs
type Str (line 4) | struct Str<'a>(&'a str);
type Test (line 7) | enum Test<'a> {
function main (line 12) | fn main() {}
FILE: test_suite/tests/ui/borrow/wrong_lifetime.rs
type Test (line 4) | struct Test<'a> {
function main (line 9) | fn main() {}
FILE: test_suite/tests/ui/conflict/adjacent-tag.rs
type E (line 5) | enum E {
function main (line 10) | fn main() {}
FILE: test_suite/tests/ui/conflict/alias-enum.rs
type E (line 6) | enum E {
type E1 (line 40) | enum E1 {
type E2 (line 53) | enum E2 {
type E3 (line 64) | enum E3 {
function main (line 73) | fn main() {
FILE: test_suite/tests/ui/conflict/alias.rs
type S1 (line 4) | struct S1 {
type S2 (line 17) | struct S2 {
type S3 (line 28) | struct S3 {
function main (line 37) | fn main() {
FILE: test_suite/tests/ui/conflict/flatten-newtype-struct.rs
type Foo (line 5) | struct Foo(#[serde(flatten)] HashMap<String, String>);
function main (line 7) | fn main() {}
FILE: test_suite/tests/ui/conflict/flatten-tuple-struct.rs
type Foo (line 5) | struct Foo(u32, #[serde(flatten)] HashMap<String, String>);
function main (line 7) | fn main() {}
FILE: test_suite/tests/ui/conflict/from-try-from.rs
type S (line 5) | struct S {
function main (line 9) | fn main() {}
FILE: test_suite/tests/ui/conflict/internal-tag-alias.rs
type E (line 5) | enum E {
function main (line 12) | fn main() {}
FILE: test_suite/tests/ui/conflict/internal-tag.rs
type E (line 5) | enum E {
function main (line 12) | fn main() {}
FILE: test_suite/tests/ui/default-attribute/enum.rs
type E (line 5) | enum E {
function main (line 9) | fn main() {}
FILE: test_suite/tests/ui/default-attribute/enum_path.rs
type E (line 5) | enum E {
function main (line 9) | fn main() {}
FILE: test_suite/tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.rs
type Enum (line 7) | enum Enum {
function main (line 20) | fn main() {}
FILE: test_suite/tests/ui/default-attribute/incorrect_type_enum_externally_tagged.rs
type Enum (line 6) | enum Enum {
function main (line 19) | fn main() {}
FILE: test_suite/tests/ui/default-attribute/incorrect_type_enum_internally_tagged.rs
type Enum (line 7) | enum Enum {
function main (line 20) | fn main() {}
FILE: test_suite/tests/ui/default-attribute/incorrect_type_enum_untagged.rs
type Enum (line 7) | enum Enum {
function main (line 20) | fn main() {}
FILE: test_suite/tests/ui/default-attribute/incorrect_type_newtype.rs
type Newtype (line 7) | struct Newtype(#[serde(default = "main")] u8);
function main (line 9) | fn main() {}
FILE: test_suite/tests/ui/default-attribute/incorrect_type_struct.rs
type Struct (line 7) | struct Struct {
function main (line 15) | fn main() {}
FILE: test_suite/tests/ui/default-attribute/incorrect_type_tuple.rs
type Tuple (line 7) | struct Tuple(u8, #[serde(default = "main")] i8);
function main (line 9) | fn main() {}
FILE: test_suite/tests/ui/default-attribute/tuple_struct.rs
type T0 (line 5) | struct T0(u8, u8);
type T1 (line 11) | struct T1(u8, #[serde(default)] u8);
type T2 (line 16) | struct T2(#[serde(default)] u8, u8, u8);
type T3 (line 23) | struct T3(#[serde(default)] u8, #[serde(default)] u8);
type T4 (line 30) | struct T4(u8, u8);
type T5 (line 35) | struct T5(#[serde(default)] u8, u8);
type T6 (line 40) | struct T6(u8, #[serde(default)] u8);
type T7 (line 45) | struct T7(#[serde(default)] u8, #[serde(default)] u8);
function main (line 47) | fn main() {}
FILE: test_suite/tests/ui/default-attribute/tuple_struct_path.rs
function d (line 3) | fn d<T>() -> T {
type T1 (line 11) | struct T1(u8, #[serde(default = "d")] u8);
type T2 (line 16) | struct T2(#[serde(default = "d")] u8, u8, u8);
type T3 (line 23) | struct T3(#[serde(default = "d")] u8, #[serde(default = "d")] u8);
type T1D (line 30) | struct T1D(#[serde(default = "d")] u8, u8);
type T2D (line 35) | struct T2D(u8, #[serde(default = "d")] u8);
type T3D (line 40) | struct T3D(#[serde(default = "d")] u8, #[serde(default = "d")] u8);
type T1Path (line 47) | struct T1Path(#[serde(default)] u8, u8);
type T2Path (line 52) | struct T2Path(u8, #[serde(default)] u8);
type T3Path (line 57) | struct T3Path(#[serde(default)] u8, #[serde(default)] u8);
type T1PathD (line 64) | struct T1PathD(#[serde(default = "d")] u8, u8);
type T2PathD (line 69) | struct T2PathD(u8, #[serde(default = "d")] u8);
type T3PathD (line 74) | struct T3PathD(#[serde(default = "d")] u8, #[serde(default = "d")] u8);
function main (line 76) | fn main() {}
FILE: test_suite/tests/ui/default-attribute/union.rs
function main (line 9) | fn main() {}
FILE: test_suite/tests/ui/default-attribute/union_path.rs
function main (line 9) | fn main() {}
FILE: test_suite/tests/ui/default-attribute/unit.rs
type Unit (line 5) | struct Unit;
function main (line 7) | fn main() {}
FILE: test_suite/tests/ui/default-attribute/unit_path.rs
type Unit (line 5) | struct Unit;
function main (line 7) | fn main() {}
FILE: test_suite/tests/ui/deprecated/deprecated_de_with.rs
type Struct (line 7) | pub struct Struct {
function deprecated_with (line 13) | fn deprecated_with<'de, D>(_deserializer: D) -> Result<i32, D::Error>
function main (line 20) | fn main() {}
FILE: test_suite/tests/ui/deprecated/deprecated_ser_with.rs
type Struct (line 7) | pub struct Struct {
function deprecated_with (line 13) | fn deprecated_with<S>(_field: &i32, _serializer: S) -> Result<S::Ok, S::...
function main (line 20) | fn main() {}
FILE: test_suite/tests/ui/duplicate-attribute/rename-and-ser.rs
type S (line 4) | struct S {
function main (line 9) | fn main() {}
FILE: test_suite/tests/ui/duplicate-attribute/rename-ser-rename-ser.rs
type S (line 4) | struct S {
function main (line 9) | fn main() {}
FILE: test_suite/tests/ui/duplicate-attribute/rename-ser-rename.rs
type S (line 4) | struct S {
function main (line 10) | fn main() {}
FILE: test_suite/tests/ui/duplicate-attribute/rename-ser-ser.rs
type S (line 4) | struct S {
function main (line 9) | fn main() {}
FILE: test_suite/tests/ui/duplicate-attribute/two-rename-ser.rs
type S (line 4) | struct S {
function main (line 10) | fn main() {}
FILE: test_suite/tests/ui/duplicate-attribute/with-and-serialize-with.rs
type S (line 4) | struct S {
function main (line 9) | fn main() {}
FILE: test_suite/tests/ui/enum-representation/content-no-tag.rs
type E (line 5) | enum E {
function main (line 10) | fn main() {}
FILE: test_suite/tests/ui/enum-representation/internal-tuple-variant.rs
type E (line 5) | enum E {
function main (line 9) | fn main() {}
FILE: test_suite/tests/ui/enum-representation/partially_tagged_wrong_order.rs
type E (line 4) | enum E {
function main (line 10) | fn main() {}
FILE: test_suite/tests/ui/enum-representation/untagged-and-adjacent.rs
type E (line 6) | enum E {
function main (line 11) | fn main() {}
FILE: test_suite/tests/ui/enum-representation/untagged-and-content.rs
type E (line 6) | enum E {
function main (line 11) | fn main() {}
FILE: test_suite/tests/ui/enum-representation/untagged-and-internal.rs
type E (line 6) | enum E {
function main (line 11) | fn main() {}
FILE: test_suite/tests/ui/enum-representation/untagged-struct.rs
type S (line 5) | struct S;
function main (line 7) | fn main() {}
FILE: test_suite/tests/ui/expected-string/boolean.rs
type S (line 4) | struct S {
function main (line 9) | fn main() {}
FILE: test_suite/tests/ui/expected-string/byte_character.rs
type S (line 4) | struct S {
function main (line 9) | fn main() {}
FILE: test_suite/tests/ui/expected-string/byte_string.rs
type S (line 4) | struct S {
function main (line 9) | fn main() {}
FILE: test_suite/tests/ui/expected-string/character.rs
type S (line 4) | struct S {
function main (line 9) | fn main() {}
FILE: test_suite/tests/ui/expected-string/float.rs
type S (line 4) | struct S {
function main (line 9) | fn main() {}
FILE: test_suite/tests/ui/expected-string/integer.rs
type S (line 4) | struct S {
function main (line 9) | fn main() {}
FILE: test_suite/tests/ui/identifier/both.rs
type F (line 5) | enum F {
function main (line 10) | fn main() {}
FILE: test_suite/tests/ui/identifier/field_struct.rs
type S (line 5) | struct S;
function main (line 7) | fn main() {}
FILE: test_suite/tests/ui/identifier/field_tuple.rs
type F (line 5) | enum F {
function main (line 10) | fn main() {}
FILE: test_suite/tests/ui/identifier/newtype_not_last.rs
type F (line 5) | enum F {
function main (line 11) | fn main() {}
FILE: test_suite/tests/ui/identifier/not_unit.rs
type F (line 5) | enum F {
function main (line 11) | fn main() {}
FILE: test_suite/tests/ui/identifier/other_not_last.rs
type F
Condensed preview — 347 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,412K chars).
[
{
"path": ".github/FUNDING.yml",
"chars": 16,
"preview": "github: dtolnay\n"
},
{
"path": ".github/ISSUE_TEMPLATE/1-problem.md",
"chars": 62,
"preview": "---\nname: Problem\nabout: Something does not seem right\n\n---\n\n\n"
},
{
"path": ".github/ISSUE_TEMPLATE/2-suggestion.md",
"chars": 86,
"preview": "---\nname: Suggestion\nabout: Share how Serde could support your use case better\n\n---\n\n\n"
},
{
"path": ".github/ISSUE_TEMPLATE/3-documentation.md",
"chars": 78,
"preview": "---\nname: Documentation\nabout: Certainly there is room for improvement\n\n---\n\n\n"
},
{
"path": ".github/ISSUE_TEMPLATE/4-other.md",
"chars": 64,
"preview": "---\nname: Anything else!\nabout: Whatever is on your mind\n\n---\n\n\n"
},
{
"path": ".github/workflows/ci.yml",
"chars": 5710,
"preview": "name: CI\n\non:\n push:\n pull_request:\n workflow_dispatch:\n schedule: [cron: \"40 1 * * *\"]\n\npermissions:\n contents: re"
},
{
"path": ".gitignore",
"chars": 21,
"preview": "/target/\n/Cargo.lock\n"
},
{
"path": "CONTRIBUTING.md",
"chars": 2024,
"preview": "# Contributing to Serde\n\nSerde welcomes contribution from everyone in the form of suggestions, bug\nreports, pull request"
},
{
"path": "Cargo.toml",
"chars": 465,
"preview": "[workspace]\nmembers = [\n \"serde\",\n \"serde_core\",\n \"serde_derive\",\n \"serde_derive_internals\",\n \"test_suite"
},
{
"path": "LICENSE-APACHE",
"chars": 9723,
"preview": " Apache License\n Version 2.0, January 2004\n http"
},
{
"path": "LICENSE-MIT",
"chars": 1023,
"preview": "Permission is hereby granted, free of charge, to any\nperson obtaining a copy of this software and associated\ndocumentati"
},
{
"path": "README.md",
"chars": 4358,
"preview": "# Serde   [![Build Status]][actions] [![Latest Version]][crates.io] [![serde msrv]][Rust 1.56] [![serde_derive msrv"
},
{
"path": "crates-io.md",
"chars": 2538,
"preview": "<!-- Serde readme rendered on crates.io -->\n\n**Serde is a framework for *ser*ializing and *de*serializing Rust data stru"
},
{
"path": "serde/Cargo.toml",
"chars": 2252,
"preview": "[package]\nname = \"serde\"\nversion = \"1.0.228\"\nauthors = [\"Erick Tryzelaar <erick.tryzelaar@gmail.com>\", \"David Tolnay <dt"
},
{
"path": "serde/build.rs",
"chars": 2471,
"preview": "use std::env;\nuse std::fs;\nuse std::path::PathBuf;\nuse std::process::Command;\nuse std::str;\n\nconst PRIVATE: &str = \"\\\n#["
},
{
"path": "serde/src/integer128.rs",
"chars": 480,
"preview": "#[macro_export]\n#[deprecated = \"\nThis macro has no effect on any version of Serde released in the past 2 years.\nIt was u"
},
{
"path": "serde/src/lib.rs",
"chars": 11673,
"preview": "//! # Serde\n//!\n//! Serde is a framework for ***ser***ializing and ***de***serializing Rust data\n//! structures efficien"
},
{
"path": "serde/src/private/de.rs",
"chars": 110746,
"preview": "use crate::lib::*;\n\nuse crate::de::value::{BorrowedBytesDeserializer, BytesDeserializer};\nuse crate::de::{\n Deseriali"
},
{
"path": "serde/src/private/mod.rs",
"chars": 574,
"preview": "#[cfg(not(no_serde_derive))]\npub mod de;\n#[cfg(not(no_serde_derive))]\npub mod ser;\n\npub use crate::lib::clone::Clone;\npu"
},
{
"path": "serde/src/private/ser.rs",
"chars": 41496,
"preview": "use crate::lib::*;\n\nuse crate::ser::{self, Impossible, Serialize, SerializeMap, SerializeStruct, Serializer};\n\n#[cfg(any"
},
{
"path": "serde_core/Cargo.toml",
"chars": 2663,
"preview": "[package]\nname = \"serde_core\"\nversion = \"1.0.228\"\nauthors = [\"Erick Tryzelaar <erick.tryzelaar@gmail.com>\", \"David Tolna"
},
{
"path": "serde_core/README.md",
"chars": 1051,
"preview": "The `serde_core` crate contains Serde's trait definitions with **no support for\n#\\[derive()\\]**.\n\nIn crates that derive "
},
{
"path": "serde_core/build.rs",
"chars": 4252,
"preview": "use std::env;\nuse std::fs;\nuse std::path::PathBuf;\nuse std::process::Command;\nuse std::str;\n\nconst PRIVATE: &str = \"\\\n#["
},
{
"path": "serde_core/src/crate_root.rs",
"chars": 7081,
"preview": "macro_rules! crate_root {\n () => {\n /// A facade around all the types we need from the `std`, `core`, and `all"
},
{
"path": "serde_core/src/de/ignored_any.rs",
"chars": 6154,
"preview": "use crate::lib::*;\n\nuse crate::de::{\n Deserialize, Deserializer, EnumAccess, Error, MapAccess, SeqAccess, VariantAcce"
},
{
"path": "serde_core/src/de/impls.rs",
"chars": 97135,
"preview": "use crate::lib::*;\n\nuse crate::de::{\n Deserialize, Deserializer, EnumAccess, Error, MapAccess, SeqAccess, Unexpected,"
},
{
"path": "serde_core/src/de/mod.rs",
"chars": 83879,
"preview": "//! Generic data structure deserialization framework.\n//!\n//! The two most important traits in this module are [`Deseria"
},
{
"path": "serde_core/src/de/value.rs",
"chars": 48848,
"preview": "//! Building blocks for deserializing basic values using the `IntoDeserializer`\n//! trait.\n//!\n//! ```edition2021\n//! us"
},
{
"path": "serde_core/src/format.rs",
"chars": 726,
"preview": "use crate::lib::fmt::{self, Write};\nuse crate::lib::str;\n\npub(super) struct Buf<'a> {\n bytes: &'a mut [u8],\n offse"
},
{
"path": "serde_core/src/lib.rs",
"chars": 4351,
"preview": "//! Serde is a framework for ***ser***ializing and ***de***serializing Rust data\n//! structures efficiently and generica"
},
{
"path": "serde_core/src/macros.rs",
"chars": 8276,
"preview": "// Super explicit first paragraph because this shows up at the top level and\n// trips up people who are just looking for"
},
{
"path": "serde_core/src/private/content.rs",
"chars": 750,
"preview": "use crate::lib::*;\n\n// Used from generated code to buffer the contents of the Deserializer when\n// deserializing untagge"
},
{
"path": "serde_core/src/private/doc.rs",
"chars": 5146,
"preview": "// Used only by Serde doc tests. Not public API.\n\nuse crate::lib::*;\n\nuse crate::ser;\n\n#[doc(hidden)]\n#[derive(Debug)]\np"
},
{
"path": "serde_core/src/private/mod.rs",
"chars": 504,
"preview": "#[cfg(all(not(no_serde_derive), any(feature = \"std\", feature = \"alloc\")))]\nmod content;\nmod seed;\n\n// FIXME: #[cfg(docte"
},
{
"path": "serde_core/src/private/seed.rs",
"chars": 635,
"preview": "use crate::de::{Deserialize, DeserializeSeed, Deserializer};\n\n/// A DeserializeSeed helper for implementing deserialize_"
},
{
"path": "serde_core/src/private/size_hint.rs",
"chars": 692,
"preview": "#[cfg(any(feature = \"std\", feature = \"alloc\"))]\nuse crate::lib::*;\n\npub fn from_bounds<I>(iter: &I) -> Option<usize>\nwhe"
},
{
"path": "serde_core/src/private/string.rs",
"chars": 794,
"preview": "use crate::lib::*;\n\n#[cfg(any(feature = \"std\", feature = \"alloc\"))]\n#[doc(hidden)]\npub fn from_utf8_lossy(bytes: &[u8]) "
},
{
"path": "serde_core/src/ser/fmt.rs",
"chars": 4166,
"preview": "use crate::lib::*;\nuse crate::ser::{Error, Impossible, Serialize, Serializer};\n\nimpl Error for fmt::Error {\n fn custo"
},
{
"path": "serde_core/src/ser/impls.rs",
"chars": 29535,
"preview": "use crate::lib::*;\n\nuse crate::ser::{Error, Serialize, SerializeTuple, Serializer};\n\n///////////////////////////////////"
},
{
"path": "serde_core/src/ser/impossible.rs",
"chars": 5308,
"preview": "//! This module contains `Impossible` serializer and its implementations.\n\nuse crate::lib::*;\n\nuse crate::ser::{\n sel"
},
{
"path": "serde_core/src/ser/mod.rs",
"chars": 65231,
"preview": "//! Generic data structure serialization framework.\n//!\n//! The two most important traits in this module are [`Serialize"
},
{
"path": "serde_core/src/std_error.rs",
"chars": 1351,
"preview": "use crate::lib::{Debug, Display};\n\n/// Either a re-export of std::error::Error or a new identical trait, depending\n/// o"
},
{
"path": "serde_derive/Cargo.toml",
"chars": 1375,
"preview": "[package]\nname = \"serde_derive\"\nversion = \"1.0.228\"\nauthors = [\"Erick Tryzelaar <erick.tryzelaar@gmail.com>\", \"David Tol"
},
{
"path": "serde_derive/build.rs",
"chars": 272,
"preview": "fn main() {\n // Warning: build.rs is not published to crates.io.\n\n println!(\"cargo:rerun-if-changed=build.rs\");\n "
},
{
"path": "serde_derive/src/bound.rs",
"chars": 15156,
"preview": "use crate::internals::ast::{Container, Data};\nuse crate::internals::{attr, ungroup};\nuse proc_macro2::Span;\nuse std::col"
},
{
"path": "serde_derive/src/de/enum_.rs",
"chars": 3490,
"preview": "use crate::de::enum_adjacently;\nuse crate::de::enum_externally;\nuse crate::de::enum_internally;\nuse crate::de::enum_unta"
},
{
"path": "serde_derive/src/de/enum_adjacently.rs",
"chars": 13795,
"preview": "//! Deserialization for adjacently tagged enums:\n//!\n//! ```ignore\n//! #[serde(tag = \"...\", content = \"...\")]\n//! enum E"
},
{
"path": "serde_derive/src/de/enum_externally.rs",
"chars": 7158,
"preview": "//! Deserialization for externally tagged enums:\n//!\n//! ```ignore\n//! enum Enum {}\n//! ```\n\nuse crate::de::enum_;\nuse c"
},
{
"path": "serde_derive/src/de/enum_internally.rs",
"chars": 3511,
"preview": "//! Deserialization for internally tagged enums:\n//!\n//! ```ignore\n//! #[serde(tag = \"...\")]\n//! enum Enum {}\n//! ```\n\nu"
},
{
"path": "serde_derive/src/de/enum_untagged.rs",
"chars": 4858,
"preview": "//! Deserialization for untagged enums:\n//!\n//! ```ignore\n//! #[serde(untagged)]\n//! enum Enum {}\n//! ```\n\nuse crate::de"
},
{
"path": "serde_derive/src/de/identifier.rs",
"chars": 15852,
"preview": "//! Deserialization of struct field identifiers and enum variant identifiers by\n//! way of a Rust enum.\n\nuse crate::de::"
},
{
"path": "serde_derive/src/de/struct_.rs",
"chars": 24472,
"preview": "use crate::de::identifier;\nuse crate::de::{\n deserialize_seq, expr_is_missing, field_i, has_flatten, wrap_deserialize"
},
{
"path": "serde_derive/src/de/tuple.rs",
"chars": 9435,
"preview": "use crate::de::{deserialize_seq, has_flatten, Parameters, TupleForm};\n#[cfg(feature = \"deserialize_in_place\")]\nuse crate"
},
{
"path": "serde_derive/src/de/unit.rs",
"chars": 1916,
"preview": "use crate::de::Parameters;\nuse crate::fragment::Fragment;\nuse crate::internals::attr;\nuse crate::private;\nuse quote::quo"
},
{
"path": "serde_derive/src/de.rs",
"chars": 34045,
"preview": "use crate::deprecated::allow_deprecated;\nuse crate::fragment::{Expr, Fragment, Stmts};\nuse crate::internals::ast::{Conta"
},
{
"path": "serde_derive/src/deprecated.rs",
"chars": 1633,
"preview": "use proc_macro2::TokenStream;\nuse quote::quote;\n\npub fn allow_deprecated(input: &syn::DeriveInput) -> Option<TokenStream"
},
{
"path": "serde_derive/src/dummy.rs",
"chars": 751,
"preview": "use proc_macro2::TokenStream;\nuse quote::quote;\n\npub fn wrap_in_const(serde_path: Option<&syn::Path>, code: TokenStream)"
},
{
"path": "serde_derive/src/fragment.rs",
"chars": 2116,
"preview": "use proc_macro2::TokenStream;\nuse quote::ToTokens;\nuse syn::{token, Token};\n\npub enum Fragment {\n /// Tokens that can"
},
{
"path": "serde_derive/src/internals/ast.rs",
"chars": 6732,
"preview": "//! A Serde ast, parsed from the Syn ast and ready to generate Rust code.\n\nuse crate::internals::{attr, check, Ctxt, Der"
},
{
"path": "serde_derive/src/internals/attr.rs",
"chars": 67346,
"preview": "use crate::internals::name::{MultiName, Name};\nuse crate::internals::symbol::*;\nuse crate::internals::{ungroup, Ctxt};\nu"
},
{
"path": "serde_derive/src/internals/case.rs",
"chars": 7121,
"preview": "//! Code to convert the Rust-styled field/variant (e.g. `my_field`, `MyType`) to the\n//! case of the source (e.g. `my-fi"
},
{
"path": "serde_derive/src/internals/check.rs",
"chars": 16740,
"preview": "use crate::internals::ast::{Container, Data, Field, Style};\nuse crate::internals::attr::{Default, Identifier, TagType};\n"
},
{
"path": "serde_derive/src/internals/ctxt.rs",
"chars": 1982,
"preview": "use quote::ToTokens;\nuse std::cell::RefCell;\nuse std::fmt::Display;\nuse std::thread;\n\n/// A type to collect errors toget"
},
{
"path": "serde_derive/src/internals/mod.rs",
"chars": 395,
"preview": "pub mod ast;\npub mod attr;\npub mod name;\n\nmod case;\nmod check;\nmod ctxt;\nmod receiver;\nmod respan;\nmod symbol;\n\nuse syn:"
},
{
"path": "serde_derive/src/internals/name.rs",
"chars": 2806,
"preview": "use crate::internals::attr::{Attr, VecAttr};\nuse proc_macro2::{Ident, Span, TokenStream};\nuse quote::ToTokens;\nuse std::"
},
{
"path": "serde_derive/src/internals/receiver.rs",
"chars": 10533,
"preview": "use crate::internals::respan::respan;\nuse proc_macro2::Span;\nuse quote::ToTokens;\nuse std::mem;\nuse syn::{\n parse_quo"
},
{
"path": "serde_derive/src/internals/respan.rs",
"chars": 451,
"preview": "use proc_macro2::{Group, Span, TokenStream, TokenTree};\n\npub(crate) fn respan(stream: TokenStream, span: Span) -> TokenS"
},
{
"path": "serde_derive/src/internals/symbol.rs",
"chars": 2509,
"preview": "use std::fmt::{self, Display};\nuse syn::{Ident, Path};\n\n#[derive(Copy, Clone)]\npub struct Symbol(&'static str);\n\npub con"
},
{
"path": "serde_derive/src/lib.rs",
"chars": 3642,
"preview": "//! This crate provides Serde's two derive macros.\n//!\n//! ```edition2021\n//! # use serde_derive::{Deserialize, Serializ"
},
{
"path": "serde_derive/src/pretend.rs",
"chars": 5852,
"preview": "use crate::internals::ast::{Container, Data, Field, Style, Variant};\nuse crate::private;\nuse proc_macro2::TokenStream;\nu"
},
{
"path": "serde_derive/src/ser.rs",
"chars": 45068,
"preview": "use crate::de::field_i;\nuse crate::deprecated::allow_deprecated;\nuse crate::fragment::{Fragment, Match, Stmts};\nuse crat"
},
{
"path": "serde_derive/src/this.rs",
"chars": 1007,
"preview": "use crate::internals::ast::Container;\nuse syn::{Path, PathArguments, Token};\n\npub fn this_type(cont: &Container) -> Path"
},
{
"path": "serde_derive_internals/Cargo.toml",
"chars": 1093,
"preview": "[package]\nname = \"serde_derive_internals\"\nversion = \"0.29.1\"\nauthors = [\"Erick Tryzelaar <erick.tryzelaar@gmail.com>\", \""
},
{
"path": "serde_derive_internals/build.rs",
"chars": 902,
"preview": "use std::path::Path;\n\nfn main() {\n // Warning: build.rs is not published to crates.io.\n\n println!(\"cargo:rerun-if-"
},
{
"path": "serde_derive_internals/lib.rs",
"chars": 1819,
"preview": "#![doc(html_root_url = \"https://docs.rs/serde_derive_internals/0.29.1\")]\n#![cfg_attr(not(check_cfg), allow(unexpected_cf"
},
{
"path": "test_suite/Cargo.toml",
"chars": 553,
"preview": "[package]\nname = \"serde_test_suite\"\nversion = \"0.0.0\"\nauthors = [\"Erick Tryzelaar <erick.tryzelaar@gmail.com>\", \"David T"
},
{
"path": "test_suite/no_std/.gitignore",
"chars": 21,
"preview": "/target/\n/Cargo.lock\n"
},
{
"path": "test_suite/no_std/Cargo.toml",
"chars": 397,
"preview": "[package]\nname = \"serde_derive_tests_no_std\"\nversion = \"0.0.0\"\nauthors = [\"David Tolnay <dtolnay@gmail.com>\"]\nedition = "
},
{
"path": "test_suite/no_std/src/main.rs",
"chars": 733,
"preview": "#![no_std]\n#![no_main]\n\nuse core::ffi::c_int;\n\n#[no_mangle]\nextern \"C\" fn main(_argc: c_int, _argv: *const *const u8) ->"
},
{
"path": "test_suite/tests/bytes/mod.rs",
"chars": 1258,
"preview": "use serde::de::{Deserializer, Error, SeqAccess, Visitor};\nuse std::fmt;\n\npub fn deserialize<'de, D>(deserializer: D) -> "
},
{
"path": "test_suite/tests/compiletest.rs",
"chars": 318,
"preview": "#[cfg_attr(target_os = \"emscripten\", ignore = \"disabled on Emscripten\")]\n#[rustversion::attr(not(nightly), ignore = \"req"
},
{
"path": "test_suite/tests/macros/mod.rs",
"chars": 1628,
"preview": "#![allow(unused_macro_rules)]\n\nuse serde_test::Token;\nuse std::iter;\n\nmacro_rules! btreeset {\n () => {\n BTreeS"
},
{
"path": "test_suite/tests/regression/issue1904.rs",
"chars": 1211,
"preview": "#![allow(dead_code)] // we do not read enum fields\n\nuse serde_derive::Deserialize;\n\n#[derive(Deserialize)]\npub struct Ne"
},
{
"path": "test_suite/tests/regression/issue2371.rs",
"chars": 1026,
"preview": "#![allow(dead_code)]\n\nuse serde_derive::Deserialize;\n\n#[derive(Deserialize)]\npub struct Nested;\n\n#[derive(Deserialize)]\n"
},
{
"path": "test_suite/tests/regression/issue2409.rs",
"chars": 225,
"preview": "#![allow(dead_code)]\n\nuse serde_derive::Deserialize;\n\nmacro_rules! bug {\n ($serde_path:literal) => {\n #[derive"
},
{
"path": "test_suite/tests/regression/issue2415.rs",
"chars": 96,
"preview": "use serde_derive::Serialize;\n\n#[derive(Serialize)]\n#[serde()]\n#[allow(dead_code)]\npub struct S;\n"
},
{
"path": "test_suite/tests/regression/issue2565.rs",
"chars": 986,
"preview": "use serde_derive::{Deserialize, Serialize};\nuse serde_test::{assert_tokens, Token};\n\n#[derive(Serialize, Deserialize, De"
},
{
"path": "test_suite/tests/regression/issue2792.rs",
"chars": 281,
"preview": "#![allow(dead_code)] // we do not read enum fields\n\nuse serde_derive::Deserialize;\n\n#[derive(Deserialize)]\n#[serde(deny_"
},
{
"path": "test_suite/tests/regression/issue2844.rs",
"chars": 661,
"preview": "#![allow(clippy::trivially_copy_pass_by_ref, dead_code)]\n\nuse serde_derive::{Deserialize, Serialize};\n\nmacro_rules! decl"
},
{
"path": "test_suite/tests/regression/issue2846.rs",
"chars": 515,
"preview": "#![allow(clippy::trivially_copy_pass_by_ref, dead_code)]\n\nuse serde_derive::Deserialize;\n\nmacro_rules! declare_in_macro "
},
{
"path": "test_suite/tests/regression.rs",
"chars": 58,
"preview": "mod regression {\n automod::dir!(\"tests/regression\");\n}\n"
},
{
"path": "test_suite/tests/test_annotations.rs",
"chars": 97197,
"preview": "#![allow(\n clippy::cast_lossless,\n clippy::derive_partial_eq_without_eq,\n clippy::from_over_into,\n // Clippy"
},
{
"path": "test_suite/tests/test_borrow.rs",
"chars": 4825,
"preview": "#![allow(\n clippy::derive_partial_eq_without_eq,\n clippy::items_after_statements,\n clippy::used_underscore_bind"
},
{
"path": "test_suite/tests/test_de.rs",
"chars": 57353,
"preview": "#![allow(\n clippy::cast_lossless,\n clippy::decimal_literal_representation,\n clippy::derive_partial_eq_without_e"
},
{
"path": "test_suite/tests/test_de_error.rs",
"chars": 37622,
"preview": "#![allow(\n clippy::derive_partial_eq_without_eq,\n clippy::empty_enums,\n clippy::unreadable_literal\n)]\n#![cfg_at"
},
{
"path": "test_suite/tests/test_deprecated.rs",
"chars": 451,
"preview": "#![deny(deprecated)]\n#![allow(dead_code)]\n\nuse serde_derive::{Deserialize, Serialize};\n\n#[derive(Serialize, Deserialize)"
},
{
"path": "test_suite/tests/test_enum_adjacently_tagged.rs",
"chars": 20764,
"preview": "#![deny(trivial_numeric_casts)]\n#![allow(\n clippy::derive_partial_eq_without_eq,\n clippy::enum_variant_names,\n "
},
{
"path": "test_suite/tests/test_enum_internally_tagged.rs",
"chars": 37961,
"preview": "#![deny(trivial_numeric_casts)]\n#![allow(\n clippy::derive_partial_eq_without_eq,\n clippy::enum_variant_names,\n "
},
{
"path": "test_suite/tests/test_enum_untagged.rs",
"chars": 13734,
"preview": "#![deny(trivial_numeric_casts)]\n#![allow(\n clippy::derive_partial_eq_without_eq,\n clippy::enum_variant_names,\n "
},
{
"path": "test_suite/tests/test_gen.rs",
"chars": 24330,
"preview": "// These just test that serde_derive is able to produce code that compiles\n// successfully when there are a variety of g"
},
{
"path": "test_suite/tests/test_identifier.rs",
"chars": 6078,
"preview": "//! Tests for `#[serde(field_identifier)]` and `#[serde(variant_identifier)]`\n\n#![allow(clippy::derive_partial_eq_withou"
},
{
"path": "test_suite/tests/test_ignored_any.rs",
"chars": 2860,
"preview": "#![allow(clippy::derive_partial_eq_without_eq)]\n\nuse serde::de::value::{Error, MapDeserializer, SeqDeserializer};\nuse se"
},
{
"path": "test_suite/tests/test_macros.rs",
"chars": 18923,
"preview": "#![deny(trivial_numeric_casts)]\n#![allow(\n clippy::derive_partial_eq_without_eq,\n clippy::enum_variant_names,\n "
},
{
"path": "test_suite/tests/test_remote.rs",
"chars": 5809,
"preview": "#![allow(clippy::redundant_field_names, dead_code)]\n\nuse serde_derive::{Deserialize, Serialize};\n\nmod remote {\n pub s"
},
{
"path": "test_suite/tests/test_roundtrip.rs",
"chars": 990,
"preview": "use serde_test::{assert_tokens, Configure, Token};\nuse std::net;\n\n#[macro_use]\n#[allow(unused_macros)]\nmod macros;\n\n#[te"
},
{
"path": "test_suite/tests/test_self.rs",
"chars": 1771,
"preview": "#![allow(clippy::used_underscore_binding, dead_code)]\n\nuse serde_derive::{Deserialize, Serialize};\n\n#[test]\nfn test_self"
},
{
"path": "test_suite/tests/test_ser.rs",
"chars": 21086,
"preview": "#![allow(clippy::derive_partial_eq_without_eq, clippy::unreadable_literal)]\n#![cfg_attr(feature = \"unstable\", feature(ne"
},
{
"path": "test_suite/tests/test_serde_path.rs",
"chars": 1249,
"preview": "#![allow(\n clippy::elidable_lifetime_names,\n clippy::extra_unused_type_parameters,\n clippy::needless_lifetimes,"
},
{
"path": "test_suite/tests/test_unstable.rs",
"chars": 458,
"preview": "#![deny(warnings)]\n#![allow(clippy::derive_partial_eq_without_eq)]\n\n// This test target is convoluted with the actual #["
},
{
"path": "test_suite/tests/test_value.rs",
"chars": 2611,
"preview": "#![allow(clippy::derive_partial_eq_without_eq, clippy::similar_names)]\n\nuse serde::de::value::{self, MapAccessDeserializ"
},
{
"path": "test_suite/tests/ui/borrow/bad_lifetimes.rs",
"chars": 134,
"preview": "use serde_derive::Deserialize;\n\n#[derive(Deserialize)]\nstruct Test<'a> {\n #[serde(borrow = \"zzz\")]\n s: &'a str,\n}\n"
},
{
"path": "test_suite/tests/ui/borrow/bad_lifetimes.stderr",
"chars": 160,
"preview": "error: failed to parse borrowed lifetimes: \"zzz\"\n --> tests/ui/borrow/bad_lifetimes.rs:5:22\n |\n5 | #[serde(borrow ="
},
{
"path": "test_suite/tests/ui/borrow/duplicate_lifetime.rs",
"chars": 138,
"preview": "use serde_derive::Deserialize;\n\n#[derive(Deserialize)]\nstruct Test<'a> {\n #[serde(borrow = \"'a + 'a\")]\n s: &'a str"
},
{
"path": "test_suite/tests/ui/borrow/duplicate_lifetime.stderr",
"chars": 164,
"preview": "error: duplicate borrowed lifetime `'a`\n --> tests/ui/borrow/duplicate_lifetime.rs:5:22\n |\n5 | #[serde(borrow = \"'a"
},
{
"path": "test_suite/tests/ui/borrow/duplicate_variant.rs",
"chars": 190,
"preview": "use serde_derive::Deserialize;\n\n#[derive(Deserialize)]\nstruct Str<'a>(&'a str);\n\n#[derive(Deserialize)]\nenum Test<'a> {\n"
},
{
"path": "test_suite/tests/ui/borrow/duplicate_variant.stderr",
"chars": 155,
"preview": "error: duplicate serde attribute `borrow`\n --> tests/ui/borrow/duplicate_variant.rs:9:15\n |\n9 | S(#[serde(borrow)] "
},
{
"path": "test_suite/tests/ui/borrow/empty_lifetimes.rs",
"chars": 175,
"preview": "use serde_derive::Deserialize;\n\n#[derive(Deserialize)]\nstruct Test<'a> {\n #[serde(borrow = \"\")]\n r: &'a str,\n #"
},
{
"path": "test_suite/tests/ui/borrow/empty_lifetimes.stderr",
"chars": 311,
"preview": "error: at least one lifetime must be borrowed\n --> tests/ui/borrow/empty_lifetimes.rs:5:22\n |\n5 | #[serde(borrow = "
},
{
"path": "test_suite/tests/ui/borrow/no_lifetimes.rs",
"chars": 121,
"preview": "use serde_derive::Deserialize;\n\n#[derive(Deserialize)]\nstruct Test {\n #[serde(borrow)]\n s: String,\n}\n\nfn main() {}"
},
{
"path": "test_suite/tests/ui/borrow/no_lifetimes.stderr",
"chars": 157,
"preview": "error: field `s` has no lifetimes to borrow\n --> tests/ui/borrow/no_lifetimes.rs:5:5\n |\n5 | / #[serde(borrow)]\n6 | "
},
{
"path": "test_suite/tests/ui/borrow/struct_variant.rs",
"chars": 179,
"preview": "use serde_derive::Deserialize;\n\n#[derive(Deserialize)]\nstruct Str<'a>(&'a str);\n\n#[derive(Deserialize)]\nenum Test<'a> {\n"
},
{
"path": "test_suite/tests/ui/borrow/struct_variant.stderr",
"chars": 190,
"preview": "error: #[serde(borrow)] may only be used on newtype variants\n --> tests/ui/borrow/struct_variant.rs:8:5\n |\n8 | / #["
},
{
"path": "test_suite/tests/ui/borrow/wrong_lifetime.rs",
"chars": 133,
"preview": "use serde_derive::Deserialize;\n\n#[derive(Deserialize)]\nstruct Test<'a> {\n #[serde(borrow = \"'b\")]\n s: &'a str,\n}\n\n"
},
{
"path": "test_suite/tests/ui/borrow/wrong_lifetime.stderr",
"chars": 167,
"preview": "error: field `s` does not have lifetime 'b\n --> tests/ui/borrow/wrong_lifetime.rs:5:5\n |\n5 | / #[serde(borrow = \"'b"
},
{
"path": "test_suite/tests/ui/conflict/adjacent-tag.rs",
"chars": 139,
"preview": "use serde_derive::Serialize;\n\n#[derive(Serialize)]\n#[serde(tag = \"conflict\", content = \"conflict\")]\nenum E {\n A,\n "
},
{
"path": "test_suite/tests/ui/conflict/adjacent-tag.stderr",
"chars": 233,
"preview": "error: enum tags `conflict` for type and content conflict with each other\n --> tests/ui/conflict/adjacent-tag.rs:4:1\n |"
},
{
"path": "test_suite/tests/ui/conflict/alias-enum.rs",
"chars": 1294,
"preview": "#![allow(non_camel_case_types)]\n\nuse serde_derive::Deserialize;\n\n#[derive(Deserialize)]\nenum E {\n S1 {\n #[serd"
},
{
"path": "test_suite/tests/ui/conflict/alias-enum.stderr",
"chars": 2512,
"preview": "error[E0425]: cannot find value `__FAIL__` in this scope\n --> tests/ui/conflict/alias-enum.rs:74:5\n |\n74 | __FAIL"
},
{
"path": "test_suite/tests/ui/conflict/alias.rs",
"chars": 656,
"preview": "use serde_derive::Deserialize;\n\n#[derive(Deserialize)]\nstruct S1 {\n #[serde(alias = \"a\", alias = \"b\", alias = \"c\")]\n "
},
{
"path": "test_suite/tests/ui/conflict/alias.stderr",
"chars": 1324,
"preview": "error[E0425]: cannot find value `__FAIL__` in this scope\n --> tests/ui/conflict/alias.rs:38:5\n |\n38 | __FAIL__;\n "
},
{
"path": "test_suite/tests/ui/conflict/flatten-newtype-struct.rs",
"chars": 151,
"preview": "use serde_derive::Serialize;\nuse std::collections::HashMap;\n\n#[derive(Serialize)]\nstruct Foo(#[serde(flatten)] HashMap<S"
},
{
"path": "test_suite/tests/ui/conflict/flatten-newtype-struct.stderr",
"chars": 233,
"preview": "error: #[serde(flatten)] cannot be used on newtype structs\n --> tests/ui/conflict/flatten-newtype-struct.rs:5:12\n |\n5 |"
},
{
"path": "test_suite/tests/ui/conflict/flatten-tuple-struct.rs",
"chars": 156,
"preview": "use serde_derive::Serialize;\nuse std::collections::HashMap;\n\n#[derive(Serialize)]\nstruct Foo(u32, #[serde(flatten)] Hash"
},
{
"path": "test_suite/tests/ui/conflict/flatten-tuple-struct.stderr",
"chars": 239,
"preview": "error: #[serde(flatten)] cannot be used on tuple structs\n --> tests/ui/conflict/flatten-tuple-struct.rs:5:17\n |\n5 | str"
},
{
"path": "test_suite/tests/ui/conflict/from-try-from.rs",
"chars": 130,
"preview": "use serde_derive::Serialize;\n\n#[derive(Serialize)]\n#[serde(from = \"u64\", try_from = \"u64\")]\nstruct S {\n a: u8,\n}\n\nfn "
},
{
"path": "test_suite/tests/ui/conflict/from-try-from.stderr",
"chars": 231,
"preview": "error: #[serde(from = \"...\")] and #[serde(try_from = \"...\")] conflict with each other\n --> tests/ui/conflict/from-try-fr"
},
{
"path": "test_suite/tests/ui/conflict/internal-tag-alias.rs",
"chars": 170,
"preview": "use serde_derive::Serialize;\n\n#[derive(Serialize)]\n#[serde(tag = \"conflict\")]\nenum E {\n A {\n #[serde(alias = \""
},
{
"path": "test_suite/tests/ui/conflict/internal-tag-alias.stderr",
"chars": 283,
"preview": "error: variant field name `conflict` conflicts with internal tag\n --> tests/ui/conflict/internal-tag-alias.rs:4:1\n |\n"
},
{
"path": "test_suite/tests/ui/conflict/internal-tag.rs",
"chars": 171,
"preview": "use serde_derive::Serialize;\n\n#[derive(Serialize)]\n#[serde(tag = \"conflict\")]\nenum E {\n A {\n #[serde(rename = "
},
{
"path": "test_suite/tests/ui/conflict/internal-tag.stderr",
"chars": 278,
"preview": "error: variant field name `conflict` conflicts with internal tag\n --> tests/ui/conflict/internal-tag.rs:4:1\n |\n 4 | /"
},
{
"path": "test_suite/tests/ui/default-attribute/enum.rs",
"chars": 115,
"preview": "use serde_derive::Deserialize;\n\n#[derive(Deserialize)]\n#[serde(default)]\nenum E {\n S { f: u8 },\n}\n\nfn main() {}\n"
},
{
"path": "test_suite/tests/ui/default-attribute/enum.stderr",
"chars": 143,
"preview": "error: #[serde(default)] can only be used on structs\n --> tests/ui/default-attribute/enum.rs:4:9\n |\n4 | #[serde(default"
},
{
"path": "test_suite/tests/ui/default-attribute/enum_path.rs",
"chars": 129,
"preview": "use serde_derive::Deserialize;\n\n#[derive(Deserialize)]\n#[serde(default = \"default_e\")]\nenum E {\n S { f: u8 },\n}\n\nfn m"
},
{
"path": "test_suite/tests/ui/default-attribute/enum_path.stderr",
"chars": 184,
"preview": "error: #[serde(default = \"...\")] can only be used on structs\n --> tests/ui/default-attribute/enum_path.rs:4:9\n |\n4 | #["
},
{
"path": "test_suite/tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.rs",
"chars": 493,
"preview": "// Tests that type error points to the path in attribute\n\nuse serde_derive::Deserialize;\n\n#[derive(Deserialize)]\n#[serde"
},
{
"path": "test_suite/tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.stderr",
"chars": 1255,
"preview": "error[E0308]: `match` arms have incompatible types\n --> tests/ui/default-attribute/incorrect_type_enum_adjacently_tagge"
},
{
"path": "test_suite/tests/ui/default-attribute/incorrect_type_enum_externally_tagged.rs",
"chars": 450,
"preview": "// Tests that type error points to the path in attribute\n\nuse serde_derive::Deserialize;\n\n#[derive(Deserialize)]\nenum En"
},
{
"path": "test_suite/tests/ui/default-attribute/incorrect_type_enum_externally_tagged.stderr",
"chars": 1245,
"preview": "error[E0308]: `match` arms have incompatible types\n --> tests/ui/default-attribute/incorrect_type_enum_externally_tagged"
},
{
"path": "test_suite/tests/ui/default-attribute/incorrect_type_enum_internally_tagged.rs",
"chars": 493,
"preview": "// Tests that type error points to the path in attribute\n\nuse serde_derive::Deserialize;\n\n#[derive(Deserialize)]\n#[serde"
},
{
"path": "test_suite/tests/ui/default-attribute/incorrect_type_enum_internally_tagged.stderr",
"chars": 825,
"preview": "error[E0308]: `match` arms have incompatible types\n --> tests/ui/default-attribute/incorrect_type_enum_internally_tagge"
},
{
"path": "test_suite/tests/ui/default-attribute/incorrect_type_enum_untagged.rs",
"chars": 469,
"preview": "// Tests that type error points to the path in attribute\n\nuse serde_derive::Deserialize;\n\n#[derive(Deserialize)]\n#[serde"
},
{
"path": "test_suite/tests/ui/default-attribute/incorrect_type_enum_untagged.stderr",
"chars": 1228,
"preview": "error[E0308]: `match` arms have incompatible types\n --> tests/ui/default-attribute/incorrect_type_enum_untagged.rs:10:3"
},
{
"path": "test_suite/tests/ui/default-attribute/incorrect_type_newtype.rs",
"chars": 201,
"preview": "// Tests that type error points to the path in attribute\n\nuse serde_derive::Deserialize;\n\n#[derive(Deserialize)]\n#[serde"
},
{
"path": "test_suite/tests/ui/default-attribute/incorrect_type_newtype.stderr",
"chars": 1248,
"preview": "error[E0308]: mismatched types\n --> tests/ui/default-attribute/incorrect_type_newtype.rs:6:19\n |\n6 | #[serde(default = "
},
{
"path": "test_suite/tests/ui/default-attribute/incorrect_type_struct.rs",
"chars": 270,
"preview": "// Tests that type error points to the path in attribute\n\nuse serde_derive::Deserialize;\n\n#[derive(Deserialize)]\n#[serde"
},
{
"path": "test_suite/tests/ui/default-attribute/incorrect_type_struct.stderr",
"chars": 1787,
"preview": "error[E0308]: mismatched types\n --> tests/ui/default-attribute/incorrect_type_struct.rs:6:19\n |\n6 | #[serde(default = \""
},
{
"path": "test_suite/tests/ui/default-attribute/incorrect_type_tuple.rs",
"chars": 203,
"preview": "// Tests that type error points to the path in attribute\n\nuse serde_derive::Deserialize;\n\n#[derive(Deserialize)]\n#[serde"
},
{
"path": "test_suite/tests/ui/default-attribute/incorrect_type_tuple.stderr",
"chars": 1244,
"preview": "error[E0308]: mismatched types\n --> tests/ui/default-attribute/incorrect_type_tuple.rs:6:19\n |\n6 | #[serde(default = \"m"
},
{
"path": "test_suite/tests/ui/default-attribute/tuple_struct.rs",
"chars": 1500,
"preview": "use serde_derive::Deserialize;\n\n// No errors expected.\n#[derive(Deserialize)]\nstruct T0(u8, u8);\n\n// No errors expected:"
},
{
"path": "test_suite/tests/ui/default-attribute/tuple_struct.stderr",
"chars": 473,
"preview": "error: field must have #[serde(default)] because previous field 0 has #[serde(default)]\n --> tests/ui/default-attribute"
},
{
"path": "test_suite/tests/ui/default-attribute/tuple_struct_path.rs",
"chars": 2517,
"preview": "use serde_derive::Deserialize;\n\nfn d<T>() -> T {\n unimplemented!()\n}\n\n// No errors expected:\n// - If both fields are "
},
{
"path": "test_suite/tests/ui/default-attribute/tuple_struct_path.stderr",
"chars": 507,
"preview": "error: field must have #[serde(default)] because previous field 0 has #[serde(default)]\n --> tests/ui/default-attribute"
},
{
"path": "test_suite/tests/ui/default-attribute/union.rs",
"chars": 114,
"preview": "use serde_derive::Deserialize;\n\n#[derive(Deserialize)]\n#[serde(default)]\nunion Union {\n f: u8,\n}\n\nfn main() {}\n"
},
{
"path": "test_suite/tests/ui/default-attribute/union.stderr",
"chars": 319,
"preview": "error: #[serde(default)] can only be used on structs\n --> tests/ui/default-attribute/union.rs:4:9\n |\n4 | #[serde(defaul"
},
{
"path": "test_suite/tests/ui/default-attribute/union_path.rs",
"chars": 128,
"preview": "use serde_derive::Deserialize;\n\n#[derive(Deserialize)]\n#[serde(default = \"default_u\")]\nunion Union {\n f: u8,\n}\n\nfn ma"
},
{
"path": "test_suite/tests/ui/default-attribute/union_path.stderr",
"chars": 379,
"preview": "error: #[serde(default = \"...\")] can only be used on structs\n --> tests/ui/default-attribute/union_path.rs:4:9\n |\n4 | #"
},
{
"path": "test_suite/tests/ui/default-attribute/unit.rs",
"chars": 100,
"preview": "use serde_derive::Deserialize;\n\n#[derive(Deserialize)]\n#[serde(default)]\nstruct Unit;\n\nfn main() {}\n"
},
{
"path": "test_suite/tests/ui/default-attribute/unit.stderr",
"chars": 304,
"preview": "error: #[serde(default)] can only be used on structs that have fields\n --> tests/ui/default-attribute/unit.rs:3:10\n |\n3"
},
{
"path": "test_suite/tests/ui/default-attribute/unit_path.rs",
"chars": 114,
"preview": "use serde_derive::Deserialize;\n\n#[derive(Deserialize)]\n#[serde(default = \"default_u\")]\nstruct Unit;\n\nfn main() {}\n"
},
{
"path": "test_suite/tests/ui/default-attribute/unit_path.stderr",
"chars": 201,
"preview": "error: #[serde(default = \"...\")] can only be used on structs that have fields\n --> tests/ui/default-attribute/unit_path."
},
{
"path": "test_suite/tests/ui/deprecated/deprecated_de_with.rs",
"chars": 351,
"preview": "#![deny(deprecated)]\n\nuse serde::Deserializer;\nuse serde_derive::Deserialize;\n\n#[derive(Deserialize)]\npub struct Struct "
},
{
"path": "test_suite/tests/ui/deprecated/deprecated_de_with.stderr",
"chars": 360,
"preview": "error: use of deprecated function `deprecated_with`\n --> tests/ui/deprecated/deprecated_de_with.rs:8:32\n |\n8 | #[se"
},
{
"path": "test_suite/tests/ui/deprecated/deprecated_ser_with.rs",
"chars": 345,
"preview": "#![deny(deprecated)]\n\nuse serde::Serializer;\nuse serde_derive::Serialize;\n\n#[derive(Serialize)]\npub struct Struct {\n "
},
{
"path": "test_suite/tests/ui/deprecated/deprecated_ser_with.stderr",
"chars": 358,
"preview": "error: use of deprecated function `deprecated_with`\n --> tests/ui/deprecated/deprecated_ser_with.rs:8:30\n |\n8 | #[s"
},
{
"path": "test_suite/tests/ui/duplicate-attribute/rename-and-ser.rs",
"chars": 133,
"preview": "use serde_derive::Serialize;\n\n#[derive(Serialize)]\nstruct S {\n #[serde(rename = \"x\", serialize = \"y\")]\n x: (),\n}\n\n"
},
{
"path": "test_suite/tests/ui/duplicate-attribute/rename-and-ser.stderr",
"chars": 198,
"preview": "error: unknown serde field attribute `serialize`\n --> tests/ui/duplicate-attribute/rename-and-ser.rs:5:27\n |\n5 | #["
},
{
"path": "test_suite/tests/ui/duplicate-attribute/rename-ser-rename-ser.rs",
"chars": 152,
"preview": "use serde_derive::Serialize;\n\n#[derive(Serialize)]\nstruct S {\n #[serde(rename(serialize = \"x\"), rename(serialize = \"y"
},
{
"path": "test_suite/tests/ui/duplicate-attribute/rename-ser-rename-ser.stderr",
"chars": 225,
"preview": "error: duplicate serde attribute `rename`\n --> tests/ui/duplicate-attribute/rename-ser-rename-ser.rs:5:38\n |\n5 | #["
},
{
"path": "test_suite/tests/ui/duplicate-attribute/rename-ser-rename.rs",
"chars": 154,
"preview": "use serde_derive::Serialize;\n\n#[derive(Serialize)]\nstruct S {\n #[serde(rename(serialize = \"x\"))]\n #[serde(rename ="
},
{
"path": "test_suite/tests/ui/duplicate-attribute/rename-ser-rename.stderr",
"chars": 160,
"preview": "error: duplicate serde attribute `rename`\n --> tests/ui/duplicate-attribute/rename-ser-rename.rs:6:13\n |\n6 | #[serd"
},
{
"path": "test_suite/tests/ui/duplicate-attribute/rename-ser-ser.rs",
"chars": 144,
"preview": "use serde_derive::Serialize;\n\n#[derive(Serialize)]\nstruct S {\n #[serde(rename(serialize = \"x\", serialize = \"y\"))]\n "
},
{
"path": "test_suite/tests/ui/duplicate-attribute/rename-ser-ser.stderr",
"chars": 212,
"preview": "error: duplicate serde attribute `rename`\n --> tests/ui/duplicate-attribute/rename-ser-ser.rs:5:37\n |\n5 | #[serde(r"
},
{
"path": "test_suite/tests/ui/duplicate-attribute/two-rename-ser.rs",
"chars": 165,
"preview": "use serde_derive::Serialize;\n\n#[derive(Serialize)]\nstruct S {\n #[serde(rename(serialize = \"x\"))]\n #[serde(rename(s"
},
{
"path": "test_suite/tests/ui/duplicate-attribute/two-rename-ser.stderr",
"chars": 168,
"preview": "error: duplicate serde attribute `rename`\n --> tests/ui/duplicate-attribute/two-rename-ser.rs:6:13\n |\n6 | #[serde(r"
},
{
"path": "test_suite/tests/ui/duplicate-attribute/with-and-serialize-with.rs",
"chars": 136,
"preview": "use serde_derive::Serialize;\n\n#[derive(Serialize)]\nstruct S {\n #[serde(with = \"w\", serialize_with = \"s\")]\n x: (),\n"
},
{
"path": "test_suite/tests/ui/duplicate-attribute/with-and-serialize-with.stderr",
"chars": 214,
"preview": "error: duplicate serde attribute `serialize_with`\n --> tests/ui/duplicate-attribute/with-and-serialize-with.rs:5:25\n |\n"
},
{
"path": "test_suite/tests/ui/enum-representation/content-no-tag.rs",
"chars": 126,
"preview": "use serde_derive::Serialize;\n\n#[derive(Serialize)]\n#[serde(content = \"c\")]\nenum E {\n A(u8),\n B(String),\n}\n\nfn main"
},
{
"path": "test_suite/tests/ui/enum-representation/content-no-tag.stderr",
"chars": 176,
"preview": "error: #[serde(tag = \"...\", content = \"...\")] must be used together\n --> tests/ui/enum-representation/content-no-tag.rs:"
},
{
"path": "test_suite/tests/ui/enum-representation/internal-tuple-variant.rs",
"chars": 118,
"preview": "use serde_derive::Serialize;\n\n#[derive(Serialize)]\n#[serde(tag = \"type\")]\nenum E {\n Tuple(u8, u8),\n}\n\nfn main() {}\n"
},
{
"path": "test_suite/tests/ui/enum-representation/internal-tuple-variant.stderr",
"chars": 177,
"preview": "error: #[serde(tag = \"...\")] cannot be used with tuple variants\n --> tests/ui/enum-representation/internal-tuple-variant"
},
{
"path": "test_suite/tests/ui/enum-representation/partially_tagged_wrong_order.rs",
"chars": 125,
"preview": "use serde_derive::Serialize;\n\n#[derive(Serialize)]\nenum E {\n #[serde(untagged)]\n A(u8),\n B(String),\n}\n\nfn main("
},
{
"path": "test_suite/tests/ui/enum-representation/partially_tagged_wrong_order.stderr",
"chars": 195,
"preview": "error: all variants with the #[serde(untagged)] attribute must be placed at the end of the enum\n --> tests/ui/enum-repre"
},
{
"path": "test_suite/tests/ui/enum-representation/untagged-and-adjacent.rs",
"chars": 156,
"preview": "use serde_derive::Serialize;\n\n#[derive(Serialize)]\n#[serde(untagged)]\n#[serde(tag = \"t\", content = \"c\")]\nenum E {\n A("
},
{
"path": "test_suite/tests/ui/enum-representation/untagged-and-adjacent.stderr",
"chars": 589,
"preview": "error: untagged enum cannot have #[serde(tag = \"...\", content = \"...\")]\n --> tests/ui/enum-representation/untagged-and-a"
},
{
"path": "test_suite/tests/ui/enum-representation/untagged-and-content.rs",
"chars": 145,
"preview": "use serde_derive::Serialize;\n\n#[derive(Serialize)]\n#[serde(untagged)]\n#[serde(content = \"c\")]\nenum E {\n A(u8),\n B("
},
{
"path": "test_suite/tests/ui/enum-representation/untagged-and-content.stderr",
"chars": 343,
"preview": "error: untagged enum cannot have #[serde(content = \"...\")]\n --> tests/ui/enum-representation/untagged-and-content.rs:4:9"
},
{
"path": "test_suite/tests/ui/enum-representation/untagged-and-internal.rs",
"chars": 144,
"preview": "use serde_derive::Serialize;\n\n#[derive(Serialize)]\n#[serde(untagged)]\n#[serde(tag = \"type\")]\nenum E {\n A(u8),\n B(S"
},
{
"path": "test_suite/tests/ui/enum-representation/untagged-and-internal.stderr",
"chars": 338,
"preview": "error: enum cannot be both untagged and internally tagged\n --> tests/ui/enum-representation/untagged-and-internal.rs:4:9"
},
{
"path": "test_suite/tests/ui/enum-representation/untagged-struct.rs",
"chars": 94,
"preview": "use serde_derive::Serialize;\n\n#[derive(Serialize)]\n#[serde(untagged)]\nstruct S;\n\nfn main() {}\n"
},
{
"path": "test_suite/tests/ui/enum-representation/untagged-struct.stderr",
"chars": 157,
"preview": "error: #[serde(untagged)] can only be used on enums\n --> tests/ui/enum-representation/untagged-struct.rs:4:9\n |\n4 | #[s"
}
]
// ... and 147 more files (download for full content)
About this extraction
This page contains the full source code of the serde-rs/serde GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 347 files (1.3 MB), approximately 334.6k tokens, and a symbol index with 2524 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.