Skip to content

Commit 12a60df

Browse files
authored
Remove Future implementation (#3142)
1 parent 9f96662 commit 12a60df

File tree

9 files changed

+5
-278
lines changed

9 files changed

+5
-278
lines changed

crates/libs/bindgen/src/rust/writer.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -697,25 +697,6 @@ impl Writer {
697697
self.GetResults()
698698
}
699699
}
700-
#features
701-
impl<#constraints> std::future::Future for #ident {
702-
type Output = windows_core::Result<#return_type>;
703-
704-
fn poll(self: std::pin::Pin<&mut Self>, context: &mut std::task::Context<'_>) -> std::task::Poll<Self::Output> {
705-
if self.Status()? == #namespace AsyncStatus::Started {
706-
let waker = context.waker().clone();
707-
708-
let _ = self.SetCompleted(&#namespace #handler::new(move |_sender, _args| {
709-
waker.wake_by_ref();
710-
Ok(())
711-
}));
712-
713-
std::task::Poll::Pending
714-
} else {
715-
std::task::Poll::Ready(self.GetResults())
716-
}
717-
}
718-
}
719700
}
720701
}
721702
}

crates/libs/windows/src/Windows/Devices/Sms/mod.rs

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,22 +1036,6 @@ impl DeleteSmsMessageOperation {
10361036
}
10371037
}
10381038
#[cfg(feature = "deprecated")]
1039-
impl std::future::Future for DeleteSmsMessageOperation {
1040-
type Output = windows_core::Result<()>;
1041-
fn poll(self: std::pin::Pin<&mut Self>, context: &mut std::task::Context<'_>) -> std::task::Poll<Self::Output> {
1042-
if self.Status()? == super::super::Foundation::AsyncStatus::Started {
1043-
let waker = context.waker().clone();
1044-
let _ = self.SetCompleted(&super::super::Foundation::AsyncActionCompletedHandler::new(move |_sender, _args| {
1045-
waker.wake_by_ref();
1046-
Ok(())
1047-
}));
1048-
std::task::Poll::Pending
1049-
} else {
1050-
std::task::Poll::Ready(self.GetResults())
1051-
}
1052-
}
1053-
}
1054-
#[cfg(feature = "deprecated")]
10551039
#[repr(transparent)]
10561040
#[derive(PartialEq, Eq, Debug, Clone)]
10571041
pub struct DeleteSmsMessagesOperation(windows_core::IUnknown);
@@ -1138,22 +1122,6 @@ impl DeleteSmsMessagesOperation {
11381122
}
11391123
}
11401124
#[cfg(feature = "deprecated")]
1141-
impl std::future::Future for DeleteSmsMessagesOperation {
1142-
type Output = windows_core::Result<()>;
1143-
fn poll(self: std::pin::Pin<&mut Self>, context: &mut std::task::Context<'_>) -> std::task::Poll<Self::Output> {
1144-
if self.Status()? == super::super::Foundation::AsyncStatus::Started {
1145-
let waker = context.waker().clone();
1146-
let _ = self.SetCompleted(&super::super::Foundation::AsyncActionCompletedHandler::new(move |_sender, _args| {
1147-
waker.wake_by_ref();
1148-
Ok(())
1149-
}));
1150-
std::task::Poll::Pending
1151-
} else {
1152-
std::task::Poll::Ready(self.GetResults())
1153-
}
1154-
}
1155-
}
1156-
#[cfg(feature = "deprecated")]
11571125
#[repr(transparent)]
11581126
#[derive(PartialEq, Eq, Debug, Clone)]
11591127
pub struct GetSmsDeviceOperation(windows_core::IUnknown);
@@ -1243,22 +1211,6 @@ impl GetSmsDeviceOperation {
12431211
}
12441212
}
12451213
#[cfg(feature = "deprecated")]
1246-
impl std::future::Future for GetSmsDeviceOperation {
1247-
type Output = windows_core::Result<SmsDevice>;
1248-
fn poll(self: std::pin::Pin<&mut Self>, context: &mut std::task::Context<'_>) -> std::task::Poll<Self::Output> {
1249-
if self.Status()? == super::super::Foundation::AsyncStatus::Started {
1250-
let waker = context.waker().clone();
1251-
let _ = self.SetCompleted(&super::super::Foundation::AsyncOperationCompletedHandler::new(move |_sender, _args| {
1252-
waker.wake_by_ref();
1253-
Ok(())
1254-
}));
1255-
std::task::Poll::Pending
1256-
} else {
1257-
std::task::Poll::Ready(self.GetResults())
1258-
}
1259-
}
1260-
}
1261-
#[cfg(feature = "deprecated")]
12621214
#[repr(transparent)]
12631215
#[derive(PartialEq, Eq, Debug, Clone)]
12641216
pub struct GetSmsMessageOperation(windows_core::IUnknown);
@@ -1347,22 +1299,6 @@ impl GetSmsMessageOperation {
13471299
self.GetResults()
13481300
}
13491301
}
1350-
#[cfg(feature = "deprecated")]
1351-
impl std::future::Future for GetSmsMessageOperation {
1352-
type Output = windows_core::Result<ISmsMessage>;
1353-
fn poll(self: std::pin::Pin<&mut Self>, context: &mut std::task::Context<'_>) -> std::task::Poll<Self::Output> {
1354-
if self.Status()? == super::super::Foundation::AsyncStatus::Started {
1355-
let waker = context.waker().clone();
1356-
let _ = self.SetCompleted(&super::super::Foundation::AsyncOperationCompletedHandler::new(move |_sender, _args| {
1357-
waker.wake_by_ref();
1358-
Ok(())
1359-
}));
1360-
std::task::Poll::Pending
1361-
} else {
1362-
std::task::Poll::Ready(self.GetResults())
1363-
}
1364-
}
1365-
}
13661302
#[cfg(all(feature = "Foundation_Collections", feature = "deprecated"))]
13671303
#[repr(transparent)]
13681304
#[derive(PartialEq, Eq, Debug, Clone)]
@@ -1471,22 +1407,6 @@ impl GetSmsMessagesOperation {
14711407
self.GetResults()
14721408
}
14731409
}
1474-
#[cfg(all(feature = "Foundation_Collections", feature = "deprecated"))]
1475-
impl std::future::Future for GetSmsMessagesOperation {
1476-
type Output = windows_core::Result<super::super::Foundation::Collections::IVectorView<ISmsMessage>>;
1477-
fn poll(self: std::pin::Pin<&mut Self>, context: &mut std::task::Context<'_>) -> std::task::Poll<Self::Output> {
1478-
if self.Status()? == super::super::Foundation::AsyncStatus::Started {
1479-
let waker = context.waker().clone();
1480-
let _ = self.SetCompleted(&super::super::Foundation::AsyncOperationWithProgressCompletedHandler::new(move |_sender, _args| {
1481-
waker.wake_by_ref();
1482-
Ok(())
1483-
}));
1484-
std::task::Poll::Pending
1485-
} else {
1486-
std::task::Poll::Ready(self.GetResults())
1487-
}
1488-
}
1489-
}
14901410
#[cfg(feature = "deprecated")]
14911411
#[repr(transparent)]
14921412
#[derive(PartialEq, Eq, Debug, Clone)]
@@ -1573,22 +1493,6 @@ impl SendSmsMessageOperation {
15731493
self.GetResults()
15741494
}
15751495
}
1576-
#[cfg(feature = "deprecated")]
1577-
impl std::future::Future for SendSmsMessageOperation {
1578-
type Output = windows_core::Result<()>;
1579-
fn poll(self: std::pin::Pin<&mut Self>, context: &mut std::task::Context<'_>) -> std::task::Poll<Self::Output> {
1580-
if self.Status()? == super::super::Foundation::AsyncStatus::Started {
1581-
let waker = context.waker().clone();
1582-
let _ = self.SetCompleted(&super::super::Foundation::AsyncActionCompletedHandler::new(move |_sender, _args| {
1583-
waker.wake_by_ref();
1584-
Ok(())
1585-
}));
1586-
std::task::Poll::Pending
1587-
} else {
1588-
std::task::Poll::Ready(self.GetResults())
1589-
}
1590-
}
1591-
}
15921496
#[repr(transparent)]
15931497
#[derive(PartialEq, Eq, Debug, Clone)]
15941498
pub struct SmsAppMessage(windows_core::IUnknown);

crates/libs/windows/src/Windows/Foundation/mod.rs

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,6 @@ impl IAsyncAction {
7878
self.GetResults()
7979
}
8080
}
81-
impl std::future::Future for IAsyncAction {
82-
type Output = windows_core::Result<()>;
83-
fn poll(self: std::pin::Pin<&mut Self>, context: &mut std::task::Context<'_>) -> std::task::Poll<Self::Output> {
84-
if self.Status()? == AsyncStatus::Started {
85-
let waker = context.waker().clone();
86-
let _ = self.SetCompleted(&AsyncActionCompletedHandler::new(move |_sender, _args| {
87-
waker.wake_by_ref();
88-
Ok(())
89-
}));
90-
std::task::Poll::Pending
91-
} else {
92-
std::task::Poll::Ready(self.GetResults())
93-
}
94-
}
95-
}
9681
unsafe impl Send for IAsyncAction {}
9782
unsafe impl Sync for IAsyncAction {}
9883
impl windows_core::RuntimeType for IAsyncAction {
@@ -198,21 +183,6 @@ impl<TProgress: windows_core::RuntimeType + 'static> IAsyncActionWithProgress<TP
198183
self.GetResults()
199184
}
200185
}
201-
impl<TProgress: windows_core::RuntimeType + 'static> std::future::Future for IAsyncActionWithProgress<TProgress> {
202-
type Output = windows_core::Result<()>;
203-
fn poll(self: std::pin::Pin<&mut Self>, context: &mut std::task::Context<'_>) -> std::task::Poll<Self::Output> {
204-
if self.Status()? == AsyncStatus::Started {
205-
let waker = context.waker().clone();
206-
let _ = self.SetCompleted(&AsyncActionWithProgressCompletedHandler::new(move |_sender, _args| {
207-
waker.wake_by_ref();
208-
Ok(())
209-
}));
210-
std::task::Poll::Pending
211-
} else {
212-
std::task::Poll::Ready(self.GetResults())
213-
}
214-
}
215-
}
216186
unsafe impl<TProgress: windows_core::RuntimeType + 'static> Send for IAsyncActionWithProgress<TProgress> {}
217187
unsafe impl<TProgress: windows_core::RuntimeType + 'static> Sync for IAsyncActionWithProgress<TProgress> {}
218188
impl<TProgress: windows_core::RuntimeType + 'static> windows_core::RuntimeType for IAsyncActionWithProgress<TProgress> {
@@ -368,21 +338,6 @@ impl<TResult: windows_core::RuntimeType + 'static> IAsyncOperation<TResult> {
368338
self.GetResults()
369339
}
370340
}
371-
impl<TResult: windows_core::RuntimeType + 'static> std::future::Future for IAsyncOperation<TResult> {
372-
type Output = windows_core::Result<TResult>;
373-
fn poll(self: std::pin::Pin<&mut Self>, context: &mut std::task::Context<'_>) -> std::task::Poll<Self::Output> {
374-
if self.Status()? == AsyncStatus::Started {
375-
let waker = context.waker().clone();
376-
let _ = self.SetCompleted(&AsyncOperationCompletedHandler::new(move |_sender, _args| {
377-
waker.wake_by_ref();
378-
Ok(())
379-
}));
380-
std::task::Poll::Pending
381-
} else {
382-
std::task::Poll::Ready(self.GetResults())
383-
}
384-
}
385-
}
386341
unsafe impl<TResult: windows_core::RuntimeType + 'static> Send for IAsyncOperation<TResult> {}
387342
unsafe impl<TResult: windows_core::RuntimeType + 'static> Sync for IAsyncOperation<TResult> {}
388343
impl<TResult: windows_core::RuntimeType + 'static> windows_core::RuntimeType for IAsyncOperation<TResult> {
@@ -500,21 +455,6 @@ impl<TResult: windows_core::RuntimeType + 'static, TProgress: windows_core::Runt
500455
self.GetResults()
501456
}
502457
}
503-
impl<TResult: windows_core::RuntimeType + 'static, TProgress: windows_core::RuntimeType + 'static> std::future::Future for IAsyncOperationWithProgress<TResult, TProgress> {
504-
type Output = windows_core::Result<TResult>;
505-
fn poll(self: std::pin::Pin<&mut Self>, context: &mut std::task::Context<'_>) -> std::task::Poll<Self::Output> {
506-
if self.Status()? == AsyncStatus::Started {
507-
let waker = context.waker().clone();
508-
let _ = self.SetCompleted(&AsyncOperationWithProgressCompletedHandler::new(move |_sender, _args| {
509-
waker.wake_by_ref();
510-
Ok(())
511-
}));
512-
std::task::Poll::Pending
513-
} else {
514-
std::task::Poll::Ready(self.GetResults())
515-
}
516-
}
517-
}
518458
unsafe impl<TResult: windows_core::RuntimeType + 'static, TProgress: windows_core::RuntimeType + 'static> Send for IAsyncOperationWithProgress<TResult, TProgress> {}
519459
unsafe impl<TResult: windows_core::RuntimeType + 'static, TProgress: windows_core::RuntimeType + 'static> Sync for IAsyncOperationWithProgress<TResult, TProgress> {}
520460
impl<TResult: windows_core::RuntimeType + 'static, TProgress: windows_core::RuntimeType + 'static> windows_core::RuntimeType for IAsyncOperationWithProgress<TResult, TProgress> {

crates/libs/windows/src/Windows/Security/Authentication/OnlineId/mod.rs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -504,21 +504,6 @@ impl SignOutUserOperation {
504504
self.GetResults()
505505
}
506506
}
507-
impl std::future::Future for SignOutUserOperation {
508-
type Output = windows_core::Result<()>;
509-
fn poll(self: std::pin::Pin<&mut Self>, context: &mut std::task::Context<'_>) -> std::task::Poll<Self::Output> {
510-
if self.Status()? == super::super::super::Foundation::AsyncStatus::Started {
511-
let waker = context.waker().clone();
512-
let _ = self.SetCompleted(&super::super::super::Foundation::AsyncActionCompletedHandler::new(move |_sender, _args| {
513-
waker.wake_by_ref();
514-
Ok(())
515-
}));
516-
std::task::Poll::Pending
517-
} else {
518-
std::task::Poll::Ready(self.GetResults())
519-
}
520-
}
521-
}
522507
unsafe impl Send for SignOutUserOperation {}
523508
unsafe impl Sync for SignOutUserOperation {}
524509
#[repr(transparent)]
@@ -602,21 +587,6 @@ impl UserAuthenticationOperation {
602587
self.GetResults()
603588
}
604589
}
605-
impl std::future::Future for UserAuthenticationOperation {
606-
type Output = windows_core::Result<UserIdentity>;
607-
fn poll(self: std::pin::Pin<&mut Self>, context: &mut std::task::Context<'_>) -> std::task::Poll<Self::Output> {
608-
if self.Status()? == super::super::super::Foundation::AsyncStatus::Started {
609-
let waker = context.waker().clone();
610-
let _ = self.SetCompleted(&super::super::super::Foundation::AsyncOperationCompletedHandler::new(move |_sender, _args| {
611-
waker.wake_by_ref();
612-
Ok(())
613-
}));
614-
std::task::Poll::Pending
615-
} else {
616-
std::task::Poll::Ready(self.GetResults())
617-
}
618-
}
619-
}
620590
unsafe impl Send for UserAuthenticationOperation {}
621591
unsafe impl Sync for UserAuthenticationOperation {}
622592
#[repr(transparent)]

