mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-05-24 01:00:49 +00:00
Implement lazy score queries for top
, recent
and check
(#71)
* Use streams and such to have 200 results * WIP * display should take a lazy score future * Introduce a Scores stream so we can lazily load top score requests * Fit range to len * Remove debugging * Simplify from_user with `and_then`
This commit is contained in:
parent
8fdd576eb9
commit
87e0a02e1f
13 changed files with 482 additions and 200 deletions
|
@ -14,9 +14,33 @@ const PREV: &str = "youmubot_pagination_prev";
|
|||
const FAST_NEXT: &str = "youmubot_pagination_fast_next";
|
||||
const FAST_PREV: &str = "youmubot_pagination_fast_prev";
|
||||
|
||||
pub trait CanEdit: Send {
|
||||
pub trait CanEdit: Send + Sized {
|
||||
fn get_message(&self) -> impl Future<Output = Result<Message>> + Send;
|
||||
fn apply_edit(&mut self, edit: CreateReply) -> impl Future<Output = Result<()>> + Send;
|
||||
|
||||
fn headers(&self) -> Option<&str> {
|
||||
None
|
||||
}
|
||||
|
||||
fn with_header(self, header: String) -> impl CanEdit {
|
||||
WithHeaders(self, header)
|
||||
}
|
||||
}
|
||||
|
||||
struct WithHeaders<T>(T, String);
|
||||
|
||||
impl<T: CanEdit> CanEdit for WithHeaders<T> {
|
||||
fn get_message(&self) -> impl Future<Output = Result<Message>> + Send {
|
||||
self.0.get_message()
|
||||
}
|
||||
|
||||
fn apply_edit(&mut self, edit: CreateReply) -> impl Future<Output = Result<()>> + Send {
|
||||
self.0.apply_edit(edit)
|
||||
}
|
||||
|
||||
fn headers(&self) -> Option<&str> {
|
||||
Some(&self.1)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> CanEdit for (Message, &'a Context) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue