Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prost Protobuf issues #6

Open
sleipnir opened this issue Sep 18, 2023 · 1 comment
Open

Prost Protobuf issues #6

sleipnir opened this issue Sep 18, 2023 · 1 comment

Comments

@sleipnir
Copy link
Member

Blocked by issues in the prost library regarding the Any message parser:

error[E0277]: the trait bound `Reply: prost::name::Name` is not satisfied
  --> spawn-examples/src/joe.rs:16:27
   |
16 |                 .response(&Reply::default())
   |                  -------- ^^^^^^^^^^^^^^^^^ the trait `prost::name::Name` is not implemented for `Reply`
   |                  |
   |                  required by a bound introduced by this call
   |
   = help: the following other types implement trait `prost::name::Name`:
             prost_types::Any
             prost_types::Duration
             prost_types::Timestamp
note: required by a bound in `spawn_rs::value::Value::response`
  --> /home/sleipnir/workspaces/eigr/eigr-labs/spawn-rust-sdk/spawn-rs/src/value.rs:34:12

Related to tokio-rs/prost#921 and tokio-rs/prost#923

@sleipnir
Copy link
Member Author

For now I created a workaround making the user enter the name of the fully qualified protobuf type:

pub fn set_language(msg: Message, ctx: Context) -> Value {
    info!("Actor msg: {:?}", msg);
    return match msg.body::<Request>() {
        Ok(request) => {
            let lang = request.language;
            info!("Setlanguage To: {:?}", lang);
            let mut reply = Reply::default();
            reply.response = lang;

            match &ctx.state::<State>() {
                Some(state) => Value::new()
                    .state::<State>(&state.as_ref().unwrap(), "domain.State".to_string()) // workaround here
                    .response(&reply, "domain.Reply".to_string())
                    .to_owned(),
                _ => Value::new()
                    .state::<State>(&State::default(), "domain.State".to_string()) // workaround here
                    .response(&reply, "domain.Reply".to_string())
                    .to_owned(),
            }
        }
        Err(_e) => Value::new()
            .state::<State>(&State::default(), "domain.State".to_string()) // workaround here
            .to_owned(),
    };
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant