Skip to content

types: AnyView has none of Any's type-URL helpers #643

Open

Description

@iainmcgin

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.

Activity

  1. added a commit that references this issue on Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions