use std::future::Future;
use std::path::PathBuf;
use std::pin::Pin;
use std::sync::Arc;
use crate::transcripts::CloudTranscript;
use crate::{AuthProvider, Backend, SyncObserver};
pub type Spawner = fn(Pin<Box<dyn Future<Output = ()> + Send + 'static>>);
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct HistoryRow {
pub delivery_id: String,
pub text: String,
pub raw_text: Option<String>,
pub created_at_ms: u64,
pub synced_from: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct HistoryKey {
pub delivery_id: String,
pub synced_from: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct KeyWindow {
pub keys: Vec<HistoryKey>,
pub next: Option<String>,
}
pub trait HistorySession {
fn key_window(&mut self, cursor: Option<&str>, limit: usize) -> Result<KeyWindow, String>;
fn rows_by_id(&mut self, delivery_ids: &[String]) -> Result<Vec<HistoryRow>, String>;
fn delete(&mut self, delivery_ids: &[String]) -> Result<(), String>;
fn insert_synced(&mut self, items: &[CloudTranscript]) -> Result<(), String>;
}
pub trait TranscriptHost: Send + Sync + 'static {
fn data_file(&self, name: &str) -> PathBuf;
fn open_history(&self) -> Result<Box<dyn HistorySession>, String>;
fn history_changed(&self);
fn busy_reason(&self) -> Option<&'static str>;
fn recovery_pending(&self, scope: &str) -> bool;
fn recovery_complete(&self, scope: &str, consent_generation: u64) -> Result<(), String>;
fn now_ms(&self) -> u64;
fn downloaded(&self, count: u32);
}
pub trait NativeObserver: Send + Sync {
fn install(&self, callback: extern "C" fn(i32));
fn set_enabled(&self, enabled: bool);
fn invalidate_subscription(&self);
}
pub trait SyncTransport: Send + Sync {
fn state_file_name(&self, base: &str) -> String;
fn legacy_import(&self) -> bool;
fn prepare(&self) -> Result<(), String>;
fn backend(&self) -> Result<Arc<dyn Backend>, String>;
fn auth(&self) -> Result<Arc<dyn AuthProvider>, String>;
fn observer(&self) -> Arc<dyn SyncObserver>;
fn set_enabled(&self, enabled: bool) -> Result<(), String>;
fn confirmed_stopped(&self) -> Option<bool>;
fn native_observer(&self) -> Option<Arc<dyn NativeObserver>>;
}