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

Include advertised version in BindError::UnsupportVersion #671

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
18 changes: 6 additions & 12 deletions wayland-client/src/globals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,20 +155,14 @@
let (name, version) = guard
.iter()
// Find the with the correct interface
.filter_map(|Global { name, interface: interface_name, version }| {
// TODO: then_some
if interface.name == &interface_name[..] {
Some((*name, *version))
} else {
None
}
.find_map(|Global { name, interface: interface_name, version }| {
(interface.name == &interface_name[..]).then_some((*name, *version))
})
.next()
.ok_or(BindError::NotPresent)?;

// Test version requirements
if version < version_start {
return Err(BindError::UnsupportedVersion);
return Err(BindError::UnsupportedVersion(version));
}

// To get the version to bind, take the lower of the version advertised by the server and the maximum
Expand Down Expand Up @@ -232,7 +226,7 @@
#[derive(Debug)]
pub enum BindError {
/// The requested version of the global is not supported.
UnsupportedVersion,
UnsupportedVersion(u32),
Copy link
Member

@elinorbgr elinorbgr Nov 9, 2023

Choose a reason for hiding this comment

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

This is a breaking change, so please include a changelog entry for this


/// The requested global was not found in the registry.
NotPresent,
Expand All @@ -243,8 +237,8 @@
impl fmt::Display for BindError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
BindError::UnsupportedVersion {} => {
write!(f, "the requested version of the global is not supported")
BindError::UnsupportedVersion(version) => {
write!(f, "the available version {version} of the global is lower than the requested version")

Check warning on line 241 in wayland-client/src/globals.rs

View check run for this annotation

Codecov / codecov/patch

wayland-client/src/globals.rs#L240-L241

Added lines #L240 - L241 were not covered by tests
}
BindError::NotPresent {} => {
write!(f, "the requested global was not found in the registry")
Expand Down
Loading