docs.rs failed to build protocheck-build-0.1.10
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build:
protocheck-build-0.1.11
⚒️ Protocheck-build
This is the build-time entrypoint for protocheck.
➡️ Getting started
To get started, you need to use [protocheck-build] as a build dependency in your crate, which will use protocheck-proc-macro to add all the validation logic to your structs. The setup will look more or less like this (this is taken directly from the tests crate)
// In your build.rs file
use Config;
use ;
use ;
compile_protos_with_validators takes these arguments:
- The
configstruct. - The proto files and include paths being used by the
config. - The list of packages to apply validators to. If a given message contains Cel validation or is validated as a field by another message, its package name must be included in this list.
The function will then:
- Compile your protos to create an intermediary descriptor
- Iterate its messages, and use the information extracted from them to add the derives and attributes to the actual
configthat are needed byprotocheck-proc-macroto add the validation logic. - Add the derive macros used by
protocheck - Use
proto_typesas the source for the well known types and the protovalidate types (it is re-exported by protocheck, so there is no need to add it as a dependency).
🍸 Tonic example
When using tonic-prost-build, the workflow is almost identical, except that we pass the config to compile_with_config:
let mut config = new;
config
.file_descriptor_set_path
.bytes
.out_dir;
// Call the build helper
compile_protos_with_validators?;
// Compile protos
configure
// We pass the config here
.compile_with_config?;
}