style: auto-format entire codebase with cargo fmt (stable rustfmt.toml)
Some checks failed
ci/woodpecker/pr/check Pipeline failed
CI / Check (pull_request) Has been cancelled
CI / Format (pull_request) Has been cancelled
CI / Clippy (pull_request) Has been cancelled
CI / Build (macos-latest) (pull_request) Has been cancelled
CI / Build (ubuntu-latest) (pull_request) Has been cancelled
CI / Build (windows-latest) (pull_request) Has been cancelled
Some checks failed
ci/woodpecker/pr/check Pipeline failed
CI / Check (pull_request) Has been cancelled
CI / Format (pull_request) Has been cancelled
CI / Clippy (pull_request) Has been cancelled
CI / Build (macos-latest) (pull_request) Has been cancelled
CI / Build (ubuntu-latest) (pull_request) Has been cancelled
CI / Build (windows-latest) (pull_request) Has been cancelled
This commit is contained in:
@@ -28,7 +28,7 @@ impl ImageRenderer {
|
||||
/// Создаёт ImageRenderer с автодетектом протокола (высокое качество для modal)
|
||||
pub fn new() -> Option<Self> {
|
||||
let picker = Picker::from_query_stdio().ok()?;
|
||||
|
||||
|
||||
Some(Self {
|
||||
picker,
|
||||
protocols: HashMap::new(),
|
||||
@@ -41,7 +41,7 @@ impl ImageRenderer {
|
||||
pub fn new_fast() -> Option<Self> {
|
||||
let mut picker = Picker::from_fontsize((8, 12));
|
||||
picker.set_protocol_type(ProtocolType::Halfblocks);
|
||||
|
||||
|
||||
Some(Self {
|
||||
picker,
|
||||
protocols: HashMap::new(),
|
||||
@@ -51,7 +51,7 @@ impl ImageRenderer {
|
||||
}
|
||||
|
||||
/// Загружает изображение из файла и создаёт протокол рендеринга.
|
||||
///
|
||||
///
|
||||
/// Если протокол уже существует, не загружает повторно (кэширование).
|
||||
/// Использует LRU eviction при превышении лимита.
|
||||
pub fn load_image(&mut self, msg_id: MessageId, path: &str) -> Result<(), String> {
|
||||
@@ -76,7 +76,7 @@ impl ImageRenderer {
|
||||
|
||||
let protocol = self.picker.new_resize_protocol(img);
|
||||
self.protocols.insert(msg_id_i64, protocol);
|
||||
|
||||
|
||||
// Обновляем access order
|
||||
self.access_counter += 1;
|
||||
self.access_order.insert(msg_id_i64, self.access_counter);
|
||||
@@ -93,17 +93,17 @@ impl ImageRenderer {
|
||||
}
|
||||
|
||||
/// Получает мутабельную ссылку на протокол для рендеринга.
|
||||
///
|
||||
///
|
||||
/// Обновляет access time для LRU.
|
||||
pub fn get_protocol(&mut self, msg_id: &MessageId) -> Option<&mut StatefulProtocol> {
|
||||
let msg_id_i64 = msg_id.as_i64();
|
||||
|
||||
|
||||
if self.protocols.contains_key(&msg_id_i64) {
|
||||
// Обновляем access time
|
||||
self.access_counter += 1;
|
||||
self.access_order.insert(msg_id_i64, self.access_counter);
|
||||
}
|
||||
|
||||
|
||||
self.protocols.get_mut(&msg_id_i64)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user