Possible to define a functionality that allows for custom defaults/generation #1131
Unanswered
michael-jaquier
asked this question in
Q&A
Replies: 1 comment
-
I feel like you are looking for the crate Arbitrary[https://docs.rs/arbitrary/latest/arbitrary/]
I think you could derive it automatically using prost-build. Let me know how that went, as I am interested in that as well.
It would be great if prost-types could derive arbitrary as well. That should be behind a feature flag. Are you willing to contribute that?
20 aug. 2024 15:19:11 Michael Jaquier ***@***.***>:
…
We have a litany of Protobufs. I would like the following to function
let mut rng = rand::thread_rng();
let my_proto: MyProto = MyProto.generate(&mut rng);
let my_proto_but_different: MyProto = MyProto.generate(&mut rng);
/// ... Do work with the proto -> Send it into system for smoke testing/testing purposes
The use case for us/me is the protos we utilize are often highly nested. The quantity of these protos makes it impractical to define some function like
pub fn generate_my_proto(rng: &mut rng) -> MyProto { ... }
Would something like so be acceptable? I believe I could create the necessary functionality behind a feature flag in code generation extending what is already create for *Default::default()* but would such a feature be accepted? There's no point in writing the code for it if it forces me to fork prost in perpetuity.
—
Reply to this email directly, view it on GitHub[#1131], or unsubscribe[https://github.com/notifications/unsubscribe-auth/AAJZ7OXMHT4MJOHMKVW2OBDZSM64ZAVCNFSM6AAAAABMZ4VWC2VHI2DSMVQWIX3LMV43ERDJONRXK43TNFXW4OZXGA3TKMBSGI].
You are receiving this because you are subscribed to this thread.
[Tracking afbeelding][https://github.com/notifications/beacon/AAJZ7OR37CMJ2WDPXDXAUOLZSM64ZA5CNFSM6AAAAABMZ4VWC2WGG33NNVSW45C7OR4XAZNKIRUXGY3VONZWS33OVJRW63LNMVXHIX3JMTHAA27UZY.gif]
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We have a litany of Protobufs. I would like the following to function
The use case for us/me is the protos we utilize are often highly nested. The quantity of these protos makes it impractical to define some function like
Would something like so be acceptable? I believe I could create the necessary functionality behind a feature flag in code generation extending what is already create for
Default::default()
but would such a feature be accepted? There's no point in writing the code for it if it forces me to fork prost in perpetuity.Beta Was this translation helpful? Give feedback.
All reactions