pub struct TemplateManager { /* private fields */ }Expand description
Управляет получением, кэшированием и доступом к шаблонам исключений.
Implementations§
Source§impl TemplateManager
impl TemplateManager
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Создает новый экземпляр TemplateManager.
Инициализирует пути, загружает конфигурацию и кэшированные шаблоны.
§Ошибки
Возвращает ошибку, если не удается определить домашнюю директорию или создать/прочитать файлы конфигурации.
Sourcepub async fn update_if_needed(&mut self) -> Result<()>
pub async fn update_if_needed(&mut self) -> Result<()>
Загружает шаблоны из API, если кэш устарел или отсутствует.
§Логика обновления
- Если кэш актуален -> ничего не делаем.
- Если кэш устарел, пробуем скачать.
- Если скачивание не удалось, но есть старый кэш -> используем его (soft fail).
- Если шаблонов нет вообще и скачивание не удалось -> возвращаем ошибку.
Sourcepub async fn force_update(&mut self) -> Result<()>
pub async fn force_update(&mut self) -> Result<()>
Принудительно обновляет шаблоны из API.
Sourcepub fn get_available_templates(&self) -> Vec<String>
pub fn get_available_templates(&self) -> Vec<String>
Возвращает список ключей всех доступных шаблонов.
Sourcepub fn get_template_contents(&self, key: &str) -> Option<&str>
pub fn get_template_contents(&self, key: &str) -> Option<&str>
Возвращает содержимое шаблона по его ключу.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TemplateManager
impl RefUnwindSafe for TemplateManager
impl Send for TemplateManager
impl Sync for TemplateManager
impl Unpin for TemplateManager
impl UnwindSafe for TemplateManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more