Skip to content
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

Add lazy, cheaply guarded proxy-conversions. #202

Merged
merged 5 commits into from
Jan 2, 2025

Conversation

luukvanderduim
Copy link
Collaborator

This introduces lazy and cheaply guarded proxy-conversions.

It adds ObjectProxies which extends `AccessibleProxy

We have an easy conversion from ObjectRef to AccessibleProxy

AccessibleProxy::get_interfaces gives insight into which interfaces are unokenebted by the object.

ObjectProxies::proxies returns Proxies, a struct that can contain zero or more proxies to the objects supported interfaces.

The proxies are created only when needed and the check against the InterfaceSet is a cheap bitwise operation.

// Provided by `ObjectRefExt`
let accessible = obj.as_accessible_proxy();

// Provided by `ObjectProxies` extending `AccessibleProxy`
// Aqcuiring `Proxies` needs to be async to get supported interfaces.
let proxies = accessible.proxies().await?;

{
    let action = proxies.action()?; // init and return &mut `ActionProxy`
    let text = proxies.text()?;
}

let action = proxies.action()?; // already initialized! Return   

Copy link

codecov bot commented Jun 27, 2024

Codecov Report

Attention: Patch coverage is 2.04082% with 144 lines in your changes missing coverage. Please review.

Project coverage is 82.14%. Comparing base (a92b8f6) to head (4c59c24).
Report is 12 commits behind head on main.

Files with missing lines Patch % Lines
atspi-proxies/src/proxy_ext.rs 0.00% 141 Missing ⚠️
atspi-common/src/error.rs 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #202      +/-   ##
==========================================
- Coverage   83.87%   82.14%   -1.73%     
==========================================
  Files          43       44       +1     
  Lines        3231     3299      +68     
==========================================
  Hits         2710     2710              
- Misses        521      589      +68     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@TTWNO TTWNO force-pushed the object-proxies-guardeed-lazy-conversions branch from efbff96 to 5fb3c28 Compare November 23, 2024 15:49
@TTWNO
Copy link
Member

TTWNO commented Nov 23, 2024

Rebased

///
/// Proxies are lazily initialized, so they are only created when requested.
/// Interface availability is checked before creating the proxy and is a cheap bitop.
pub trait ObjectProxies<'a> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd appreciate something like ProxyExt or something like that. Thoughts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't naming supposed to be the hardest thing in software engineering?
ProxyExt sounds just fine.

}
}

impl<'a> Proxies<'a> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation is good.

@TTWNO TTWNO marked this pull request as ready for review December 30, 2024 23:00
@TTWNO
Copy link
Member

TTWNO commented Dec 30, 2024

@luukvanderduim are you okay with merging this?

@TTWNO TTWNO merged commit 0a4a49d into main Jan 2, 2025
12 of 14 checks passed
@TTWNO TTWNO deleted the object-proxies-guardeed-lazy-conversions branch January 2, 2025 19:25
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.

2 participants