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) -> Result {
let table = policy.freq_table()?;
// 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)?);
pr_info!("The flags at index 0 is: {}\n", table.flags(index));
pr_info!("The data at index 0 is: {}\n", table.data(index));
Ok(())
}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.
Auto Trait Implementations§
impl !Freeze for Table
impl !RefUnwindSafe for Table
impl Send for Table
impl !Sync for Table
impl !Unpin for Table
impl UnwindSafe for Table
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> PinInit<T> for T
impl<T> PinInit<T> for T
Source§unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
slot. Read more