permitio / fastapi_websocket_rpc

⚡ FASTAPI Websocket RPC- A fast and durable bidirectional JSON RPC channel over Websockets.
https://permit.io
MIT License
216 stars 25 forks source link

Binary Types: Any way to support it? #28

Closed realoriginal closed 1 year ago

realoriginal commented 1 year ago

Idiotic question, is there a suitable way I could achieve being able to support passing binary types to and from the RPC methods on client & server more easily rather than performing the type conversion myself with this library?

orweis commented 1 year ago

The arguments passed can be binary buffers. Not sure what you're looking for otherwise.

realoriginal commented 1 year ago

It appears as though if I have a method on the server set to say TLDR: async def my_method( self, my_type : bytes ) -> bytes - The my_type gets converted to a string ( even if passed as a 'bytes' type client side, and returning 'bytes' via the server returns it as a string to the client.

orweis commented 1 year ago

I see what you mean. The wire format is JSON so encoding as strings is pretty unavoidable. I guess you could potentially add code to check for bytes and do the casting internally, but it is tantamount to the same thing.

On Tue, Oct 24, 2023, 23:36 Austin Hudson @.***> wrote:

It appears as though if I have a method on the server set to say TLDR: async def my_method( self, my_type : bytes ) -> bytes - The my_type gets converted to a string ( even if passed as a 'bytes' type client side, and returning 'bytes' via the server returns it as a string to the client.

— Reply to this email directly, view it on GitHub https://github.com/permitio/fastapi_websocket_rpc/issues/28#issuecomment-1777996938, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAP3ULIJGCVYELODAE6VRRDYBARE3AVCNFSM6AAAAAA6OIUN2WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZXHE4TMOJTHA . You are receiving this because you commented.Message ID: @.***>

realoriginal commented 1 year ago

Fair enough. Thank you.