crates/libs/windows/src/Windows/Storage/Streams/mod.rs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,21 +1325,6 @@ impl DataReaderLoadOperation {
13251325
self.GetResults()
13261326
}
13271327
}
1328-
impl std::future::Future for DataReaderLoadOperation {
1329-
type Output = windows_core::Result<u32>;
1330-
fn poll(self: std::pin::Pin<&mut Self>, context: &mut std::task::Context<'_>) -> std::task::Poll<Self::Output> {
1331-
if self.Status()? == super::super::Foundation::AsyncStatus::Started {
1332-
let waker = context.waker().clone();
1333-
let _ = self.SetCompleted(&super::super::Foundation::AsyncOperationCompletedHandler::new(move |_sender, _args| {
1334-
waker.wake_by_ref();
1335-
Ok(())
1336-
}));
1337-
std::task::Poll::Pending
1338-
} else {
1339-
std::task::Poll::Ready(self.GetResults())
1340-
}
1341-
}
1342-
}
13431328
unsafe impl Send for DataReaderLoadOperation {}
13441329
unsafe impl Sync for DataReaderLoadOperation {}
13451330
#[repr(transparent)]
@@ -1608,21 +1593,6 @@ impl DataWriterStoreOperation {
16081593
self.GetResults()
16091594
}
16101595
}
1611-
impl std::future::Future for DataWriterStoreOperation {
1612-
type Output = windows_core::Result<u32>;
1613-
fn poll(self: std::pin::Pin<&mut Self>, context: &mut std::task::Context<'_>) -> std::task::Poll<Self::Output> {
1614-
if self.Status()? == super::super::Foundation::AsyncStatus::Started {
1615-
let waker = context.waker().clone();
1616-
let _ = self.SetCompleted(&super::super::Foundation::AsyncOperationCompletedHandler::new(move |_sender, _args| {
1617-
waker.wake_by_ref();
1618-
Ok(())
1619-
}));
1620-
std::task::Poll::Pending
1621-
} else {
1622-
std::task::Poll::Ready(self.GetResults())
1623-
}
1624-
}
1625-
}
16261596
unsafe impl Send for DataWriterStoreOperation {}
16271597
unsafe impl Sync for DataWriterStoreOperation {}
16281598
#[repr(transparent)]

