Skip to main content

wayle_core/
lib.rs

1//! Reactive state for Wayle services. Wrap a value in [`Property<T>`]
2//! and consumers can `.get()` it or `.watch()` for a stream of changes.
3//!
4//! ```rust,no_run
5//! use wayle_core::Property;
6//! use futures::stream::StreamExt;
7//!
8//! # async fn example() {
9//! let brightness = Property::new(75u32);
10//! brightness.set(100);
11//!
12//! let mut changes = brightness.watch();
13//! while let Some(level) = changes.next().await {
14//!     println!("{level}");
15//! }
16//! # }
17//! ```
18//!
19//! Also includes D-Bus macros (`unwrap_*!`, `watch_all!`) for extracting
20//! properties with type-safe defaults.
21//!
22//! Enable `schema` for [`schemars::JsonSchema`] support on `Property<T>`.
23
24#[macro_use]
25mod macros;
26/// XDG Base Directory path resolution.
27pub mod paths;
28mod property;
29
30use std::sync::Arc;
31
32pub use property::{Property, PropertyStream};
33
34/// A [`Property`] holding a service that initializes in the background.
35/// Starts `None`, becomes `Some` once the service is ready.
36pub type DeferredService<T> = Property<Option<Arc<T>>>;
37
38/// D-Bus root object path.
39pub const ROOT_PATH: &str = "/";
40
41/// D-Bus null object path (no associated object).
42pub const NULL_PATH: &str = "/";
43
44#[doc = include_str!("../README.md")]
45#[cfg(doctest)]
46pub struct ReadmeDocTests;