pub struct Table(/* private fields */);
Expand description
CPU frequency table.
Rust abstraction for the C struct cpufreq_frequency_table
.
§Invariants
A Table
instance always corresponds to a valid C struct cpufreq_frequency_table
.
The callers must ensure that the struct cpufreq_frequency_table
is valid for access and
remains valid for the lifetime of the returned reference.
§Examples
The following example demonstrates how to read a frequency value from Table
.
use kernel::cpufreq::{Policy, TableIndex};
fn show_freq(policy: &Policy) {
let table = policy.freq_table().unwrap();
// SAFETY: Index is a valid entry in the table.
let index = unsafe { TableIndex::new(0) };
pr_info!("The frequency at index 0 is: {:?}\n", table.freq(index).unwrap());
pr_info!("The flags at index 0 is: {}\n", table.flags(index));
pr_info!("The data at index 0 is: {}\n", table.data(index));
}
Implementations§
Source§impl Table
impl Table
Sourcepub unsafe fn from_raw<'a>(ptr: *const cpufreq_frequency_table) -> &'a Self
pub unsafe fn from_raw<'a>(ptr: *const cpufreq_frequency_table) -> &'a Self
Creates a reference to an existing C struct cpufreq_frequency_table
pointer.
§Safety
The caller must ensure that ptr
is valid for reading and remains valid for the lifetime
of the returned reference.
Sourcepub fn as_raw(&self) -> *mut cpufreq_frequency_table
pub fn as_raw(&self) -> *mut cpufreq_frequency_table
Returns the raw mutable pointer to the C struct cpufreq_frequency_table
.
Sourcepub fn freq(&self, index: TableIndex) -> Result<Hertz>
pub fn freq(&self, index: TableIndex) -> Result<Hertz>
Returns frequency at index
in the Table
.
Sourcepub fn flags(&self, index: TableIndex) -> u32
pub fn flags(&self, index: TableIndex) -> u32
Returns flags at index
in the Table
.
Sourcepub fn data(&self, index: TableIndex) -> u32
pub fn data(&self, index: TableIndex) -> u32
Returns data at index
in the Table
.