diff --git a/sdk/identity/azure_identity/src/lib.rs b/sdk/identity/azure_identity/src/lib.rs index 39c0a0c0dbe..3e29aac1b48 100644 --- a/sdk/identity/azure_identity/src/lib.rs +++ b/sdk/identity/azure_identity/src/lib.rs @@ -13,7 +13,6 @@ mod env; mod managed_identity_credential; mod oauth2_http_client; mod refresh_token; -mod timeout; use azure_core::{ error::{ErrorKind, ResultExt}, diff --git a/sdk/identity/azure_identity/src/timeout.rs b/sdk/identity/azure_identity/src/timeout.rs deleted file mode 100644 index 0d98c541a4c..00000000000 --- a/sdk/identity/azure_identity/src/timeout.rs +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) 2020 Yoshua Wuyts -// -// based on https://crates.io/crates/futures-time -// Licensed under either of Apache License, Version 2.0 or MIT license at your option. - -// cspell:ignore Yoshua Wuyts -use azure_core::sleep::{sleep, Sleep}; -use futures::Future; -use std::time::Duration; -use std::{ - pin::Pin, - task::{Context, Poll}, -}; - -#[pin_project::pin_project] -#[derive(Debug)] -pub(crate) struct Timeout { - #[pin] - future: F, - #[pin] - deadline: D, - completed: bool, -} - -impl Timeout { - #[allow(dead_code)] - pub(crate) fn new(future: F, deadline: D) -> Self { - Self { - future, - deadline, - completed: false, - } - } -} - -impl Future for Timeout { - type Output = azure_core::Result; - - fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - let this = self.project(); - - assert!(!*this.completed, "future polled after completing"); - - match this.future.poll(cx) { - Poll::Ready(v) => { - *this.completed = true; - Poll::Ready(Ok(v)) - } - Poll::Pending => match this.deadline.poll(cx) { - Poll::Ready(_) => { - *this.completed = true; - Poll::Ready(Err(azure_core::error::Error::with_message( - azure_core::error::ErrorKind::Other, - || String::from("operation timed out"), - ))) - } - Poll::Pending => Poll::Pending, - }, - } - } -} - -#[allow(dead_code)] -pub(crate) trait TimeoutExt: Future { - fn timeout(self, duration: Duration) -> Timeout - where - Self: Sized, - { - Timeout::new(self, sleep(duration)) - } -} - -impl TimeoutExt for T where T: Future {}