stardust_xr_schemas/dbus/
interfaces.rs

1use crate::impl_queryable_for_proxy;
2use zbus::Result;
3
4#[zbus::proxy(interface = "org.stardustxr.SpatialRef")]
5pub trait SpatialRef {
6	#[zbus(property)]
7	/// Put this UID into `import_spatial``
8	fn uid(&self) -> Result<u64>;
9}
10
11#[zbus::proxy(interface = "org.stardustxr.FieldRef")]
12pub trait FieldRef {
13	#[zbus(property)]
14	/// Put this UID into `import_field``
15	fn uid(&self) -> Result<u64>;
16}
17
18#[zbus::proxy(
19	interface = "org.stardustxr.PlaySpace",
20	default_service = "org.stardustxr.PlaySpace",
21	default_path = "/org/stardustxr/PlaySpace"
22)]
23// this is associated with the `SpatialRef` at the same paath, all points are relative to it`
24pub trait PlaySpace {
25	#[zbus(property)]
26	fn bounds(&self) -> Result<Vec<(f64, f64)>>;
27	// #[zbus(property)]
28	// fn set_bounds(&self, bounds: Vec<(f64, f64)>) -> Result<()>;
29}
30
31#[zbus::proxy(interface = "org.stardustxr.Reparentable")]
32/// You need to implement at least SpatialRef but optionally FieldRef
33pub trait Reparentable {
34	/// Ask the reparentable to parent itself to the given SpatialRef
35	fn parent(&self, new_parent: u64) -> Result<()>;
36	/// Ask the reparentable to unparent itself from the given SpatialRef
37	fn unparent(&self) -> Result<()>;
38	/// Set the transform of the reparentable relative to the given SpatialRef to zero
39	fn reset_transform(&self, spatial_ref: u64) -> Result<()>;
40}
41#[zbus::proxy(interface = "org.stardustxr.ReparentLock")]
42/// You need to implement reparentable
43pub trait ReparentLock {
44	/// Ask to make it so nothing else can reparent this
45	fn lock(&self) -> Result<()>;
46	fn unlock(&self) -> Result<()>;
47}
48
49#[zbus::proxy(interface = "org.stardustxr.Destroy")]
50/// Destroy an object.
51/// Implement SpatialRef and/or FieldRef for spatial context.
52/// This trait might be implemented on the root to close the whole client or individual objects to delete.
53pub trait Destroy {
54	fn destroy(&self) -> Result<()>;
55}
56
57impl_queryable_for_proxy!(
58	SpatialRefProxy,
59	FieldRefProxy,
60	PlaySpaceProxy,
61	ReparentableProxy,
62	ReparentLockProxy,
63	DestroyProxy
64);