You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
types: AnyView has none of Any's type-URL helpers #643
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 existlet 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
changelog: cite anthropics#734 for the anthropics#643 fragment