Struct SwitchtecDevice

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

SwitchtecDevice offers an safer way to work with the underlying switchtec_dev and represents an open Switchtec PCI Switch device that can be passed into switchtec-user C library functions

  • SwitchtecDevice closes the Switchtec character device when it goes out of scope

Implementations§

Source§

impl SwitchtecDevice

Source

pub fn open<T: AsRef<Path>>(path: T) -> Result<Self>

Open the Switchtec PCIe Switch character device at the given path, returning a SwitchtecDevice that can be used to pass into switchtec-user C library functions

use switchtec_user_sys::{switchtec_die_temp, SwitchtecDevice};

let device = SwitchtecDevice::open("/dev/pciswitch0")?;

// SAFETY: We know that device holds a valid/open switchtec device
let temperature = unsafe { switchtec_die_temp(*device) };
println!("Temperature: {temperature}");
// Switchtec device is closed with `device` goes out of scope
}
Source

pub fn name(&self) -> Result<String>

Get the device name (E.g. “pciswitch0” in “/dev/pciswitch0”)

This can fail if the device name is not valid UTF-8

https://microsemi.github.io/switchtec-user/group__Device.html#ga8d416a587f5e37e818ee937bd0c0dab1

Source

pub fn boot_phase(&self) -> switchtec_boot_phase

Source

pub fn firmware_version(&self) -> Result<String>

Get the firmware version as a user readable string

This can fail if the firmware version is not valid UTF-8

https://microsemi.github.io/switchtec-user/group__Device.html#gad16f110712bd23170ad69450c361122e

Source

pub fn generation(&self) -> switchtec_gen

Source

pub fn partition(&self) -> i32

Source

pub fn die_temp(&self) -> Result<f32>

Trait Implementations§

Source§

impl Debug for SwitchtecDevice

Source§

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

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

impl Deref for SwitchtecDevice

Source§

type Target = *mut switchtec_dev

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Drop for SwitchtecDevice

Source§

fn drop(&mut self)

Executes the destructor for this type. 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.