pub struct EventLoop<'nvml> { /* private fields */ }
Expand description

Holds the EventSet utilized within an event loop.

A usage example is available (examples/event_loop.rs). It can be run as follows:

cargo run --example event_loop

Implementations§

source§

impl<'nvml> EventLoop<'nvml>

source

pub fn register_device( self, device: &'nvml Device<'nvml> ) -> Result<Self, NvmlErrorWithSource>

Register another device that this EventLoop should receive events for.

This method takes ownership of this struct and then hands it back to you if everything went well with the registration process.

§Errors
  • Uninitialized, if the library has not been successfully initialized
  • GpuLost, if a GPU has fallen off the bus or is otherwise inaccessible
  • Unknown, on any unexpected error
§Platform Support

Only supports Linux.

source

pub fn run_forever<F>(&mut self, callback: F)
where F: FnMut(Result<Event<'nvml>, NvmlError>, &mut EventLoopState),

Handle events with the given callback until the loop is manually interrupted.

§Errors

The function itself does not return anything. You will be given errors to handle within your closure if they occur; events are handed to you wrapped in a Result.

The errors that you will need to handle are:

  • Uninitialized, if the library has not been successfully initialized
  • GpuLost, if a GPU has fallen off the bus or is otherwise inaccessible
  • Unknown, on any unexpected error
§Examples

See the event_loop example in the examples directory at the root.

§Platform Support

Only supports Linux.

source

pub fn as_inner(&'nvml self) -> &'nvml EventSet<'nvml>

Obtain a reference to the EventSet contained within this struct.

source

pub fn as_mut_inner(&'nvml mut self) -> &'nvml mut EventSet<'nvml>

Obtain a mutable reference to the EventSet contained within this struct.

source

pub fn into_inner(self) -> EventSet<'nvml>

Consumes this EventLoop and yields the EventSet contained within.

Trait Implementations§

source§

impl<'nvml> From<EventSet<'nvml>> for EventLoop<'nvml>

source§

fn from(set: EventSet<'nvml>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'nvml> !RefUnwindSafe for EventLoop<'nvml>

§

impl<'nvml> Send for EventLoop<'nvml>

§

impl<'nvml> !Sync for EventLoop<'nvml>

§

impl<'nvml> Unpin for EventLoop<'nvml>

§

impl<'nvml> !UnwindSafe for EventLoop<'nvml>

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>,

§

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>,

§

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.