Skip to main content

parse_type_ref

Function parse_type_ref 

Source
pub fn parse_type_ref(s: &str) -> Result<TypeRef, String>
Expand description

Parse the IDL’s compact type syntax into a TypeRef.

Handles primitive names (i32, string, bytes, and so on), iterators (iter<T>), lists ([T]), maps ({K:V}), and the optional suffix (T?). Any other bare identifier is taken to be a user-defined record, enum, interface, or callback interface name and returned as TypeRef::Named.

§Errors

Returns an error message when s is empty or only whitespace, when a map type ({K:V}) is missing its : separator. The same errors propagate up from a malformed inner type of a list, map, optional, or iterator.