Struct thermal_config::ThermalConfig
source · pub struct ThermalConfig { /* private fields */ }
Expand description
This library is used to parse a thermal configuration JSON file into a data structure which also implements some convenience methods for accessing and consuming the data.
The intended usage is that ThermalConfig::read()
is called with a thermal configuration JSON
file path. If successful, the function returns a ThermalConfig instance containing the parsed
config data.
The parser expects a JSON5 file of the following format: { clients: { audio: [ { state: 1, trip_points: [ { sensor_name: ‘CPU thermal’, activate_at: 75, deactivate_below: 71, }, ], }, { state: 2, trip_points: [ { sensor_name: ‘CPU thermal’, activate_at: 86, deactivate_below: 82, }, ], }, ], }, } Represents the top level of a thermal configuration structure.
Implementations§
source§impl ThermalConfig
impl ThermalConfig
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new, empty ThermalConfig instance.
An empty ThermalConfig instance corresponds to the case where no client has specified a thermal trip point configuration.
Note: this is only intended for use in tests. However, it isn’t marked as cfg(test) so that code outside of the library can use it in their tests as well.
sourcepub fn read(json_file_path: &Path) -> Result<ThermalConfig, Error>
pub fn read(json_file_path: &Path) -> Result<ThermalConfig, Error>
Read the supplied JSON file path and parse into a ThermalConfig instance.
Attempts to open, read, and parse the supplied JSON file into a valid ThermalConfig instance. If a ThermalConfig instance could be created with the JSON configuration, then it is also tested for validity. If a ThermalConfig instance could not be created, or validation fails, then an error is returned.
sourcepub fn add_client_config(self, client: &str, config: ClientConfig) -> Self
pub fn add_client_config(self, client: &str, config: ClientConfig) -> Self
Adds a configuration entry for the specified client.
Note: this is only intended for use in tests. However, it isn’t marked as cfg(test) so that code outside of the library can use it in their tests as well.
sourcepub fn get_client_config(&self, client: &String) -> Option<&ClientConfig>
pub fn get_client_config(&self, client: &String) -> Option<&ClientConfig>
Gets the ClientConfig instance for the specified client.