-
Notifications
You must be signed in to change notification settings - Fork 469
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
Add more attributes #493
Open
r3v2d0g
wants to merge
18
commits into
tokio-rs:master
Choose a base branch
from
deliveroo:master
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add more attributes #493
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ly for messages and scalars)
r3v2d0g
force-pushed
the
master
branch
6 times, most recently
from
July 1, 2021 12:02
fdf2ce9
to
bb3a1c1
Compare
This seems interesting, since its quite large its not extremely high priority on my list but I will get to this soon. Thanks for the patience. |
@r3v2d0g I am still interested in adding this to prost but would you be able to break these up into some smaller PRs. Thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds four new struct attributes, and seven new field attributes. It also adds support for using
#[prost(...)]
multiple times on a field.Struct attributes
debug = bool
(default:true
): iffalse
,prost
won't implementDebug
for the structdefault = bool
(default:true
): iffalse
,prost
won't implementDefault
for the structmerge = bool
(default:true
): iffalse
,prost
will implementMessage::merge_field
andMessage::merge
to return an errrorproto = "proto2" | "proto3"
(default:"proto2"
): changes the default behavior ofmessage
fields withoutrequired
oroptional
specified to beoptional
whenproto = "proto2"
andrequired
whenproto = "proto3"
Field attributes
Scalar and
message
fieldsT
is the field's type.U
is either the specified scalar or a type implementingMessage
.as_msg = "fn_or_closure"
:fn (field: &T) -> &U
to_msg = "fn_or_closure"
:fn (field: &T) -> U
from_msg = "fn_or_closure"
:fn (msg: U) -> T
merge_msg = "fn_or_closure"
:fn (field: &mut T, msg: U)
clear = bool
(default:true
): iffalse
, doesn't clear this field whenMessage::clear
is calledrepeated
fieldsT
is either the field's type (ifas_msgs
orto_msgs
is set) or theT
inVec<T>
(ifas_msgs
andto_msgs
are not set).U
is either the specified scalar or a type implementingMessage
.as_msg = "fn_or_closure"
:fn (elem: &T) -> &U
to_msg = "fn_or_closure"
:fn (elem: &T) -> U
as_msgs = "fn_or_closure"
:fn (field: &T) -> &Vec<U>
orfn (field: &T) -> impl Iterator<Item = &U> + '_
to_msgs = "fn_or_closure"
:fn (field: &T) -> Vec<U>
orfn (field: &T) -> impl Iterator<U> + '_
from_msg = "fn_or_closure"
:fn (msg: U) -> T
merge_msg = "fn_or_closure"
:fn (elem_or_field: &mut T, msg: U)
clear = bool
(default:true
): iffalse
, doesn't clear this field whenMessage::clear
is calledIf the field is defined as
packed
or the scalar type is a number, thenas_msgs
andto_msgs
should not return anIterator
.If
as_msgs
orto_msgs
is set, thenas_msg
andto_msg
should not be set.map = "key, value"
fieldsT
is the value type of the map (theV
inHashMap<K, V>
andBTreeMap<K, V>
).U
is either the specified scalar (asvalue
) or a type implementingMessage
.as_msg = "fn_or_closure"
:fn (field: &T) -> &U
to_msg = "fn_or_closure"
:fn (field: &T) -> U
from_msg = "fn_or_closure"
:fn (msg: U) -> T
merge_msg = "fn_or_closure"
:fn (field: &mut T, msg: U)
clear = bool
(default:true
): iffalse
, doesn't clear this field whenMessage::clear
is called