types: `AnyView` has none of `Any`'s type-URL helpers
Maintainers usually reply within 3 days
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
Research direction
Start in buffa-types/src/any_ext.rs: read how Any implements type_name, is_message, is_type, unpack_message and unpack_if, especially the documented split rule (text after the last /, no name for URLs without / or with an empty name). Then locate the generated AnyView<'a> definition and its decode_view entry point to see what its two borrowed fields offer. Done means AnyView exposes the same five helpers by sharing the split logic with Any::type_name, with tests covering the split edge cases and unpack decoding from the borrowed value; run the crate's test suite (cargo test) to confirm.
Written by the indexing model from the issue text.
Description
Any has type_name(), is_message::<T>(), is_type(), unpack_message::<T>() and unpack_if() (buffa-types/src/any_ext.rs). The generated AnyView<'a> has only its two fields, type_url: &'a str and value: &'a [u8], so code that holds a decoded view repeats the URL split by hand or converts to an owned Any first:
let view = AnyView::decode_view(bytes)?;
// view.is_message::<Duration>() does not exist
let is_duration =
view.type_url.rsplit_once('/').map(|(_, name)| name) == Some(Duration::FULL_NAME);
A view is what a zero-copy handler dispatches on, so the type test is the first thing it needs. The hand-written split also has to repeat the rule that Any::type_name documents: the name is the text after the last /, and a URL with no / or with an empty name has no type name.
Proposed: inherent type_name, is_message, is_type, unpack_message and unpack_if on AnyView, sharing the split with Any::type_name. They allocate only what the unpacked message needs: unpack_message decodes from the borrowed value.
- Dominant language
- Rust
- Stars
- 927
- Forks
- 119
- Avg merge
- 3d 6h
- Merged PRs (30d)
- 152
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from anthropics/buffa
-
codegen: `generate` does not check `CodeGenConfig::extern_paths`, so a direct caller's malformed proto name is kept and never matches a typePossibly taken @vladislav-miroshnikov claimed this 13 days ago. Openenhancement
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
anthropics/buffa#703 ·
Maintainers usually reply within 3 days
-
docs: `DescriptorPool::files()` does not say that link-time inference is left out of the returned descriptorsPossibly taken @veljjanoski claimed this 12 days ago. Opendocumentation
Difficulty 1/5 Under an hour Newbie friendliness 78/100
anthropics/buffa#642 · 1 comment ·
Maintainers usually reply within 3 days
-
descriptor: an editions file whose edition the pool does not define links with the edition 2023 defaultsPossibly taken @saloni-garg claimed this 4 days ago. Openquestion
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
anthropics/buffa#634 ·
Maintainers usually reply within 3 days
-
codegen: the generated `TYPE_URL` doc names `Any::pack` / `Any::unpack_if`, not `pack_message` / `unpack_message`Possibly taken @veljjanoski claimed this 12 days ago. Opendocumentation
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
anthropics/buffa#621 · 1 comment ·
Maintainers usually reply within 3 days
-
docs: custom-type rustdoc states the crate-local limit for `bytes` unconditionally and does not mention the remote-derive `arbitrary` / `serde` keys for collectionsPossibly taken @kh0ra claimed this 11 days ago. Opendocumentation
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
anthropics/buffa#620 ·
Maintainers usually reply within 3 days
All issues in anthropics/buffa
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
o8 next debug build aborts on Glass to Dark appearance switch (nil identifier messaged before check)Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
hurttlocker/o8#5112 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
memory_patch_page drops the `#` of headings like `## Notes on C#`Possibly taken @viniciusdsandrade claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
akitaonrails/ai-memory#1859 ·
Maintainers usually reply within 1 day