This commit is contained in:
2023-06-06 22:47:00 +02:00
parent b902e5f488
commit 8f8f092737
3 changed files with 14 additions and 9 deletions

View File

@@ -1,3 +1,4 @@
use core::fmt::Debug;
use std::str::FromStr; use std::str::FromStr;
use moka::future::Cache; use moka::future::Cache;
@@ -121,8 +122,8 @@ async fn send_book_handler<T, P, Fut>(
user_langs_cache: Cache<UserId, Vec<String>>, user_langs_cache: Cache<UserId, Vec<String>>,
) -> crate::bots::BotHandlerInternal ) -> crate::bots::BotHandlerInternal
where where
T: Format + Clone, T: Format + Clone + Debug,
P: FormatTitle + Clone, P: FormatTitle + Clone + Debug,
Fut: std::future::Future<Output = Result<Page<T, P>, Box<dyn std::error::Error + Send + Sync>>>, Fut: std::future::Future<Output = Result<Page<T, P>, Box<dyn std::error::Error + Send + Sync>>>,
{ {
let id = match command { let id = match command {
@@ -198,8 +199,8 @@ async fn send_pagination_book_handler<T, P, Fut>(
user_langs_cache: Cache<UserId, Vec<String>>, user_langs_cache: Cache<UserId, Vec<String>>,
) -> crate::bots::BotHandlerInternal ) -> crate::bots::BotHandlerInternal
where where
T: Format + Clone, T: Format + Clone + Debug,
P: FormatTitle + Clone, P: FormatTitle + Clone + Debug,
Fut: std::future::Future<Output = Result<Page<T, P>, Box<dyn std::error::Error + Send + Sync>>>, Fut: std::future::Future<Output = Result<Page<T, P>, Box<dyn std::error::Error + Send + Sync>>>,
{ {
let (id, page) = match callback_data { let (id, page) = match callback_data {

View File

@@ -1,3 +1,4 @@
use core::fmt::Debug;
use std::str::FromStr; use std::str::FromStr;
use moka::future::Cache; use moka::future::Cache;
@@ -114,8 +115,8 @@ async fn generic_search_pagination_handler<T, P, Fut>(
user_langs_cache: Cache<UserId, Vec<String>>, user_langs_cache: Cache<UserId, Vec<String>>,
) -> BotHandlerInternal ) -> BotHandlerInternal
where where
T: Format + Clone, T: Format + Clone + Debug,
P: FormatTitle + Clone, P: FormatTitle + Clone + Debug,
Fut: std::future::Future<Output = Result<Page<T, P>, Box<dyn std::error::Error + Send + Sync>>>, Fut: std::future::Future<Output = Result<Page<T, P>, Box<dyn std::error::Error + Send + Sync>>>,
{ {
let chat_id = cq.chat_id(); let chat_id = cq.chat_id();

View File

@@ -1,3 +1,4 @@
use core::fmt::Debug;
use serde::Deserialize; use serde::Deserialize;
use super::formaters::{Format, FormatResult, FormatTitle}; use super::formaters::{Format, FormatResult, FormatTitle};
@@ -90,16 +91,18 @@ pub struct Page<T, P> {
impl<T, P> Page<T, P> impl<T, P> Page<T, P>
where where
T: Format + Clone, T: Format + Clone + Debug,
P: FormatTitle + Clone P: FormatTitle + Clone + Debug
{ {
pub fn format_items(&self, max_size: usize) -> String { pub fn format_items(&self, max_size: usize) -> String {
log::error!("format: {:?}", self);
let title: String = match &self.parent_item { let title: String = match &self.parent_item {
Some(parent_item) => { Some(parent_item) => {
let item_title = parent_item.format_title(); let item_title = parent_item.format_title();
if item_title.is_empty() { if item_title.is_empty() {
return "".to_string(); return item_title;
} }
format!("{item_title}\n\n\n") format!("{item_title}\n\n\n")