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

zbus 4.0 port #155

Merged
merged 17 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
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
41 changes: 17 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ on:
branches:
- main
jobs:
find-msrv:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.step2.outputs.version }}
steps:
- uses: actions/checkout@v4
- id: step2
run: echo "version=`cat Cargo.toml | sed -n 's/rust-version = "\(.*\)"/\1/p'`" >> "$GITHUB_OUTPUT"
benchmarks:
runs-on: ubuntu-latest
needs: [clippy,no-unused-dependencies]
Expand All @@ -28,8 +36,10 @@ jobs:
key: ${{ runner.os }}-x86_64-unknown-linux-gnu-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-x86_64-unknown-linux-gnu-build-${{ env.cache-name }}-
- name: Run benchmarks
- name: Compile benchmarks (1k)
run: cargo bench --no-run --bench event_parsing
- name: Compile benchmarks (100k)
run: cargo bench --no-run --bench event_parsing_100k
clippy:
runs-on: ubuntu-latest
needs: [rustfmt,no-unused-dependencies,wasm-compatible-common-crate]
Expand Down Expand Up @@ -187,33 +197,16 @@ jobs:
run: cargo semver-checks check-release -p atspi --default-features
msrv-compliance:
runs-on: ubuntu-latest
needs: [clippy,no-unused-dependencies]
needs: [clippy,no-unused-dependencies,find-msrv]
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Cache cargo home
uses: actions/cache@v3
env:
cache-name: cache-cargo-home
with:
path: |
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
key: ${{ runner.os }}-x86_64-unknown-linux-gnu-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-x86_64-unknown-linux-gnu-build-${{ env.cache-name }}-
- name: Install Rust
- name: install stable toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Install Cargo MSRV Verifier
uses: taiki-e/install-action@main
with:
tool: cargo-msrv
toolchain: ${{ needs.find-msrv.outputs.version }}
- name: Git checkout
uses: actions/checkout@v3
- name: Check MSRV Compliance
run: cargo msrv --path atspi verify
run: cargo test --workspace --no-run --all-features
wasm-compatible-common-crate:
runs-on: ubuntu-latest
needs: [rustfmt]
Expand Down
7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
resolver = "2"
members = [
"atspi",
"atspi-proxies",
"atspi-common",
"atspi-connection",
"atspi-proxies"]
]


[workspace.package]
description = "AT-SPI2 protocol implementation in Rust"
Expand All @@ -15,9 +17,10 @@ authors = [
"DataTriny <datatriny@gmail.com>",
"Luuk van der Duim <luukvanderduim@gmail.com>"
]
rust-version = "1.75.0"

[workspace.dependencies]
zbus = { version = "3.12.0", default-features = false }
zbus = { version = "4.0", default-features = false }
tracing = "0.1.37"
enumflags2 = "0.7.7"

Expand Down
15 changes: 7 additions & 8 deletions atspi-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repository = "https://github.com/odilia-app/atspi"
description = "Primitive types used for sending and receiving Linux accessibility events."
license = "Apache-2.0 OR MIT"
include = ["src/**/*", "LICENSE-*", "README.md"]
rust-version = "1.68.2"
rust-version.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -22,18 +22,17 @@ tokio = ["zbus/tokio"]
enumflags2 = "0.7.7"
serde = "1.0"
static_assertions = "1.1.0"
zbus_names = "3.0"
zvariant = { version = "4.0", default-features = false }
zbus = { workspace = true, optional = true, default-features = false }
zbus_names = "2.5.0"
zvariant = { version = "3", default-features = false }

