From c560b3b21ace3b5560710286750f3180d515db98 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Tue, 9 Mar 2021 11:03:24 +1100 Subject: [PATCH] Introduce `RateUpdate` type alias to reduce duplication --- swap/src/kraken.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/swap/src/kraken.rs b/swap/src/kraken.rs index 66bbff30..fdd7ecd3 100644 --- a/swap/src/kraken.rs +++ b/swap/src/kraken.rs @@ -8,6 +8,8 @@ use std::convert::TryFrom; use tokio::sync::watch; use tokio_tungstenite::tungstenite; +type RateUpdate = Result; + pub async fn connect() -> Result { let (rate_update, rate_update_receiver) = watch::channel(Err(Error::NotYetRetrieved)); @@ -95,17 +97,17 @@ pub async fn connect() -> Result { #[derive(Clone, Debug)] pub struct RateUpdateStream { - inner: watch::Receiver>, + inner: watch::Receiver, } impl RateUpdateStream { - pub async fn wait_for_update(&mut self) -> Result> { + pub async fn wait_for_update(&mut self) -> Result { self.inner.changed().await?; Ok(self.inner.borrow().clone()) } - pub fn latest_update(&mut self) -> Result { + pub fn latest_update(&mut self) -> RateUpdate { self.inner.borrow().clone() } }