use std::borrow::Cow;
use crate::listener::HistoryListener;
use crate::location::Location;
#[cfg(feature = "query")]
use crate::{error::HistoryResult, query::ToQuery};
pub trait History: Clone + PartialEq {
fn len(&self) -> usize;
fn is_empty(&self) -> bool {
self.len() == 0
}
fn back(&self) {
self.go(-1);
}
fn forward(&self) {
self.go(1);
}
fn go(&self, delta: isize);
fn push<'a>(&self, route: impl Into<Cow<'a, str>>);
fn replace<'a>(&self, route: impl Into<Cow<'a, str>>);
fn push_with_state<'a, T>(&self, route: impl Into<Cow<'a, str>>, state: T)
where
T: 'static;
fn replace_with_state<'a, T>(&self, route: impl Into<Cow<'a, str>>, state: T)
where
T: 'static;
#[cfg(feature = "query")]
fn push_with_query<'a, Q>(
&self,
route: impl Into<Cow<'a, str>>,
query: Q,
) -> HistoryResult<(), Q::Error>
where
Q: ToQuery;
#[cfg(feature = "query")]
fn replace_with_query<'a, Q>(
&self,
route: impl Into<Cow<'a, str>>,
query: Q,
) -> HistoryResult<(), Q::Error>
where
Q: ToQuery;
#[cfg(feature = "query")]
fn push_with_query_and_state<'a, Q, T>(
&self,
route: impl Into<Cow<'a, str>>,
query: Q,
state: T,
) -> HistoryResult<(), Q::Error>
where
Q: ToQuery,
T: 'static;
#[cfg(feature = "query")]
fn replace_with_query_and_state<'a, Q, T>(
&self,
route: impl Into<Cow<'a, str>>,
query: Q,
state: T,
) -> HistoryResult<(), Q::Error>
where
Q: ToQuery,
T: 'static;
fn listen<CB>(&self, callback: CB) -> HistoryListener
where
CB: Fn() + 'static;
fn location(&self) -> Location;
}