This commit is contained in:
Natsu Kagami 2025-05-11 15:13:43 -04:00
parent 0661199420
commit 11e34e0c78
Signed by: nki
GPG key ID: 55A032EB38B49ADB
5 changed files with 78 additions and 65 deletions

View file

@ -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) {