-
Notifications
You must be signed in to change notification settings - Fork 80
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
Support for Spray #72
Comments
After some random searching, perhaps you can try something like this:
Haven't tried it and it's by very definition unsafe, however every ScalaBuff case class comes with a no-arg constructor (every parameter is optional) so in theory this should never throw an Exception. If you pass in a Message that doesn't have a no-arg constructor, it will throw an InstantiationException. Also, there's probably a cleaner way to do this - but I hope it's a good start. :) |
That works if you have a Class[T], but I don't think you do with Spray's Unmarshaller. However I'm guessing it's better to do it this way, with a direct parseFrom method call on the object of type T instead of instantiating the whole class. I'm not sure about the exact semantics though since the companion object is a, well, object. |
I am trying to use ScalaBuff in a Spray application. The marshalling of messages to Protobuf works like a charm using ScalaBuff:
This is generic and works for all messages generated by ScalaBuff.
I am, however, not sure how to get unmarshalling:
In this method, I somehow need to call
T
'sparseFrom
method.Does ScalaBuff provide a way to achieve this?
Note: I also posted this question in the Spray User Group.
The text was updated successfully, but these errors were encountered: