Skip to main content

DeviceHandle

Struct DeviceHandle 

Source
pub struct DeviceHandle<S: DeviceService> { /* private fields */ }
Expand description

TODO: Docs

Implementations§

Source§

impl<S: DeviceService> DeviceHandle<S>

Source

pub const fn is_blocking() -> bool

Source

pub fn insert( device_id: DeviceId, service: S, ) -> Result<Self, ServiceCreationError>

Source

pub fn new(device_id: DeviceId) -> Self

Source

pub fn device_id(&self) -> DeviceId

Source

pub fn utilities(&self) -> ServerUtilitiesHandle

Source

pub fn submit_blocking<'a, R: Send, T: FnOnce(&mut S) -> R + Send + 'a>( &self, task: T, ) -> Result<R, CallError>

Source

pub fn submit<T: FnOnce(&mut S) + Send + 'static>(&self, task: T)

Source

pub fn flush_queue(&self)

Source

pub fn exclusive<R: Send, T: FnOnce() -> R + Send>( &self, task: T, ) -> Result<R, CallError>

Source

pub fn shutdown(device_id: DeviceId)

Stops the background runner threads for device_id, blocking until they exit. Queued tasks run before the threads stop. Live handles keep their runner alive, so all handles for the device should be dropped first.

Only meaningful for handle implementations with background threads; a no-op otherwise.

§Scope

This is device-wide, and S is ignored. It shuts down every DeviceService registered on device_id, across both service stages, not only S. The type parameter selects the handle implementation to dispatch through, nothing more.

DeviceId is not unique across runtimes either: type_id is assigned per runtime, so distinct backends can hand out the same id. Shutting down a device from one runtime can therefore tear down another runtime’s services on the colliding id, and block while that runtime’s handles are still live.

Trait Implementations§

Source§

impl<S: DeviceService> Clone for DeviceHandle<S>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<S> !RefUnwindSafe for DeviceHandle<S>

§

impl<S> !UnwindSafe for DeviceHandle<S>

§

impl<S> Freeze for DeviceHandle<S>

§

impl<S> Send for DeviceHandle<S>

§

impl<S> Sync for DeviceHandle<S>

§

impl<S> Unpin for DeviceHandle<S>

§

impl<S> UnsafeUnpin for DeviceHandle<S>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.