RFC: hide `compio-driver` from the monocrate
- Dominant language
- Rust
- Stars
- 1.9k
- Forks
- 133
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 20
Description
The crates `compio-runtime`, `compio-fs`, `compio-net`, and `compio-process` depends on the driver directly, while users usually don't. The low-level code breaks faster than the high-level one. I propose hiding the driver from the public interface of the monocrate.
A new trait will be introduced in `compio-driver`:
```rust
pub trait RuntimeExt {
fn with_driver(&self, f: impl FnOnce(&Proactor) -> R) -> R;
fn with_driver_mut(&self, f: impl FnOnce(&mut Proactor) -> R) -> R;
fn driver_type(&self) -> DriverType {
self.with_driver(|p| p.driver_type())
}
}
```
The types `Submit*` could even be decoupled from the runtime as they only depends on the proactor. If we want a complete decoupling, we could add a trait for `Proactor`.
`compio_runtime::Runtime` will implement `RuntimeExt`, but users will not be able to use it until they pull `compio-driver` in explicitly. Then it will be safe to introduce breaking changes to `compio-driver`, because the high-level APIs will depend on a different driver. `submit` methods will break, but it's because the user is trying to use a low-level `OpCode`, whose stability is not guarenteed by the high-level APIs.
Contributor guide
Assessment
This issue has not been assessed yet.