-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Labels
enhancementNew feature or requestNew feature or request
Description
High-level ideas:
- Now that
async/.awaitis stable, wcrs should be natively async - Event loop integration: it should not fork or spawn threads behind your back
- Less allocations, less
RefCells
Watching the socket requires a reactor; there should be implementations for Tokio and async-std, togglable with a cfg flag.
I imagine the high-level API could look somewhat like this:
struct ConnectResult {
connection: Connection,
// Spawn this task on your executor.
task: impl Future<Output = ()>,
}
impl Connection {
/// Establish a new connection to the compositor.
///
/// Returns the connection and a task to spawn, the task
/// takes care of watching and dispatching Wayland events
/// on the connection's internal socket.
pub async fn connect() -> Result<ConnectResult>;
/// Wrap an existing Wayland connection, which should be
/// dispatched by someone else. Use this if you already use
/// Wayland in your program for something else.
pub async fn with_display(display: &wayland_client::Display) -> Result<Connection>;
// Convenience wrapper over `.set_source(Source::simple())`
pub fn set(&mut self, content: impl AsyncRead, mime_type: MimeType);
pub fn set_source(&mut self, source: Source);
// Convenience wrapper over `current_offer().read()`
pub fn get(&mut self, mime_type: MimeType) -> impl AsyncRead;
pub fn current_offer(&self) -> Option<Offer>;
pub fn offers(&self) -> impl Stream<Item = Offer>;
}
impl Source {
pub fn simple(content: impl AsyncRead, mime_type: MimeType) -> Source;
pub fn new(content_options: &[(MimeType, impl AsyncWrite)]) -> Source;
}
impl Offer {
pub fn available_types(&self) -> impl Iterator<Item = MimeType>;
pub fn read(&mut self, mime_type: MimeType) -> impl AsyncRead;
}There would be probably some "options" args here and there to set things like which clipboard and seats to use.
Naming and details are of course subject to bikeshedding.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request