thermal_config

Struct 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

Source

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.

Source

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.

Source

pub fn validate(&self) -> Result<(), Error>

Validates the thermal configuration.

Source

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.

Source

pub fn get_client_config(&self, client: &String) -> Option<&ClientConfig>

Gets the ClientConfig instance for the specified client.

Source

pub fn into_iter(self) -> impl Iterator<Item = (String, ClientConfig)>

Trait Implementations§

Source§

impl Debug for ThermalConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ThermalConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,