Skip to content

Add object safe APIs to the adapters #563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions platforms/macos/src/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,25 @@ impl Adapter {
Self { state }
}

/// Check if the adapter is currently active.
pub fn active(&self) -> bool {
match self.state {
State::Inactive { .. } => false,
_ => true,
}
}

/// If the tree has been initialized, apply the given TreeUpdate. Note: If
/// the caller's implementation of [`ActivationHandler::request_initial_tree`]
/// initially returned `None`, the [`TreeUpdate`] returned by the provided function
/// must contain a full tree.
///
/// If a [`QueuedEvents`] instance is returned, the caller must call
/// [`QueuedEvents::raise`] on it.
pub fn update(&mut self, update: TreeUpdate) -> Option<QueuedEvents> {
self.update_if_active(|| update)
}

/// If and only if the tree has been initialized, call the provided function
/// and apply the resulting update. Note: If the caller's implementation of
/// [`ActivationHandler::request_initial_tree`] initially returned `None`,
Expand Down