use crate::snapshot::types::{ActiveAllocation, ThreadMemoryStats};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum Query {
TopAllocationsBySize { limit: usize },
TopAllocationsByCount { limit: usize },
MemoryLeaks { min_age_ms: u64 },
LargeAllocations { min_size: usize },
ThreadMemoryStats { thread_id: u64 },
ScopeMemoryStats { scope_name: String },
TypeMemoryStats { type_name: String },
Summary,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum QueryResult {
Allocations(AllocationQueryResult),
Threads(ThreadQueryResult),
Summary(SummaryQueryResult),
Empty,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AllocationQueryResult {
pub count: usize,
pub total_bytes: usize,
pub allocations: Vec<ActiveAllocation>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ThreadQueryResult {
pub count: usize,
pub total_bytes: usize,
pub threads: Vec<ThreadMemoryStats>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SummaryQueryResult {
pub total_allocations: usize,
pub total_deallocations: usize,
pub active_allocations: usize,
pub total_allocated: usize,
pub total_deallocated: usize,
pub current_memory: usize,
pub peak_memory: usize,
pub thread_count: usize,
}