pub struct SystemPowerModeConfig { /* private fields */ }
Expand description
This library is used to parse a system power mode configuration JSON file into a data structure which also implements some convenience methods for accessing and consuming the data.
The intended usage is that SystemPowerModeConfig::read()
is called with the path to a system
power mode configuration JSON file. If successful, the function returns a
SystemPowerModeConfig
instance containing the parsed configuration.
The parser expects a a valid JSON5 serialization of SystemPowerModeConfig
, such as the
following:
{
clients: {
wlan: {
mode_matches: [
{
mode: 'battery_saver',
level: 0,
},
],
default_level: 1,
},
},
}
Represents the top level of a system power mode configuration.
This struct wraps the contents of a system power mode configuration file. All of the types
contained within this top level struct are defined in the fuchsia.power.clientlevel
and
fuchsia.power.systemmode
libraries.
Implementations§
Source§impl SystemPowerModeConfig
impl SystemPowerModeConfig
Sourcepub fn read(json_file_path: &Path) -> Result<SystemPowerModeConfig, Error>
pub fn read(json_file_path: &Path) -> Result<SystemPowerModeConfig, Error>
Reads the supplied JSON file path and parses into a SystemPowerModeConfig
instance.
Attempts to open, read, and parse the supplied JSON file into a valid
SystemPowerModeConfig
instance. If parsing was successful, then it is also tested for
validity. If a SystemPowerModeConfig
instance could not be created, or validation fails,
then an error is returned.
Sourcepub fn get_client_config(
&self,
client_type: ClientType,
) -> Option<&ClientConfig>
pub fn get_client_config( &self, client_type: ClientType, ) -> Option<&ClientConfig>
Gets the ClientConfig
instance for the specified client.
pub fn into_iter(self) -> impl Iterator<Item = (ClientType, ClientConfig)>
Trait Implementations§
Source§impl Debug for SystemPowerModeConfig
impl Debug for SystemPowerModeConfig
Source§impl PartialEq for SystemPowerModeConfig
impl PartialEq for SystemPowerModeConfig
Source§impl SystemPowerModeConfigTestExt for SystemPowerModeConfig
impl SystemPowerModeConfigTestExt for SystemPowerModeConfig
Source§fn add_client_config(
self,
client_type: ClientType,
config: ClientConfig,
) -> Self
fn add_client_config( self, client_type: ClientType, config: ClientConfig, ) -> Self
Adds a configuration entry for the specified client.