jhugman / uniffi-bindgen-react-native

A uniffi bindings generator for calling Rust from react-native
https://jhugman.github.io/uniffi-bindgen-react-native/
Other
52 stars 6 forks source link

Migrate from askama to rinja #155

Open Johennes opened 2 weeks ago

Johennes commented 2 weeks ago

Fixes: #150

I started working on this before realizing it'll first require a new release of uniffi-rs. So leaving this here as a draft to be picked up again later.

jhugman commented 2 weeks ago

I started working on this before realizing it'll first require a new release of uniffi-rs. So leaving this here as a draft to be picked up again later.

I don't think this relies on uniffi-rs, but there maybe some more self:: and borrows to add to the templates. Would @GuillaumeGomez be able to help here?

Johennes commented 2 weeks ago

I haven't dug deeply but this error looked as if it was still pulling in askama (even though its not a direct dependency anymore) and the only crate that appears to do it was from uniffi-rs.

115 | #[derive(Template)]
    |                 ^ the trait `From<askama::error::Error>` is not implemented for `bindings::_::rinja::Error`, which is required by `Result<(), bindings::_::rinja::Error>: FromResidual<Result<Infallible, askama::error::Error>>`

Maybe that error is just a surrogate though?

GuillaumeGomez commented 2 weeks ago

That's strange. Unless you still have askama in your dependency tree, you should never see askama anywhere as rinja doesn't depend on it (directly or indirectly).

Johennes commented 2 weeks ago

Poking at it a little, the build fails on a number of statements in the templates, for instance:

{%- let obj = ci|get_object_definition(name) %}

If I'm reading things correctly, that function bubbles up into lookup_error which results in askama::Error in the versions of the uniffi-rs crates that we're using and was changed to rinja::Error in the merged yet unreleased pull request that migrated uniffi-rs to rinja.

GuillaumeGomez commented 2 weeks ago

Ah then until you use the latest version, I suppose you'll have the issue.