in uniffi_udl/src/converters/mod.rs [128:162]
fn convert(&self, ci: &mut InterfaceCollector) -> Result<CallbackInterfaceMetadata> {
if self.attributes.is_some() {
bail!("callback interface attributes are not supported yet");
}
if self.inheritance.is_some() {
bail!("callback interface inheritance is not supported");
}
let object_name = self.identifier.0;
for (index, member) in self.members.body.iter().enumerate() {
match member {
weedle::interface::InterfaceMember::Operation(t) => {
let mut method: TraitMethodMetadata = t.convert(ci)?;
// A CallbackInterface is described in Rust as a trait, but uniffi
// generates a struct implementing the trait and passes the concrete version
// of that.
// This really just reflects the fact that CallbackInterface and Object
// should be merged; we'd still need a way to ask for a struct delegating to
// foreign implementations be done.
// But currently they are passed as a concrete type with no associated types.
method.trait_name = object_name.to_string();
method.index = index as u32;
ci.items.insert(method.into());
}
_ => bail!(
"no support for callback interface member type {:?} yet",
member
),
}
}
Ok(CallbackInterfaceMetadata {
module_path: ci.module_path(),
name: object_name.to_string(),
docstring: self.docstring.as_ref().map(|v| convert_docstring(&v.0)),
})
}