Event

Struct Event 

Source
pub struct Event<'a> {
    pub header: ExchangeHeader,
    pub data: &'a mut [u8],
}
Expand description

Typical Event received by the kernel using the copy_from_kernel(my_event)

Event is SentryExchangeable, see crate::exchange::SentryExchangeable and the corresponding implementation for this struct for more information.

Fields§

§header: ExchangeHeader§data: &'a mut [u8]

Trait Implementations§

Source§

impl<'a> Debug for Event<'a>

Source§

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

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

impl SentryExchangeable for Event<'_>

Event SentryExchangeable trait implementation

Events are objects that are used to hold event ifnormation that need to be delivered or received from the kernel.

Events are received from the kernel and hold a header and an associated data bloc. The SentryExchangeable trait only support, in nominal mode, the from_kernel() usage for any event, and to_kernel when emitting IPC

This trait allows to easily receive or deliver properly formatted events, including the event header forged by the kernel and associated data.

§Example

let mut my_event = uapi::systypes::Event {
    header: uapi::systypes::ExchangeHeader {
        peer: 0,
        event: uapi::systypes::EventType::None.into(),
        length: 0,
        magic: 0,
    },
    data: &mut[0; 12],
};
// wait for kernel events of type IRQ or IPC
let _ = uapi::syscall::wait_for_event(
            uapi::systypes::EventType::IRQ.into() | uapi::systypes::EventType::Ipc.into(),
            0;
        );
// get back event data from kernel
let _ = my_event.from_kernel();
// handle event
if !my_event.header.is_valid() {
    return Err(),
}
match my_event.header.event {
    EventType::Irq => treat_irq(&my_event.data, my_event.length),
    EventType::IPC => treat_ipc(&my_event.data,  my_event.length),
    any_other      => Err(),
}
Source§

fn to_kernel(&self) -> Result<Status, Status>

Event can be used as source for to_kernel() when being an IPC

Events not being and IPC do not need to emit any data in the kernel exchange zone, leading to Err(Status::Invalid) return code.

Source§

fn from_kernel(&mut self) -> Result<Status, Status>

set the current object using the data delivered by the kernel in the exchange zone

Auto Trait Implementations§

§

impl<'a> Freeze for Event<'a>

§

impl<'a> RefUnwindSafe for Event<'a>

§

impl<'a> Send for Event<'a>

§

impl<'a> Sync for Event<'a>

§

impl<'a> Unpin for Event<'a>

§

impl<'a> !UnwindSafe for Event<'a>

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.