-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cc3e13e
commit 2b2411b
Showing
9 changed files
with
57 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod base; | ||
pub mod mutex; | ||
pub mod oauth; | ||
pub mod pagination; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use futures::lock::{Mutex, MutexGuard}; | ||
|
||
#[derive(Debug, Default)] | ||
pub struct FuturesMutex<T: ?Sized>(Mutex<T>); | ||
|
||
#[derive(Debug)] | ||
pub struct LockError; | ||
|
||
impl<T> FuturesMutex<T> { | ||
pub fn new(val: T) -> Self { | ||
FuturesMutex(Mutex::new(val)) | ||
} | ||
|
||
pub async fn lock(&self) -> Result<MutexGuard<'_, T>, LockError> { | ||
let val = self.0.lock().await; | ||
Ok(val) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//! This mutex wraps both the synchronous and asynchronous versions under the | ||
//! same interface. | ||
|
||
#[cfg(feature = "__async")] | ||
mod futures; | ||
#[cfg(feature = "__sync")] | ||
mod sync; | ||
|
||
#[cfg(feature = "__async")] | ||
pub use self::futures::FuturesMutex as Mutex; | ||
#[cfg(feature = "__sync")] | ||
pub use self::sync::SyncMutex as Mutex; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub type SyncMutex<T> = std::sync::Mutex<T>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters