Struct Ctl

Source
pub struct Ctl { /* private fields */ }
Expand description

Ctl is a handle to the kstat library.

Users instantiate a control handle and access the kstat’s it contains, for example via the Ctl::iter method.

Implementations§

Source§

impl Ctl

Source

pub fn new() -> Result<Self, Error>

Create a new Ctl.

Source

pub fn update(self) -> Result<Self, Error>

Synchronize this Ctl with the kernel’s view of the data.

A Ctl is really a snapshot of the kernel’s internal list of kstats. This method consumes and updates a control object, bringing it into sync with the kernel’s copy.

Source

pub fn iter(&self) -> Iter<'_>

Return an iterator over the Kstats in self.

Note that this will only return Kstats which are successfully read. For example, it will ignore those with non-UTF-8 names.

Source

pub fn read<'a>(&self, kstat: &mut Kstat<'a>) -> Result<Data<'a>, Error>

Read a Kstat, returning the data for it.

Source

pub fn filter<'a>( &'a self, module: Option<&'a str>, instance: Option<i32>, name: Option<&'a str>, ) -> impl Iterator<Item = Kstat<'a>>

Find Kstats by module, instance, and/or name.

If a field is None, any matching Kstat is returned.

Trait Implementations§

Source§

impl Debug for Ctl

Source§

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

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

impl Drop for Ctl

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Ctl

The Ctl wraps a raw pointer allocated by the libkstat(3KSTAT) library. This itself isn’t thread-safe, but doesn’t refer to any thread-local state. So it’s safe to send across threads.

Auto Trait Implementations§

§

impl Freeze for Ctl

§

impl RefUnwindSafe for Ctl

§

impl !Sync for Ctl

§

impl Unpin for Ctl

§

impl UnwindSafe for Ctl

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.