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 SentryExchangeable for Event<'_>
Event SentryExchangeable trait implementation
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(),
}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> 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
Mutably borrows from an owned value. Read more