compio-rs / compio-rs/compio

RFC: hide `compio-driver` from the monocrate

Open
#945 0 comments 0 reactions 0 assignees View on GitHub
RFC
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.