[−][src]Struct apigpio::Subscription
Methods from Deref<Target = Receiver<GpioChange>>
pub fn borrow(&self) -> Ref<T>
[src]
Returns a reference to the most recently sent value
Outstanding borrows hold a read lock. This means that long lived borrows could cause the send half to block. It is recommended to keep the borrow as short lived as possible.
Examples
use tokio::sync::watch; let (_, rx) = watch::channel("hello"); assert_eq!(*rx.borrow(), "hello");
pub async fn recv(&'_ mut self) -> Option<T>
[src]
Attempts to clone the latest value sent via the channel.
If this is the first time the function is called on a Receiver
instance, then the function completes immediately with the current
value held by the channel. On the next call, the function waits until
a new value is sent in the channel.
None
is returned if the Sender
half is dropped.
Examples
use tokio::sync::watch; #[tokio::main] async fn main() { let (tx, mut rx) = watch::channel("hello"); let v = rx.recv().await.unwrap(); assert_eq!(v, "hello"); tokio::spawn(async move { tx.broadcast("goodbye").unwrap(); }); // Waits for the new task to spawn and send the value. let v = rx.recv().await.unwrap(); assert_eq!(v, "goodbye"); let v = rx.recv().await; assert!(v.is_none()); }
Trait Implementations
impl Deref for Subscription
[src]
type Target = Receiver<GpioChange>
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
impl DerefMut for Subscription
[src]
Auto Trait Implementations
impl !RefUnwindSafe for Subscription
impl Send for Subscription
impl Sync for Subscription
impl Unpin for Subscription
impl !UnwindSafe for Subscription
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,