alexa_rust icon indicating copy to clipboard operation
alexa_rust copied to clipboard

Response struct fields are all private, making response structs difficult to inspect and test

Open MikeFHay opened this issue 2 years ago • 0 comments

Thanks for the library. I'm new to Rust so forgive me if I'm missing something.

All the fields for all of the structs in response.rs are private, and none of the structs derive Eq or PartialEq. This makes it difficult to test functions that return Responses, e.g. attempting to test your example hello world function:

assert_eq!(Response::simple("hello", "hello world"), handle_hello().unwrap())

Fails with "error[E0369]: binary operation == cannot be applied to type alexa_sdk::Response"

and

assert_eq!("hello world", &handle_hello().unwrap().body.output_speech.unwrap().text.unwrap());

fails with "error[E0616]: field body of struct alexa_sdk::Response is private".

Since all of these structs are expected to be constructed by the user code, and are directly serialized into stable Alexa API response types. I would expect the fields to be public. It would also be a nice convenience if they derived Eq.

MikeFHay avatar Jul 04 '22 22:07 MikeFHay