pub struct Device { /* private fields */ }
Expand description
A Device connects a Future to the backplane.
Implementations§
Source§impl Device
impl Device
Sourcepub fn disconnect(self, fault: Option<Fault>)
pub fn disconnect(self, fault: Option<Fault>)
Notify our peers we’re disconnecting.
Sourcepub fn link(&self, other: &Device, mode: LinkMode)
pub fn link(&self, other: &Device, mode: LinkMode)
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.
Sourcepub fn unlink(&self, other: &Device, mode: LinkMode)
pub fn unlink(&self, other: &Device, mode: LinkMode)
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.
Sourcepub fn link_line(&self, other: Line, mode: LinkMode) -> Result<(), LinkError>
pub fn link_line(&self, other: Line, mode: LinkMode) -> Result<(), LinkError>
Link with a line. This is safer than linking directly to a Device, but a little slower.
Sourcepub fn unlink_line(&self, other: &Line, mode: LinkMode)
pub fn unlink_line(&self, other: &Line, mode: LinkMode)
Unlink with a line. This is safer than linking directly to a Device, but a little slower.
Sourcepub fn receive(&self) -> Option<Message>
pub fn receive(&self) -> Option<Message>
Attempts to get the next message. Does not wait for one to arrive.
Sourcepub async fn watch<F, C>(
&mut self,
f: F,
) -> Result<Watched<<F as Future>::Output>, Crash<C>>
pub async fn watch<F, C>( &mut self, f: F, ) -> Result<Watched<<F as Future>::Output>, Crash<C>>
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.
Sourcepub async fn part_manage<'a, F, T, C>(
self,
f: F,
) -> Result<(Device, T), Crash<C>>
pub async fn part_manage<'a, F, T, C>( self, f: F, ) -> Result<(Device, T), Crash<C>>
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.