mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-08-18 05:41:48 +00:00

* chore: observe file upload state * chore: observe file upload state * chore: upgrade client api * Update frontend/appflowy_flutter/lib/startup/tasks/file_storage_task.dart Co-authored-by: Lucas.Xu <lucas.xu@appflowy.io> * chore: fix tauri build --------- Co-authored-by: Lucas.Xu <lucas.xu@appflowy.io>
47 lines
1.0 KiB
Rust
47 lines
1.0 KiB
Rust
use allo_isolate::{IntoDart, Isolate};
|
|
use anyhow::anyhow;
|
|
use futures::Sink;
|
|
pub use futures_util::sink::SinkExt;
|
|
use pin_project::pin_project;
|
|
use std::pin::Pin;
|
|
use std::task::{Context, Poll};
|
|
|
|
#[pin_project]
|
|
pub struct IsolateSink {
|
|
isolate: Isolate,
|
|
}
|
|
|
|
impl IsolateSink {
|
|
pub fn new(isolate: Isolate) -> Self {
|
|
Self { isolate }
|
|
}
|
|
}
|
|
|
|
impl<T> Sink<T> for IsolateSink
|
|
where
|
|
T: IntoDart,
|
|
{
|
|
type Error = anyhow::Error;
|
|
|
|
fn poll_ready(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
|
Poll::Ready(Ok(()))
|
|
}
|
|
|
|
fn start_send(self: Pin<&mut Self>, item: T) -> Result<(), Self::Error> {
|
|
let this = self.project();
|
|
if this.isolate.post(item) {
|
|
Ok(())
|
|
} else {
|
|
Err(anyhow!("failed to post message"))
|
|
}
|
|
}
|
|
|
|
fn poll_flush(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
|
Poll::Ready(Ok(()))
|
|
}
|
|
|
|
fn poll_close(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
|
Poll::Ready(Ok(()))
|
|
}
|
|
}
|