add tsf availability check

This commit is contained in:
mii
2025-03-05 02:52:00 +09:00
parent 723445786e
commit 89b688176b
7 changed files with 244 additions and 10 deletions

View File

@ -0,0 +1,24 @@
use anyhow::Result;
use tracing::{error, info};
use crate::tsf::{search_candidate_provider::SearchCandidateProvider, set_thread_local_input_settings};
pub fn check_tsf_availability() -> Result<bool> {
info!("Checking TSF availability");
if let Err(e) = set_thread_local_input_settings(true) {
error!("Failed to set thread local input settings: {:?}", e);
return Ok(false);
}
match SearchCandidateProvider::create() {
Ok(_) => {
info!("TSF is available");
Ok(true)
}
Err(e) => {
error!("Failed to create SearchCandidateProvider: {:?}", e);
Ok(false)
}
}
}