Add session stats to desktop app

This commit is contained in:
Igor Katson 2024-08-21 13:22:22 +01:00
parent 857db0caf4
commit 93c53b4285
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
5 changed files with 17 additions and 3 deletions

View file

@ -19,6 +19,7 @@ use librqbit::{
TorrentListResponse, TorrentStats,
},
dht::PersistentDhtConfig,
session_stats::snapshot::SessionStatsSnapshot,
tracing_subscriber_config_utils::{init_logging, InitLoggingOptions, InitLoggingResult},
AddTorrent, AddTorrentOptions, Api, ApiError, PeerConnectionOptions, Session, SessionOptions,
SessionPersistenceConfig,
@ -318,6 +319,11 @@ async fn torrent_action_configure(
.await
}
#[tauri::command]
async fn stats(state: tauri::State<'_, State>) -> Result<SessionStatsSnapshot, ApiError> {
Ok(state.api()?.api_session_stats())
}
#[tauri::command]
fn get_version() -> &'static str {
env!("CARGO_PKG_VERSION")
@ -352,6 +358,7 @@ async fn start() {
torrent_action_start,
torrent_action_configure,
torrent_create_from_base64_file,
stats,
get_version,
config_default,
config_current,