mod league_rules;
mod leagues;
mod pvp_matches;
mod stashes;
pub use self::league_rules::LeagueRules;
pub use self::leagues::Leagues;
pub use self::pvp_matches::PvpMatches;
pub use self::stashes::Stashes;
use std::borrow::Borrow;
use std::fmt::Debug;
use std::ops::Deref;
use futures::Stream as StdStream;
use super::error::Error;
pub type Stream<T, E = Error> = Box<StdStream<Item = T, Error = E>>;
#[derive(Debug)]
pub struct Batched<T: Debug, C = String> {
entry: T,
curr_token: Option<C>,
next_token: Option<C>,
}
impl<T: Debug, C> Deref for Batched<T, C> {
type Target = T;
fn deref(&self) -> &Self::Target {
&self.entry
}
}
impl<T: Debug, C> Batched<T, C> {
#[inline]
pub fn current_batch_token<Q>(&self) -> Option<&Q>
where Q: ?Sized, C: Borrow<Q>
{
self.curr_token.as_ref().map(|t| t.borrow())
}
#[inline]
pub fn next_batch_token<Q>(&self) -> Option<&Q>
where Q: ?Sized, C: Borrow<Q>
{
self.next_token.as_ref().map(|t| t.borrow())
}
}
#[cfg(test)]
mod tests {
use super::Batched;
#[test]
fn batched_with_string_token() {
let batched: Batched<(), String> = Batched{
entry: (), curr_token: None, next_token: Some("foo".into())
};
let token: &str = batched.next_batch_token().unwrap();
assert_eq!("foo", token);
}
}