#[cfg(target_arch = "wasm32")]
mod browser;
mod memory;
#[cfg(target_arch = "wasm32")]
pub use browser::{BrowserHistory, HistoryMode};
pub use memory::MemoryHistory;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct EntryKey(pub u64);
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct HistoryEntry {
pub url: String,
pub key: EntryKey,
}
pub trait History {
fn current(&self) -> HistoryEntry;
fn push(&mut self, url: &str) -> EntryKey;
fn replace(&mut self, url: &str);
fn back(&mut self);
fn forward(&mut self);
fn can_go_back(&self) -> bool;
fn can_go_forward(&self) -> bool;
fn poll(&mut self, ctx: &egui::Context) -> Option<HistoryEntry>;
}
pub fn default_history() -> impl History {
#[cfg(target_arch = "wasm32")]
{
BrowserHistory::new(HistoryMode::Path)
}
#[cfg(not(target_arch = "wasm32"))]
{
MemoryHistory::new("/")
}
}