accesskit_unix/atspi/
object_address.rs
1use atspi::ObjectRef;
7use serde::{Deserialize, Serialize};
8use zbus::{
9 names::UniqueName,
10 zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Str, Type, Value},
11};
12
13const NULL_PATH: &str = "/org/a11y/atspi/null";
15
16#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, OwnedValue, Type, Value)]
17pub(crate) struct OwnedObjectAddress {
18 bus_name: String,
19 path: OwnedObjectPath,
20}
21
22impl OwnedObjectAddress {
23 pub(crate) fn new(bus_name: &UniqueName, path: OwnedObjectPath) -> Self {
24 Self {
25 bus_name: bus_name.to_string(),
26 path,
27 }
28 }
29
30 pub(crate) fn null() -> Self {
31 Self {
32 bus_name: String::new(),
33 path: ObjectPath::from_str_unchecked(NULL_PATH).into(),
34 }
35 }
36}
37
38impl From<ObjectRef> for OwnedObjectAddress {
39 fn from(object: ObjectRef) -> Self {
40 Self {
41 bus_name: Str::from(object.name).into(),
42 path: object.path,
43 }
44 }
45}