pub struct DebugToolbar { /* private fields */ }Expand description
Debug toolbar
Implementations§
Source§impl DebugToolbar
impl DebugToolbar
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new debug toolbar
§Examples
use reinhardt_test::debug::DebugToolbar;
let toolbar = DebugToolbar::new();
assert!(toolbar.is_enabled());Sourcepub fn set_enabled(&mut self, enabled: bool)
pub fn set_enabled(&mut self, enabled: bool)
Enable or disable the debug toolbar
§Examples
use reinhardt_test::debug::DebugToolbar;
let mut toolbar = DebugToolbar::new();
toolbar.set_enabled(false);
assert!(!toolbar.is_enabled());Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if the debug toolbar is enabled
§Examples
use reinhardt_test::debug::DebugToolbar;
let toolbar = DebugToolbar::new();
assert!(toolbar.is_enabled());Sourcepub async fn add_panel(&self, id: String, panel: DebugPanel)
pub async fn add_panel(&self, id: String, panel: DebugPanel)
Add a debug panel
§Examples
use reinhardt_test::debug::{DebugToolbar, DebugPanel, DebugEntry};
let toolbar = DebugToolbar::new();
let panel = DebugPanel {
title: "Test Panel".to_string(),
content: vec![DebugEntry::Text { text: "Hello".to_string() }],
};
toolbar.add_panel("test".to_string(), panel).await;
let panels = toolbar.get_panels().await;
assert!(panels.contains_key("test"));Sourcepub async fn record_sql_query(&self, query: String, duration: Duration)
pub async fn record_sql_query(&self, query: String, duration: Duration)
Record SQL query
§Examples
use reinhardt_test::debug::DebugToolbar;
use std::time::Duration;
let toolbar = DebugToolbar::new();
toolbar.record_sql_query("SELECT * FROM users".to_string(), Duration::from_millis(10)).await;
let timing = toolbar.get_timing().await;
assert_eq!(timing.sql_queries, 1);
assert!(timing.sql_time >= Duration::from_millis(10));Sourcepub async fn record_cache_hit(&self)
pub async fn record_cache_hit(&self)
Record cache hit
§Examples
use reinhardt_test::debug::DebugToolbar;
let toolbar = DebugToolbar::new();
toolbar.record_cache_hit().await;
let timing = toolbar.get_timing().await;
assert_eq!(timing.cache_hits, 1);Sourcepub async fn record_cache_miss(&self)
pub async fn record_cache_miss(&self)
Record cache miss
§Examples
use reinhardt_test::debug::DebugToolbar;
let toolbar = DebugToolbar::new();
toolbar.record_cache_miss().await;
let timing = toolbar.get_timing().await;
assert_eq!(timing.cache_misses, 1);Sourcepub async fn finalize(&self)
pub async fn finalize(&self)
Finalize timing information
§Examples
use reinhardt_test::debug::DebugToolbar;
use std::time::Duration;
let toolbar = DebugToolbar::new();
// Simulate some work
tokio::time::sleep(Duration::from_millis(10)).await;
toolbar.finalize().await;
let timing = toolbar.get_timing().await;
assert!(timing.total_time >= Duration::from_millis(10));Sourcepub async fn get_panels(&self) -> HashMap<String, DebugPanel>
pub async fn get_panels(&self) -> HashMap<String, DebugPanel>
Get all panels
§Examples
use reinhardt_test::debug::{DebugToolbar, DebugPanel, DebugEntry};
let toolbar = DebugToolbar::new();
let panel = DebugPanel {
title: "Test".to_string(),
content: vec![],
};
toolbar.add_panel("test".to_string(), panel).await;
let panels = toolbar.get_panels().await;
assert_eq!(panels.len(), 1);Sourcepub async fn get_timing(&self) -> TimingInfo
pub async fn get_timing(&self) -> TimingInfo
Get timing info
§Examples
use reinhardt_test::debug::DebugToolbar;
let toolbar = DebugToolbar::new();
let timing = toolbar.get_timing().await;
assert_eq!(timing.sql_queries, 0);
assert_eq!(timing.cache_hits, 0);Sourcepub async fn get_sql_queries(&self) -> Vec<SqlQuery>
pub async fn get_sql_queries(&self) -> Vec<SqlQuery>
Get SQL queries
§Examples
use reinhardt_test::debug::DebugToolbar;
use std::time::Duration;
let toolbar = DebugToolbar::new();
toolbar.record_sql_query("SELECT 1".to_string(), Duration::from_millis(5)).await;
let queries = toolbar.get_sql_queries().await;
assert_eq!(queries.len(), 1);
assert_eq!(queries[0].query, "SELECT 1");Sourcepub async fn render_html(&self) -> String
pub async fn render_html(&self) -> String
Render as HTML
§Examples
use reinhardt_test::debug::DebugToolbar;
let toolbar = DebugToolbar::new();
toolbar.finalize().await;
let html = toolbar.render_html().await;
assert!(html.contains("debug-toolbar"));
assert!(html.contains("Timing"));Trait Implementations§
Auto Trait Implementations§
impl Freeze for DebugToolbar
impl !RefUnwindSafe for DebugToolbar
impl Send for DebugToolbar
impl Sync for DebugToolbar
impl Unpin for DebugToolbar
impl UnsafeUnpin for DebugToolbar
impl !UnwindSafe for DebugToolbar
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().