Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(prost-types): derive Arbitrary #1188

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ jobs:
uses: ./.github/actions/setup-ninja
- uses: Swatinem/rust-cache@v2
- name: test
run: cargo test
run: cargo test --features arbitrary
- name: test no-default-features
run: cargo test -p prost-build -p prost-derive -p prost-types --no-default-features

Expand Down
2 changes: 2 additions & 0 deletions prost-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ doctest = false
[features]
default = ["std"]
std = ["prost/std"]
arbitrary = ["dep:arbitrary"]

[dependencies]
prost = { version = "0.13.4", path = "../prost", default-features = false, features = ["prost-derive"] }
arbitrary = { version = "1.4", features = ["derive"], optional = true }

[dev-dependencies]
proptest = "1"
Expand Down
5 changes: 5 additions & 0 deletions prost-types/src/compiler.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// This file is @generated by prost-build.
/// The version number of protocol compiler.
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Version {
#[prost(int32, optional, tag = "1")]
Expand All @@ -14,6 +15,7 @@ pub struct Version {
pub suffix: ::core::option::Option<::prost::alloc::string::String>,
}
/// An encoded CodeGeneratorRequest is written to the plugin's stdin.
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CodeGeneratorRequest {
/// The .proto files that were explicitly listed on the command-line. The
Expand Down Expand Up @@ -45,6 +47,7 @@ pub struct CodeGeneratorRequest {
pub compiler_version: ::core::option::Option<Version>,
}
/// The plugin writes an encoded CodeGeneratorResponse to stdout.
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CodeGeneratorResponse {
/// Error message. If non-empty, code generation failed. The plugin process
Expand All @@ -67,6 +70,7 @@ pub struct CodeGeneratorResponse {
/// Nested message and enum types in `CodeGeneratorResponse`.
pub mod code_generator_response {
/// Represents a single generated file.
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct File {
/// The file name, relative to the output directory. The name must not
Expand Down Expand Up @@ -131,6 +135,7 @@ pub mod code_generator_response {
pub generated_code_info: ::core::option::Option<super::super::GeneratedCodeInfo>,
}
/// Sync with code_generator.h.
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[derive(
Clone,
Copy,
Expand Down
1 change: 1 addition & 0 deletions prost-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
//!
//! ## Feature Flags
//! - `std`: Enable integration with standard library. Disable this feature for `no_std` support. This feature is enabled by default.
//! - `arbitrary`: Enable integration with crate `arbitrary`. All types on this crate will implement `trait Arbitrary`.
//!
//! [1]: https://developers.google.com/protocol-buffers/docs/reference/google.protobuf

Expand Down
Loading
Loading