Struct rpi_mailbox::Mailbox

source ·
pub struct Mailbox(_);

Implementations§

source§

impl Mailbox

source

pub fn new<P>(device: &P) -> Result<Self, Error>where P: ?Sized + NixPath,

open device

device: path to mailbox device. e.g. /dev/vcio

Examples found in repository?
examples/memflag.rs (line 32)
29
30
31
32
33
34
35
36
37
38
39
40
41
42
fn main() {
    use memflag::Flags;

    let mb = Mailbox::new("/dev/vcio").expect("mailbox");

    print!("NORMAL:           ");
    print_addr(&mb, Flags::MEM_FLAG_NORMAL).expect("MEM_FLAG_NORMAL");
    print!("DIRECT:           ");
    print_addr(&mb, Flags::MEM_FLAG_DIRECT).expect("MEM_FLAG_DIRECT");
    print!("COHERENT:         ");
    print_addr(&mb, Flags::MEM_FLAG_COHERENT).expect("MEM_FLAG_COHERENT");
    print!("L1_NONALLOCATING: ");
    print_addr(&mb, Flags::MEM_FLAG_L1_NONALLOCATING).expect("MEM_FLAG_L1_NONALLOCATING");
}
More examples
Hide additional examples
examples/info.rs (line 9)
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
fn main() {
    let mb = Mailbox::new("/dev/vcio").expect("mailbox");

    let rev = firmware_revision(&mb).expect("firmware_revision");
    let date = DateTime::<Utc>::from_utc(
        NaiveDateTime::from_timestamp_opt(rev as i64, 0).unwrap(),
        Utc,
    );
    println!("Firmware revision: {}", date.format("%b %e %Y %T"));

    let model = get_board_model(&mb).expect("board_model");
    println!("Board model: 0x{:08x}", model);

    let rev = get_board_revision(&mb).expect("board_revision");
    println!("Board revision: 0x{:08x}", rev);

    let mac = get_board_mac_address(&mb).expect("board_mac_address");
    println!("Board MAC address: {:012x}", mac);

    let serial = get_board_serial(&mb).expect("board_serial");
    println!("Board serial: 0x{:x}", serial);

    let (base, size) = get_arm_memory(&mb).expect("arm_memory");
    println!("ARM memory: 0x{:08x} bytes at 0x{:08x}", size, base);

    let (base, size) = get_vc_memory(&mb).expect("vc_memory");
    println!("VC memory:  0x{:08x} bytes at 0x{:08x}", size, base);

    let throttled = get_throttled(&mb).expect("throttled");
    println!("Throttled: 0x{:x}", throttled);
}

Trait Implementations§

source§

impl AsRawFd for Mailbox

source§

fn as_raw_fd(&self) -> RawFd

Extracts the raw file descriptor. Read more
source§

impl Debug for Mailbox

source§

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

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

impl Drop for Mailbox

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl FromRawFd for Mailbox

source§

unsafe fn from_raw_fd(fd: RawFd) -> Self

Constructs a new instance of Self from the given raw file descriptor. Read more
source§

impl IntoRawFd for Mailbox

source§

fn into_raw_fd(self) -> RawFd

Consumes this object, returning the raw underlying file descriptor. Read more
source§

impl Ord for Mailbox

source§

fn cmp(&self, other: &Mailbox) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<Mailbox> for Mailbox

source§

fn eq(&self, other: &Mailbox) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Mailbox> for Mailbox

source§

fn partial_cmp(&self, other: &Mailbox) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Eq for Mailbox

source§

impl StructuralEq for Mailbox

source§

impl StructuralPartialEq for Mailbox

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.