proton_power_monitor

Native power and idle state queries for MoonBit on Windows, Linux, and macOS.

power-monitor
native
windows
linux
macos
power-management
moon add moonbit-community/proton_power_monitor@0.2.1
Download zip
Version
0.2.1
License
Apache-2.0
Last updated
7 hours ago
Downloads
19
README

#proton_power_monitor

Native power and idle state queries for MoonBit on Windows, Linux, and macOS.

#
PowerMonitorError

pub(all) suberror PowerMonitorError {
BackendUnavailable(detail~ : String)
OperationFailed(operation~ : String, detail~ : String)
} derive(Eq)

#
PowerMonitorError::equal

#
PowerMonitorError::not_equal

fn PowerMonitorError::not_equal(x : PowerMonitorError, y : PowerMonitorError) -> Bool

#
PowerMonitorError::output

fn PowerMonitorError::output(self : PowerMonitorError, logger : &Logger) -> Unit

#
PowerMonitorError::to_string

fn PowerMonitorError::to_string(self : PowerMonitorError) -> String

#
PowerMonitor

pub struct PowerMonitor {
// private fields
}

#
PowerMonitor::destroy

fn PowerMonitor::destroy(self : PowerMonitor) -> Unit

#
PowerMonitor::drain_events

fn PowerMonitor::drain_events(self : PowerMonitor) -> Array[PowerMonitorEvent]

Drains every pending event from the queue. Returns an empty array when no event is pending; never raises for an empty queue.

#
PowerMonitor::idle_seconds

fn PowerMonitor::idle_seconds(self : PowerMonitor) -> Int raise PowerMonitorError

#
PowerMonitor::new

#
PowerMonitor::power_source

#
PowerMonitor::start_watching

fn PowerMonitor::start_watching(self : PowerMonitor) -> Unit raise PowerMonitorError

Starts the event watch backend. The backend is best-effort: a platform that cannot watch (for example Linux without a system D-Bus) records the failure on the native side and returns BackendUnavailable, leaving polling queries fully usable.

#
PowerMonitor::stop_watching

fn PowerMonitor::stop_watching(self : PowerMonitor) -> Unit raise PowerMonitorError

Stops the event watch backend and joins its thread. Idempotent.

#
PowerMonitorEvent

pub enum PowerMonitorEvent {
Suspend
Resume
OnAC
OnBattery
LockScreen
UnlockScreen
} derive(Eq,
Debug
)

System power and session events delivered by the watch backend.

#
PowerMonitorEvent::equal

#
PowerMonitorEvent::not_equal

fn PowerMonitorEvent::not_equal(x : PowerMonitorEvent, y : PowerMonitorEvent) -> Bool

#
PowerSource

pub(all) enum PowerSource {
Unknown
AC
Battery
} derive(Eq,
Debug
)

#
PowerSource::equal

fn PowerSource::equal(PowerSource, PowerSource) -> Bool

#
PowerSource::not_equal

fn PowerSource::not_equal(x : PowerSource, y : PowerSource) -> Bool

#
PowerSourceInfo

pub(all) struct PowerSourceInfo {
source : PowerSource
battery_percent : Int?
} derive(Eq,
Debug
)

#
PowerSourceInfo::equal

#
PowerSourceInfo::not_equal

fn PowerSourceInfo::not_equal(x : PowerSourceInfo, y : PowerSourceInfo) -> Bool

#
State

pub type State

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io