Struct Device

Source
pub struct Device { /* private fields */ }
Expand description

A Device connects a Future to the backplane.

Implementations§

Source§

impl Device

Source

pub fn new() -> Self

Creates a new Device.

Source

pub fn device_id(&self) -> DeviceID

Get the ID of this Device.

Source

pub fn line(&self) -> Line

Opens a line to the Device.

Source

pub fn disconnect(self, fault: Option<Fault>)

Notify our peers we’re disconnecting.

Link with another Device with the provided LinkMode. LinkModes are additive, so you can ‘upgrade’ a link this way.

This method is intended for static-style linking, where the topology is not expected to change. You should not link to a Device this way after linking to it through a Line.

Unlink from another Device with the provided LinkMode. LinkModes are subtractive, so you can ‘downgrade’ a link this way.

This method is intended for static-style linking, where the topology is not expected to change. You should not link to a Device this way after linking to it through a Line.

Link with a line. This is safer than linking directly to a Device, but a little slower.

Unlink with a line. This is safer than linking directly to a Device, but a little slower.

Source

pub fn receive(&self) -> Option<Message>

Attempts to get the next message. Does not wait for one to arrive.

Source

pub async fn watch<F, C>( &mut self, f: F, ) -> Result<Watched<<F as Future>::Output>, Crash<C>>
where F: Future + Unpin, F::Output: Debug, C: 'static + Any + Debug + Send,

Returns the first of (with a bias towards the former):

  • The next message to be received.
  • The result of the completed future.
  • The crash of the Device.
Source

pub async fn part_manage<'a, F, T, C>( self, f: F, ) -> Result<(Device, T), Crash<C>>
where F: Future<Output = Result<T, C>> + Unpin, C: 'static + Debug + Send, T: Debug,

Runs an async closure while monitoring for messages. Messages are handled as follows:

  • Disconnects without fault are ignored.
  • Disconnects with fault cause the Device to fault.
  • Requests to disconnect cause the Device to crash but announce a successful completion.

If the provided closure returns successfully, the result is returned along with the Device for re-use. Monitors will not be notified.

If the Device faults, either because the provided closure returned an Err variant or because a fault was propagated, announces our fault to our monitors.

Source

pub async fn manage<F, C, T>(self, f: F) -> Result<T, Crash<C>>
where F: Future<Output = Result<T, C>> + Unpin, C: 'static + Debug + Send, T: Debug,

Like part_manage(), but in the case of successful completion of the provided future, notifies our monitors and consumes self

Trait Implementations§

Source§

impl Debug for Device

Source§

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

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

impl Default for Device

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for Device

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Stream for Device

Source§

type Item = Message

Values yielded by the stream.
Source§

fn poll_next( self: Pin<&mut Self>, ctx: &mut Context<'_>, ) -> Poll<Option<Self::Item>>

Attempt to pull out the next value of this stream, registering the current task for wakeup if the value is not yet available, and returning None if the stream is exhausted. Read more
Source§

fn size_hint(&self) -> (usize, Option<usize>)

Returns the bounds on the remaining length of the stream. Read more
Source§

impl Unpin for Device

Auto Trait Implementations§

§

impl !Freeze for Device

§

impl !RefUnwindSafe for Device

§

impl Send for Device

§

impl !Sync for Device

§

impl !UnwindSafe for Device

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<S> StreamExt for S
where S: Stream + ?Sized,

Source§

fn next(&mut self) -> NextFuture<'_, Self>
where Self: Unpin,

Retrieves the next item in the stream. Read more
Source§

fn count(self) -> CountFuture<Self>
where Self: Sized,

Counts the number of elements in the stream. Read more
Source§

fn map<T, F>(self, f: F) -> Map<Self, F>
where Self: Sized, F: FnMut(Self::Item) -> T,

Maps items of the stream to new values using a closure. Read more
Source§

fn filter<P>(self, predicate: P) -> Filter<Self, P>
where Self: Sized, P: FnMut(&Self::Item) -> bool,

Keeps items of the stream for which predicate returns true. Read more
Source§

fn filter_map<T, F>(self, f: F) -> FilterMap<Self, F>
where Self: Sized, F: FnMut(Self::Item) -> Option<T>,

Filters and maps items of the stream using a closure. Read more
Source§

fn collect<C>(self) -> CollectFuture<Self, C>
where C: Default + Extend<Self::Item>, Self: Sized,

Collects all items in the stream into a collection. Read more
Source§

fn try_collect<T, C>(self) -> TryCollectFuture<Self, C>
where C: Default + Extend<T>, Self: Sized, Self::Item: Result<Ok = T>,

Collects all items in the fallible stream into a collection. Read more
Source§

fn fold<T, F>(self, init: T, f: F) -> FoldFuture<Self, F, T>
where Self: Sized, F: FnMut(T, Self::Item) -> T,

Accumulates a computation over the stream. Read more
Source§

fn try_fold<T, E, F, B>( &mut self, init: B, f: F, ) -> TryFoldFuture<'_, Self, F, B>
where Self: Sized + Unpin, Self::Item: Result<Ok = T, Err = E>, F: FnMut(B, T) -> Result<B, E>,

Accumulates a fallible computation over the stream. Read more
Source§

fn boxed(self) -> Pin<Box<dyn Stream<Item = Self::Item> + Send>>
where Self: Sized + Send + 'static,

Boxes the stream and changes its type to dyn Stream<Item = T> + Send. Read more
Source§

fn boxed_local(self) -> Pin<Box<dyn Stream<Item = Self::Item>>>
where Self: Sized + 'static,

Boxes the stream and changes its type to dyn Stream<Item = T>. 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.