Skip to main content

DeviceHandle

Struct DeviceHandle 

pub struct DeviceHandle<S, I = ChannelDeviceHandle>
where I: DeviceHandleSpec, S: ?Sized,
{ /* private fields */ }
Expand description

A handle to one service, reached as S.

S is the concrete service for a handle built with insert or new, and a trait object for one built with seen_as. Either way the service lives where the transport I put it; the handle only knows how to see it as S.

Implementations§

§

impl<S, I> DeviceHandle<S, I>
where S: DeviceService, I: DeviceHandleSpec,

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

pub fn new(device_id: DeviceId) -> DeviceHandle<S, I>

§

impl<S, I> DeviceHandle<S, I>
where S: 'static + ?Sized, I: DeviceHandleSpec,

pub const fn is_blocking() -> bool

pub fn seen_as<T>( self, cast: fn(&mut (dyn Any + 'static)) -> &mut T, ) -> DeviceHandle<T, I>
where T: ?Sized,

The same service, seen as T: cast turns the state this handle already reaches into a T, once per task, on the thread that runs it.

pub fn device_id(&self) -> DeviceId

pub fn service_id(&self) -> ServiceId

The service this handle reaches: its device and its concrete type, whatever it is seen as.

pub fn utilities(&self) -> Arc<dyn Any + Send + Sync> ⓘ

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

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

pub fn flush_queue(&self)

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

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§

§

impl<S, I> Clone for DeviceHandle<S, I>
where I: DeviceHandleSpec, S: ?Sized,

§

fn clone(&self) -> DeviceHandle<S, I>

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, I> Freeze for DeviceHandle<S, I>
where I: Freeze, S: ?Sized,

§

impl<S, I> RefUnwindSafe for DeviceHandle<S, I>
where I: RefUnwindSafe, S: ?Sized,

§

impl<S, I> Send for DeviceHandle<S, I>
where I: Send, S: ?Sized,

§

impl<S, I> Sync for DeviceHandle<S, I>
where I: Sync, S: ?Sized,

§

impl<S, I> Unpin for DeviceHandle<S, I>
where I: Unpin, S: ?Sized,

§

impl<S, I> UnsafeUnpin for DeviceHandle<S, I>
where I: UnsafeUnpin, S: ?Sized,

§

impl<S, I> UnwindSafe for DeviceHandle<S, I>
where I: UnwindSafe, S: ?Sized,

Blanket Implementations§

§

impl<T> Adaptor<()> for T

§

fn adapt(&self)

Adapt the type to be passed to a metric.
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
§

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

§

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
§

impl<K, Q> Comparable<Q> for K
where K: Borrow<Q> + ?Sized, Q: Ord + ?Sized,

§

fn compare(&self, key: &Q) -> Ordering

Compare self to key and return their ordering.
§

impl<K, Q> Equivalent<Q> for K
where K: Borrow<Q> + ?Sized, Q: Eq + ?Sized,

§

fn equivalent(&self, key: &Q) -> bool

Compare self to key and return true if they are equal.
§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more