Repository navigation
types: add the Any type-URL helpers to AnyView - #734
Open
farmer-data wants to merge 2 commits into
Open
farmer-data wants to merge 2 commits into
farmer-data wants to merge 2 commits into
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
Fixes anthropics#643. AnyView gains inherent type_name, is_message, is_type, unpack_message and unpack_if, sharing the type-name rule with Any through a private type_name_of. AnyView::type_name returns Option<&'a str>, borrowing from the decoded buffer.
This branch has not been deployed
This file contains hidden or 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
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.
Fixes #643.
AnyViewgains inherenttype_name,is_message,is_type,unpack_messageandunpack_if, so a zero-copy handler can test and unpack the packed type without converting to anAnyor splittingtype_urlby hand.Any::type_nameandAnyView::type_namenow share one privatetype_name_of, so the rules can't drift, including the bare-name reading from any: read a type URL without a '/' as a bare message name #692.AnyView::type_namereturnsOption<&'a str>, borrowing from the decoded buffer rather than the view.unpack_messageandunpack_ifdecode an ownedTfrom the borrowedvalue. For a view of the payload, the docs point tois_message::<FooView>()plusFooView::decode_view(view.value). A view-returningunpack_viewwould be additive, and I left it out sinceAnyhas no counterpart.Anyon 8 type URLs (empty, trailing/, no/, a near-miss name, other prefixes), plus lifetime, view-type and decode-error tests. The guide's Any section gets one paragraph, including how to reach the helpers fromAnyOwnedViewviaview().Verification:
task lint,task test-local(4293 passed, 0 failed) and stricttask docpass with the repo-pinned protoc 33.5. Reviewed withrust-code-reviewerandrust-api-ergonomics-reviewerper CLAUDE.md: no Critical or High findings. The Medium (theis_typedoc wording) and the doc Lows are addressed.