Skip to main content

Crate win_nightlight_watch

Crate win_nightlight_watch 

Source
Expand description

Observe Night Light changes and read decoded snapshots.

Create one Watcher for settings and one for state as needed. Read each initial snapshot with Watcher::read_current after constructing it. Successful notification consumption rearms before reading. Snapshots reflect the later read, and notifications can combine writes or produce duplicates.

The watcher does not start a thread or write registry values. This crate supports Windows only. Fallible operations return an Error; public operations do not panic.

§Example

use std::time::Duration;
use win_nightlight_watch::Snapshot;
use win_nightlight_watch::Watcher;

fn observe(mut changed: impl FnMut(Snapshot)) -> Result<(), Box<dyn std::error::Error>> {
    let watcher = Watcher::settings()?;
    changed(watcher.read_current()?);

    loop {
        if let Some(snapshot) = watcher.wait_timeout(Duration::from_secs(60))? {
            changed(snapshot);
        }
    }
}

Structs§

Error
Report a watcher failure and preserve its underlying error.
Watcher
Observe one Night Light record without a background thread.

Enums§

ErrorKind
Classify a watcher failure.
Snapshot
Store a decoded observation of one Night Light registry value.

Type Aliases§

Result
Result of a registry watcher operation.