crates/samples/windows/ocr/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ version = "0.0.0"
44
edition = "2021"
55
publish = false
66

7-
[dependencies]
8-
futures = "0.3.5"
9-
107
[dependencies.windows]
118
path = "../../../libs/windows"
129
features = [

crates/samples/windows/ocr/src/main.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,18 @@ use windows::{
66
};
77

88
fn main() -> Result<()> {
9-
futures::executor::block_on(main_async())
10-
}
11-
12-
async fn main_async() -> Result<()> {
139
let mut message = std::env::current_dir().unwrap();
1410
message.push("message.png");
1511

1612
let file =
17-
StorageFile::GetFileFromPathAsync(&HSTRING::from(message.to_str().unwrap()))?.await?;
18-
let stream = file.OpenAsync(FileAccessMode::Read)?.await?;
13+
StorageFile::GetFileFromPathAsync(&HSTRING::from(message.to_str().unwrap()))?.get()?;
14+
let stream = file.OpenAsync(FileAccessMode::Read)?.get()?;
1915

20-
let decode = BitmapDecoder::CreateAsync(&stream)?.await?;
21-
let bitmap = decode.GetSoftwareBitmapAsync()?.await?;
16+
let decode = BitmapDecoder::CreateAsync(&stream)?.get()?;
17+
let bitmap = decode.GetSoftwareBitmapAsync()?.get()?;
2218

2319
let engine = OcrEngine::TryCreateFromUserProfileLanguages()?;
24-
let result = engine.RecognizeAsync(&bitmap)?.await?;
20+
let result = engine.RecognizeAsync(&bitmap)?.get()?;
2521

2622
println!("{}", result.Text()?);
2723
Ok(())

crates/tests/winrt/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,4 @@ features = [
2929
]
3030

3131
[dev-dependencies]
32-
futures = "0.3"
3332
helpers = { package = "test_helpers", path = "../helpers" }

0 commit comments

Comments
 (0)