tuwunel_admin/debug/
memory_stats.rs1use tuwunel_core::Result;
2
3use crate::admin_command;
4
5#[admin_command]
6pub(super) async fn memory_stats(&self, opts: Option<String>) -> Result {
7 const OPTS: &str = "abcdefghijklmnopqrstuvwxyz";
8
9 let opts: String = OPTS
10 .chars()
11 .filter(|&c| {
12 let allow_any = opts.as_ref().is_some_and(|opts| opts == "*");
13
14 let allow = allow_any || opts.as_ref().is_some_and(|opts| opts.contains(c));
15
16 !allow
17 })
18 .collect();
19
20 let stats = tuwunel_core::alloc::memory_stats(&opts).unwrap_or_default();
21
22 self.write_str("```\n").await?;
23 self.write_str(&stats).await?;
24 self.write_str("\n```").await?;
25 Ok(())
26}