Skip to main content

servo_wakelock/
lib.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5//! Platform abstraction for the Screen Wake Lock API.
6//!
7//! Defines [`WakeLockDelegate`], a trait for acquiring and releasing OS-level
8//! wake locks. Platform-specific implementations will be added in follow-up
9//! work. For now, [`DefaultWakeLockDelegate`] is the only implementation and
10//! does nothing.
11//!
12//! <https://w3c.github.io/screen-wake-lock/>
13use std::error::Error;
14
15use embedder_traits::{WakeLockDelegate, WakeLockType};
16
17/// A no-op [`WakeLockDelegate`] used when no platform implementation is
18/// available. All operations succeed silently.
19pub struct DefaultWakeLockDelegate;
20
21impl WakeLockDelegate for DefaultWakeLockDelegate {
22    fn acquire(&self, _type_: WakeLockType) -> Result<(), Box<dyn Error>> {
23        Ok(())
24    }
25
26    fn release(&self, _type_: WakeLockType) -> Result<(), Box<dyn Error>> {
27        Ok(())
28    }
29}