Crates.io | bincode_derive |
lib.rs | bincode_derive |
version | |
source | src |
created_at | 2021-10-25 08:58:10.915593+00 |
updated_at | 2025-03-10 18:27:58.056599+00 |
description | Implementation of #[derive(Encode, Decode)] for bincode |
homepage | |
repository | https://github.com/bincode-org/bincode |
max_upload_size | |
id | 470862 |
Cargo.toml error: | TOML parse error at line 22, column 1 | 22 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
The derive crate for bincode. Implements bincode::Encode
and bincode::Decode
.
This crate is roughly split into 2 parts:
Most of parsing is done in the src/parse/
folder. This will generate the following types:
Attributes
, not being used currentlyVisibility
, not being used currentlyDataType
either Struct
or Enum
, with the name of the data type being parsedGenerics
the generics part of the type, e.g. struct Foo<'a>
GenericConstraints
the "where" part of the typeGenerating the code implementation is done in either src/derive_enum.rs
and src/derive_struct.rs
.
This is supported by the structs in src/generate
. The most notable points of this module are:
StreamBuilder
is a thin but friendly wrapper around TokenStream
Generator
is the base type of the code generator. This has helper methods to generate implementations:
ImplFor
is a helper struct for a single impl A for B
construction. In this functions can be defined:
GenerateFnBody
is a helper struct for a single function in the above impl
. This is created with a callback to FnBuilder
which helps set some properties. GenerateFnBody
has a stream()
function which returns StreamBuilder
for the function.For additional derive testing, see the test cases in ../tests
For testing purposes, all generated code is outputted to the current target/generated/bincode
folder, under file name <struct/enum name>_Encode.rs
and <struct/enum name>_Decode.rs
. This can help with debugging.