瀏覽代碼

doesnt work :(

Lucas Nogueira 1 年之前
父節點
當前提交
1cb0d8e521
共有 1 個文件被更改,包括 23 次插入1 次删除
  1. 23 1
      core/tauri/src/ipc/command.rs

+ 23 - 1
core/tauri/src/ipc/command.rs

@@ -246,7 +246,7 @@ pub mod private {
     }
   }
 
-  // ===== Result<impl Serialize, impl Into<InvokeError>> =====
+  // ===== Result<impl IpcResponse, impl Into<InvokeError>> =====
 
   pub struct ResultTag(InvokeResponse);
 
@@ -293,6 +293,28 @@ pub mod private {
     }
   }
 
+  // ===== Future<Output = Vec<u8>> =====
+
+  pub struct BufferFutureTag<F: Future<Output = Vec<u8>>>(Pin<Box<F>>);
+
+  pub trait BufferFutureKind<F: Future<Output = Vec<u8>>> {
+    fn async_kind(self) -> BufferFutureTag<F>;
+  }
+
+  impl<F: Future<Output = Vec<u8>>> BufferFutureKind<F> for F {
+    #[inline(always)]
+    fn async_kind(self) -> BufferFutureTag<F> {
+      BufferFutureTag(Box::pin(self))
+    }
+  }
+
+  impl<F: Future<Output = Vec<u8>>> BufferFutureTag<F> {
+    #[inline(always)]
+    pub fn future(self) -> impl Future<Output = Result<InvokeResponseBody, InvokeError>> {
+      self.0.map(|value| Ok(InvokeResponseBody::Raw(value)))
+    }
+  }
+
   // ===== Future<Output = impl IpcResponse> =====
 
   pub struct FutureTag<T: IpcResponse, F: Future<Output = T>>(Pin<Box<F>>);