pub struct LoggerStatic<const CAP: usize, const MSG_LEN: usize> { /* private fields */ }Expand description
๐ชต Fixed-capacity static logger with owned byte buffers.
๐ sys/log
Each logger is identified by its capacity (CAP) as the number of stored messages,
and each messageโs maximum length (MSG_LEN).
Use the slog! macro to define, log, clear, or iterate its messages.
ยงSafety
Employs a single-byte, non-atomic guard as a const-safe soft check against re-entrant or concurrent access.
While not providing full thread safety, it can detect most accidental overlaps in single-threaded or unsynchronized contexts, serving as a last-resort diagnostic aid under the assumption of disciplined single-threaded use.
Implementationsยง
Sourceยงimpl<const CAP: usize, const MSG_LEN: usize> LoggerStatic<CAP, MSG_LEN>
impl<const CAP: usize, const MSG_LEN: usize> LoggerStatic<CAP, MSG_LEN>
Sourcepub const fn log_bytes(&mut self, msg: &[u8])
pub const fn log_bytes(&mut self, msg: &[u8])
Logs bytes from msg, truncating if longer than MSG_LEN.
Sourcepub const fn get(&mut self, i: usize) -> Option<(&str, usize)> โ
pub const fn get(&mut self, i: usize) -> Option<(&str, usize)> โ
Returns the message and truncation count at index i, or None if out of bounds.
ยงFeatures
Uses the unsafe_str feature to skip duplicated UTF-8 validation.
Sourcepub fn for_each<F: FnMut(usize, &str, usize)>(&mut self, f: F)
pub fn for_each<F: FnMut(usize, &str, usize)>(&mut self, f: F)
Runs the provided closure for each message in run-time.
The closure receives:
i: index of the messages: string slice (truncated if necessary)truncated: number of bytes that did not fit
ยงFeatures
Uses the unsafe_str feature to skip duplicated validation checks.
Sourcepub const fn any_truncated(&mut self) -> bool
pub const fn any_truncated(&mut self) -> bool
Returns true if any logged message was truncated.
Sourcepub const fn truncation_stats(&mut self) -> (usize, usize) โ
pub const fn truncation_stats(&mut self) -> (usize, usize) โ
Returns (count, total_lost_bytes) for truncated messages.
Trait Implementationsยง
Sourceยงimpl<const CAP: usize, const MSG_LEN: usize> Clone for LoggerStatic<CAP, MSG_LEN>
impl<const CAP: usize, const MSG_LEN: usize> Clone for LoggerStatic<CAP, MSG_LEN>
Sourceยงfn clone(&self) -> LoggerStatic<CAP, MSG_LEN>
fn clone(&self) -> LoggerStatic<CAP, MSG_LEN>
1.0.0 (const: unstable) ยท Sourceยงfn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<const CAP: usize, const MSG_LEN: usize> Eq for LoggerStatic<CAP, MSG_LEN>
Sourceยงimpl<const CAP: usize, const MSG_LEN: usize> PartialEq for LoggerStatic<CAP, MSG_LEN>
impl<const CAP: usize, const MSG_LEN: usize> PartialEq for LoggerStatic<CAP, MSG_LEN>
Sourceยงfn eq(&self, other: &LoggerStatic<CAP, MSG_LEN>) -> bool
fn eq(&self, other: &LoggerStatic<CAP, MSG_LEN>) -> bool
self and other values to be equal, and is used by ==.impl<const CAP: usize, const MSG_LEN: usize> StructuralPartialEq for LoggerStatic<CAP, MSG_LEN>
Auto Trait Implementationsยง
impl<const CAP: usize, const MSG_LEN: usize> Freeze for LoggerStatic<CAP, MSG_LEN>
impl<const CAP: usize, const MSG_LEN: usize> RefUnwindSafe for LoggerStatic<CAP, MSG_LEN>
impl<const CAP: usize, const MSG_LEN: usize> Send for LoggerStatic<CAP, MSG_LEN>
impl<const CAP: usize, const MSG_LEN: usize> Sync for LoggerStatic<CAP, MSG_LEN>
impl<const CAP: usize, const MSG_LEN: usize> Unpin for LoggerStatic<CAP, MSG_LEN>
impl<const CAP: usize, const MSG_LEN: usize> UnsafeUnpin for LoggerStatic<CAP, MSG_LEN>
impl<const CAP: usize, const MSG_LEN: usize> UnwindSafe for LoggerStatic<CAP, MSG_LEN>
Blanket Implementationsยง
Sourceยงimpl<T> AnyExt for T
impl<T> AnyExt for T
Sourceยงfn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
TypeId of Self using a custom hasher.Sourceยงfn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Sourceยงfn as_any_box(self: Box<Self>) -> Box<dyn Any>where
Self: Sized,
fn as_any_box(self: Box<Self>) -> Box<dyn Any>where
Self: Sized,
alloc only.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
Sourceยงimpl<T> ByteSized for T
impl<T> ByteSized for T
Sourceยงconst BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
Sourceยงfn byte_align(&self) -> usize
fn byte_align(&self) -> usize
Sourceยงfn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
ยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
ยงfn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Sourceยงimpl<T> MemExt for Twhere
T: ?Sized,
impl<T> MemExt for Twhere
T: ?Sized,
Sourceยงconst NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Sourceยงfn mem_align_of<T>() -> usize
fn mem_align_of<T>() -> usize
Sourceยงfn mem_align_of_val(&self) -> usize
fn mem_align_of_val(&self) -> usize
Sourceยงfn mem_size_of<T>() -> usize
fn mem_size_of<T>() -> usize
Sourceยงfn mem_size_of_val(&self) -> usize
fn mem_size_of_val(&self) -> usize
Sourceยงfn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true if dropping values of this type matters. Read moreSourceยงfn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self without running its destructor. Read moreSourceยงfn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Sourceยงunsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
unsafe_layout only.T represented by the all-zero byte-pattern. Read moreSourceยงunsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout only.T represented by the all-zero byte-pattern. Read moreSourceยงfn mem_as_bytes(&self) -> &[u8] โ
fn mem_as_bytes(&self) -> &[u8] โ
unsafe_slice only.