-
Notifications
You must be signed in to change notification settings - Fork 5
API rework #86
Description
When I saw the Arduino API, I thought of having the same here in Rust. I think that could be possible.
The main thoughts were on how we subscribe to data and how we set up a Node.
For the first point, I think of subscribing on the Node rather on the session manager. To do it like this, the startup process of the Node should be explicit. I think of something like the rocket crate does in a smaller fashion. This should indicate when the Node is in config state and when it can be used to receive and transmit messages.
I don't know if this would restrict, when to subscribe. But I think for a realtime and deterministic application it would be great to do the subscription and this stuff at the beginning and then start up the node. Furthermore, it would add another generic parameter (maybe bad).
This pattern is often used in Rust:
trait State {}
struct Config;
struct Running;
impl State for Config {}
impl State for Running {}
struct Node<S: State> {
_state: PhantomData<S>
}
impl Node<Config> {
fn start() -> Node_<Running> {}
}Pros:
- well-structured configuration of node (big pro)
- all calls are made to the node (subscribe)
Cons:
- another generic
- restricts when to subscribe (loosen restriction by adding a possibility to go back to config state)
Thoughts?