pub struct Link { /* private fields */ }
Expand description
A link to another unit.
The link allows tracking of updates of that other unit. This happens via
the query
method. A link’s owner can signal that they
are currently not interested in receiving updates via the
suspend
method. This suspension will automatically be
lifted the next time query
is called.
Links can be created from the name of the unit they should be linking to
via manager::load_link. This function is
also called implicitly through the impls for Deserialize
and From
.
Note, however, that the function only adds the link to a list of links
to be properly connected by the manager later.
Implementations
sourceimpl Link
impl Link
sourcepub async fn query(&mut self) -> Result<Update, UnitStatus>
pub async fn query(&mut self) -> Result<Update, UnitStatus>
Query for the next update.
The method returns a future that resolves into the next update. The future can be dropped safely at any time.
The future either resolves into a payload update or the connected
unit’s new status as the error variant. The current status is also
available via the get_status
method.
If the link is currently suspended, calling this method will lift the suspension.
sourcepub async fn query_suspended(&mut self) -> UnitStatus
pub async fn query_suspended(&mut self) -> UnitStatus
Query a suspended link.
When a link is suspended, it still received updates to the unit’s status. These updates can also be queried for explicitly via this method.
Much like query
, the future returned by this method can safely be
dropped at any time.
sourcepub async fn suspend(&mut self)
pub async fn suspend(&mut self)
Suspends the link.
A suspended link will not receive any payload updates from the connected unit. It will, however, still receive status updates.
The suspension is lifted automatically the next time query
is
called.
Note that this is an async method that needs to be awaited in order to do anything.
sourcepub fn get_status(&self) -> UnitStatus
pub fn get_status(&self) -> UnitStatus
Returns the current status of the connected unit.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Link
impl<'de> Deserialize<'de> for Link
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl !RefUnwindSafe for Link
impl Send for Link
impl Sync for Link
impl Unpin for Link
impl !UnwindSafe for Link
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more