[dev-dependencies]
zbus = { workspace = true }
atspi-connection = { path = "../atspi-connection" }
atspi-proxies = { path = "../atspi-proxies" }
byteorder = "1.4.3"
tokio-stream = { version = "0.1", default-features = false, features = ["time"] }
tokio = { version = "1", default_features = false, features = ["macros", "rt-multi-thread"] }
rename-item = "0.1.0"
tokio-test = "0.4.2"
serde_plain = "1.0.1"
static_assertions = "1.1.0"
tokio = { version = "1", default-features = false, features = ["macros", "rt-multi-thread"] }
tokio-stream = { version = "0.1", default-features = false, features = ["time"] }
tokio-test = "0.4.2"
zbus = { workspace = true }
6 changes: 3 additions & 3 deletions atspi-common/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct CacheItem {
pub ifaces: InterfaceSet,
/// The short localized name. s
pub short_name: String,
/// ObjectRef role. u
/// `ObjectRef` role. u
pub role: Role,
/// More detailed localized name.
pub name: String,
Expand Down Expand Up @@ -76,11 +76,11 @@ pub struct LegacyCacheItem {
pub parent: ObjectRef,
/// List of references to the accessible's children. a(so)
pub children: Vec<ObjectRef>,
/// The exposed interfece(s) set. as
/// The exposed interface(s) set. as
pub ifaces: InterfaceSet,
/// The short localized name. s
pub short_name: String,
/// ObjectRef role. u
/// `ObjectRef` role. u
pub role: Role,
/// More detailed localized name.
pub name: String,
Expand Down
4 changes: 4 additions & 0 deletions atspi-common/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
/// No member on event.
MissingMember,

/// No Signature.
MissingSignature,

/// When matching on an unknown role
UnknownRole(u32),

Expand Down Expand Up @@ -82,6 +85,7 @@
Self::UnknownInterface => f.write_str("Unknown interface."),
Self::MissingInterface => f.write_str("Missing interface."),
Self::MissingMember => f.write_str("Missing member."),
Self::MissingSignature => f.write_str("Missing signature."),

Check warning on line 88 in atspi-common/src/error.rs

View check run for this annotation

Codecov / codecov/patch

atspi-common/src/error.rs#L88

Added line #L88 was not covered by tests
Self::UnknownRole(e) => f.write_str(&format!("atspi: Unknown role: {e}")),
Self::UnknownSignal => f.write_str("atspi: Unknown signal"),
Self::CacheVariantMismatch => f.write_str("atspi: Cache variant mismatch"),
Expand Down
17 changes: 9 additions & 8 deletions atspi-common/src/events/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
events::{EventBodyOwned, GenericEvent, HasMatchRule, HasRegistryEventString, ObjectRef},
Event,
};
use zvariant::ObjectPath;
use zvariant::{ObjectPath, OwnedValue};

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, Hash)]
pub enum DocumentEvents {
Expand Down Expand Up @@ -220,7 +220,8 @@ impl GenericEvent<'_> for PageChangedEvent {
impl TryFrom<&zbus::Message> for DocumentEvents {
type Error = AtspiError;
fn try_from(ev: &zbus::Message) -> Result<Self, Self::Error> {
let member = ev
let header = ev.header();
let member = header
.member()
.ok_or(AtspiError::MemberMatch("Event without member".into()))?;
match member.as_str() {
Expand Down Expand Up @@ -257,7 +258,7 @@ impl From<LoadCompleteEvent> for EventBodyOwned {
kind: String::default(),
detail1: i32::default(),
detail2: i32::default(),
any_data: zvariant::Value::U8(0).into(),
any_data: OwnedValue::from(0u8),
}
}
}
Expand All @@ -280,7 +281,7 @@ impl From<ReloadEvent> for EventBodyOwned {
kind: String::default(),
detail1: i32::default(),
detail2: i32::default(),
any_data: zvariant::Value::U8(0).into(),
any_data: OwnedValue::from(0u8),
}
}
}
Expand All @@ -307,7 +308,7 @@ impl From<LoadStoppedEvent> for EventBodyOwned {
kind: String::default(),
detail1: i32::default(),
detail2: i32::default(),
any_data: zvariant::Value::U8(0).into(),
any_data: OwnedValue::from(0u8),
}
}
}
Expand All @@ -334,7 +335,7 @@ impl From<ContentChangedEvent> for EventBodyOwned {
kind: String::default(),
detail1: i32::default(),
detail2: i32::default(),
any_data: zvariant::Value::U8(0).into(),
any_data: OwnedValue::from(0u8),
}
}
}
Expand All @@ -361,7 +362,7 @@ impl From<AttributesChangedEvent> for EventBodyOwned {
kind: String::default(),
detail1: i32::default(),
detail2: i32::default(),
any_data: zvariant::Value::U8(0).into(),
any_data: OwnedValue::from(0u8),
}
}
}
Expand All @@ -388,7 +389,7 @@ impl From<PageChangedEvent> for EventBodyOwned {
kind: String::default(),
detail1: i32::default(),
detail2: i32::default(),
any_data: zvariant::Value::U8(0).into(),
any_data: OwnedValue::from(0u8),
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions atspi-common/src/events/focus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
events::{EventBodyOwned, GenericEvent, HasMatchRule, HasRegistryEventString, ObjectRef},
Event,
};
use zvariant::ObjectPath;
use zvariant::{ObjectPath, OwnedValue};

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, Hash)]
pub enum FocusEvents {
Expand Down Expand Up @@ -54,7 +54,8 @@ impl GenericEvent<'_> for FocusEvent {
impl TryFrom<&zbus::Message> for FocusEvents {
type Error = AtspiError;
fn try_from(ev: &zbus::Message) -> Result<Self, Self::Error> {
let member = ev
let header = ev.header();
let member = header
.member()
.ok_or(AtspiError::MemberMatch("Event without member".into()))?;
match member.as_str() {
Expand All @@ -78,7 +79,7 @@ impl From<FocusEvent> for EventBodyOwned {
kind: String::default(),
detail1: i32::default(),
detail2: i32::default(),
any_data: zvariant::Value::U8(0).into(),
any_data: OwnedValue::from(0u8),
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions atspi-common/src/events/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
events::{EventBodyOwned, GenericEvent, HasMatchRule, HasRegistryEventString, ObjectRef},
Event,
};
use zvariant::ObjectPath;
use zvariant::{ObjectPath, OwnedValue};

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, Hash)]
pub enum KeyboardEvents {
Expand Down Expand Up @@ -57,7 +57,8 @@ impl GenericEvent<'_> for ModifiersEvent {
impl TryFrom<&zbus::Message> for KeyboardEvents {
type Error = AtspiError;
fn try_from(ev: &zbus::Message) -> Result<Self, Self::Error> {
let member = ev
let header = ev.header();
let member = header
.member()
.ok_or(AtspiError::MemberMatch("Event without member".into()))?;
match member.as_str() {
Expand Down Expand Up @@ -89,7 +90,7 @@ impl From<ModifiersEvent> for EventBodyOwned {
kind: String::default(),
detail1: event.previous_modifiers,
detail2: event.current_modifiers,
any_data: zvariant::Value::U8(0).into(),
any_data: OwnedValue::from(0u8),
}
}
}
Expand Down
Loading
Loading