jamesmunns / postcard-rpc

An RPC layer for postcard based protocols
Apache License 2.0
48 stars 11 forks source link

host_server and target_client libraries #37

Open t-moe opened 1 week ago

t-moe commented 1 week ago

I would be nice to have "host_server" and "target_client" libraries of postcard-rpc. So the MCU would be the one initiating the request to the PC and the PC would answer the rpc calls. Everything else would be the same.

I asked @jamesmunns via Matrix regarding this, here are his responses:

So: postcard doesn't have code for this yet. The protocol has nothing special that forces it to be the orientation it is, that's just how I normally set it up. I'm very open to having "host_server" and "target_client" libraries: at least the latter I will also want for MCU-to-MCU comms, but I don't have any plan to build it right now.

I also asked about whether there are some big roadblocks in the way, and James responded with:

nah, there's sort of practical limitations maybe, depending on what route you go:

  • honestly the host_client code might be possible to just support with alloc, you might be better off with a different channel (tokio channel is used, could be cfg'd to something else), but it's really not THAT heavy, though I'm not sure how much "slack" you have wrt RAM usage on your current app
  • if you want to make a much lighter client that can only support one "in-flight" request at a time, that'd probably make it much easier to handle no_std, but would be more "novel" work
  • for the PC server, it'd probably be pretty easy to make a dispatcher that takes like HashMap<Endpoint, fn() -> Box<dyn Future<Output = Result<Vec, Something>>>, as a dispatcher

I'm currently a bit on a tight schedule with my current client, so I opted for implementing my own very simple rpc logic on top of postcard for now, as this was just quicker to do. But I'll probably revisit this postcard-rpc as soon as our rpc interface grows larger...

jamesmunns commented 1 week ago

Just noting that I am open to PRs here, feel free to @ me if anyone has any questions, or would like to pick up the work.