in uniffi_udl/src/converters/callables.rs [181:223]
fn convert(&self, ci: &mut InterfaceCollector) -> Result<TraitMethodMetadata> {
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(TraitMethodMetadata {
module_path: ci.module_path(),
trait_name: Default::default(), // we'll fill these in later.
index: Default::default(),
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
}
},
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)),
})
}