Skip to main content

DevtoolsTrace

Struct DevtoolsTrace 

Source
pub struct DevtoolsTrace<T> { /* private fields */ }
Expand description

Devtools 环形缓冲:零开销开关 + 容量淘汰 + 线程安全。

Implementations§

Source§

impl<T> DevtoolsTrace<T>

Source

pub fn new(capacity: usize) -> Self

创建一个新的环形缓冲,容量 capacity。默认关闭。

Source

pub fn enabled(&self) -> bool

开关状态。关闭时 Self::push 立即返回。

Source

pub fn set_enabled(&self, on: bool)

打开/关闭采集。

Source

pub fn capacity(&self) -> usize

当前容量上限。

Source

pub fn push(&self, record: T)

追加一条记录。关闭时立即返回(零锁、零分配)。

Source

pub fn peek(&self, max: usize) -> Vec<T>
where T: Clone,

取最近 max 条快照。max == 0 取全部。只读不 drain。

Source

pub fn clear(&self)

清空缓冲。显式清空不受开关影响:关闭时也要能清掉上一会话留下的记录。

Source

pub fn len(&self) -> usize

当前条数(调试用)。

Source

pub fn is_empty(&self) -> bool

是否为空(调试用)。

Trait Implementations§

Source§

impl<T: Debug> Debug for DevtoolsTrace<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> !Freeze for DevtoolsTrace<T>

§

impl<T> Forget for DevtoolsTrace<T>

§

impl<T> Move for DevtoolsTrace<T>

§

impl<T> RefUnwindSafe for DevtoolsTrace<T>

§

impl<T> Send for DevtoolsTrace<T>
where Mutex<VecDeque<T>>: Send,

§

impl<T> Sync for DevtoolsTrace<T>
where Mutex<VecDeque<T>>: Sync,

§

impl<T> Unpin for DevtoolsTrace<T>
where Mutex<VecDeque<T>>: Unpin,

§

impl<T> UnsafeUnpin for DevtoolsTrace<T>

§

impl<T> UnwindSafe for DevtoolsTrace<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.