atspi_common/
cache.rs
1use crate::{Accessible, InterfaceSet, Role, StateSet};
5use serde::{Deserialize, Serialize};
6use zvariant::Type;
7
8#[allow(clippy::module_name_repetitions)]
10#[derive(Clone, Debug, Serialize, Deserialize, Type, PartialEq, Eq, Hash)]
11pub struct CacheItem {
12 pub object: Accessible,
14 pub app: Accessible,
16 pub parent: Accessible,
18 pub index: i32,
20 pub children: i32,
22 pub ifaces: InterfaceSet,
24 pub short_name: String,
26 pub role: Role,
28 pub name: String,
30 pub states: StateSet,
32}
33impl Default for CacheItem {
34 fn default() -> Self {
35 Self {
36 object: Accessible {
37 name: ":0.0".into(),
38 path: "/org/a11y/atspi/accessible/object".try_into().unwrap(),
39 },
40 app: Accessible {
41 name: ":0.0".into(),
42 path: "/org/a11y/atspi/accessible/application".try_into().unwrap(),
43 },
44 parent: Accessible {
45 name: ":0.0".into(),
46 path: "/org/a11y/atspi/accessible/parent".try_into().unwrap(),
47 },
48 index: 0,
49 children: 0,
50 ifaces: InterfaceSet::empty(),
51 short_name: String::default(),
52 role: Role::Invalid,
53 name: String::default(),
54 states: StateSet::empty(),
55 }
56 }
57}
58
59#[test]
60fn zvariant_type_signature_of_cache_item() {
61 assert_eq!(
62 CacheItem::signature(),
63 zbus::zvariant::Signature::from_static_str("((so)(so)(so)iiassusau)").unwrap()
64 );
65}
66
67#[allow(clippy::module_name_repetitions)]
69#[derive(Clone, Debug, Serialize, Deserialize, Type, PartialEq, Eq, Hash)]
70pub struct LegacyCacheItem {
71 pub object: Accessible,
73 pub app: Accessible,
75 pub parent: Accessible,
77 pub children: Vec<Accessible>,
79 pub ifaces: InterfaceSet,
81 pub short_name: String,
83 pub role: Role,
85 pub name: String,
87 pub states: StateSet,
89}
90impl Default for LegacyCacheItem {
91 fn default() -> Self {
92 Self {
93 object: Accessible {
94 name: ":0.0".into(),
95 path: "/org/a11y/atspi/accessible/object".try_into().unwrap(),
96 },
97 app: Accessible {
98 name: ":0.0".into(),
99 path: "/org/a11y/atspi/accessible/application".try_into().unwrap(),
100 },
101 parent: Accessible {
102 name: ":0.0".into(),
103 path: "/org/a11y/atspi/accessible/parent".try_into().unwrap(),
104 },
105 children: Vec::new(),
106 ifaces: InterfaceSet::empty(),
107 short_name: String::default(),
108 role: Role::Invalid,
109 name: String::default(),
110 states: StateSet::empty(),
111 }
112 }
113}
114
115#[test]
116fn zvariant_type_signature_of_legacy_cache_item() {
117 assert_eq!(
118 LegacyCacheItem::signature(),
119 zbus::zvariant::Signature::from_static_str("((so)(so)(so)a(so)assusau)").unwrap()
120 );
121}