Skip to content

Failed to deserialize #31

Closed
Closed
@MangriMen

Description

@MangriMen

Hello, i have this listener and get panic at deserializing.

LoadingPayload located is in separate project if it's important. And has all #derive that readme says.

    event_emitter.on("loading", move |payload: LoadingPayload| {
        let value = app.clone();
        async move {
            let app = value.clone();

            app.emit("loading", payload).unwrap();
            }
     });
thread 'tokio-runtime-worker' panicked at C:\Users\user\.cargo\registry\src\index.crates.io-6f17d22bba15001f\async-event-emitter-0.1.3\src\lib.rs:265:17:
 value can't be deserialized into type ....::...::...::LoadingPayload
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This place in your lib

            let value: T = bincode::deserialize(&bytes).unwrap_or_else(|_| {
                panic!(
                    " value can't be deserialized into type {}",
                    std::any::type_name::<T>()
                )
            });

LoadingPayload

#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)]
pub struct LoadingPayload {
    pub event: LoadingBarType,
    pub loader_uuid: Uuid,
    pub fraction: Option<f64>, // by convention, if optional, it means the loading is done
    pub message: String,
}

LoadingBarType

#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, Hash, PartialEq, Eq)]
#[serde(tag = "type")]
#[serde(rename_all = "snake_case")]
pub enum LoadingBarType {

UPD. I found this topic bincode-org/bincode#548. It says that bincode can't deserialize serde tagged enum. I will close issue, if you has some idea to deal with it i will be very glad

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions