fzyzcjy / flutter_rust_bridge

Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.

Home Page:https://fzyzcjy.github.io/flutter_rust_bridge/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uuid, Time(Utc) is not supported on SSE codec (but can use it by enabling the flag of DCO codec); AnyhowException has wrong code hints

Andrepuel opened this issue · comments

Describe the bug

Runtime error when trying to interact with Uuid, chrono::DateTime or anyhow::Result.

Steps to reproduce

use chrono::{DateTime, Utc};
use flutter_rust_bridge::frb;
use uuid::Uuid;

#[frb(init)]
pub fn init_app() {
    flutter_rust_bridge::setup_default_user_utils();
}

pub fn gen_uuid() -> Uuid {
    Uuid::new_v4()
}

pub fn get_now() -> DateTime<Utc> {
    Utc::now()
}

pub fn an_error() -> Result<(), anyhow::Error> {
    Err(anyhow::anyhow!("test"))
}

Logs

(adding the logs was hitting the char limit of github comment)

Expected behavior

No response

Generated binding code

impl SseDecode for flutter_rust_bridge::for_generated::anyhow::Error {
        // Codec=Sse (Serialization based), see doc to use other codecs
        fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
            unimplemented!("The type Delegate(AnyhowException) is not yet supported in serialized mode, please use full_dep mode, and feel free to create an issue");
        }
    }

    impl SseDecode for chrono::DateTime<chrono::Utc> {
        // Codec=Sse (Serialization based), see doc to use other codecs
        fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
            unimplemented!("The type Delegate(Time(Utc)) is not yet supported in serialized mode, please use full_dep mode, and feel free to create an issue");
        }
    }

    impl SseDecode for uuid::Uuid {
        // Codec=Sse (Serialization based), see doc to use other codecs
        fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
            unimplemented!("The type Delegate(Uuid) is not yet supported in serialized mode, please use full_dep mode, and feel free to create an issue");
        }
    }

OS

Linux

Version of flutter_rust_bridge_codegen

2.0.0-dev.21

Flutter info

No response

Version of clang++

No response

Additional context

I am guessing this is a known limitation of the version 2, as it is dev. But I didn't find a ticket tracking this.

Hi! Thanks for opening your first issue here! 😄

You are right, they are not yet in SSE codec. You can temporarily enable full_dep: true to use the DCO codec (but need to have LLVM installed just like in older version), and also feel free to PR! Alternatively, I may work on it in the next batch (hopefully within a few days)

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue.