tock / libtock-rs

Rust userland library for Tock
Apache License 2.0
163 stars 109 forks source link

platform: subscribe: add return code variants #487

Closed bradjc closed 1 year ago

bradjc commented 1 year ago

One convention in Tock is that the first argument of an upcall is a return code. A return code is an ErrorCode but 0 means Success.

This makes it possible to write a subscribe callback like:

let called: Cell<Option<Result<(), ErrorCode>>> = Cell::new(None);
let called: Cell<Option<Result<(u32,), ErrorCode>>> = Cell::new(None);
let called: Cell<Option<Result<(u32, u32), ErrorCode>>> = Cell::new(None);

My implementation of converting a u32 to an errorcode is functional but not great, any ideas on what that should look like?