Skip to content

add bisync crate for async support#33

Open
omelia-iliffe wants to merge 9 commits intorobohouse-delft:mainfrom
omelia-iliffe:async
Open

add bisync crate for async support#33
omelia-iliffe wants to merge 9 commits intorobohouse-delft:mainfrom
omelia-iliffe:async

Conversation

@omelia-iliffe
Copy link
Contributor

A (large) PR to add Async support via the bisync crate

A number of public types have moved do to needing to seperate the method calls (that need to be either async or sync) and the types they return (as you don't need special AsyncPing, AsyncResponse, ..etc types ).

I also removed some top level exports to try to separate the client and device systems more.

The bisync pattern looks like this

#[path = "."]
pub(crate) mod asynch {
	use crate::AsyncSerialPort as SerialPort;
	use bisync::asynchronous::*;
	mod bus;
	pub(crate) use bus::Bus;
}
#[path = "."]
pub(crate) mod sync {
	use crate::SerialPort;
	use bisync::synchronous::*;
	mod bus;
	pub(crate) use bus::Bus;
}

Instead of having one of these patterns at the top level I opted for multiple, one for Bus, Client, and Device.
The modules asynch and sync are not exported, rather opting for structs with an Async prefix (ie AsyncClient)
This make it clearer imo.

The pattern also requires the use of super alot which I imagine might get tricky to maintain. Import the wrong thing without super and it might break in a hard to understand way.

Otherwise, it's great! I'm using it at the moment with embassy on the esp32 and enjoying it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant