in uniffi_udl/src/converters/callables.rs [135:177]
fn convert(&self, ci: &mut InterfaceCollector) -> Result<MethodMetadata> {
if self.special.is_some() {
bail!("special operations not supported");
}
if self.modifier.is_some() {
bail!("method modifiers are not supported")
}
let return_type = ci.resolve_return_type_expression(&self.return_type)?;
let attributes = MethodAttributes::try_from(self.attributes.as_ref())?;
let is_async = attributes.is_async();
let throws = match attributes.get_throws_err() {
Some(name) => match ci.get_type(name) {
Some(t) => Some(t),
None => bail!("unknown type for error: {name}"),
},
None => None,
};
let takes_self_by_arc = attributes.get_self_by_arc();
Ok(MethodMetadata {
module_path: ci.module_path(),
name: match self.identifier {
None => bail!("anonymous methods are not supported {:?}", self),
Some(id) => {
let name = id.0.to_string();
if name == "new" {
bail!("the method name \"new\" is reserved for the default constructor");
}
name
}
},
// We don't know the name of the containing `Object` at this point, fill it in later.
self_name: Default::default(),
is_async,
inputs: self.args.body.list.convert(ci)?,
return_type,
throws,
takes_self_by_arc,
checksum: None,
docstring: self.docstring.as_ref().map(|v| convert_docstring(&v.0)),
})
}