PanicSlot

Struct PanicSlot 

pub struct PanicSlot<'a> { /* private fields */ }
Expand description

Framing wrapper around a borrowed RAM region.

One instance is constructed at boot from the BSP-provided &'static mut [u8]. Pass the same region (the literal same RAM, not a fresh copy) every reset so the previous boot’s panic can be recovered.

Implementations§

§

impl<'a> PanicSlot<'a>

pub fn new(region: &'a mut [u8]) -> PanicSlot<'a>

Wrap a RAM region. Region must be at least [HEADER_LEN] + 1 byte; smaller regions panic in debug and silently truncate writes to zero payload bytes in release.

pub fn payload_capacity(&self) -> usize

Capacity available for payload bytes.

pub fn capture(&mut self, msg: &[u8]) -> usize

Write a panic message. Truncates if msg is larger than the payload capacity. Returns the number of payload bytes actually stored. Designed to be callable from a panic handler, so it allocates nothing and uses only direct slice writes.

pub fn read(&self) -> Option<&[u8]>

Borrow the previously-captured payload, if a valid record is present. Returns None for an uninitialized region, a stale / foreign record (wrong magic), a corrupt record (bad checksum), or an out-of-bounds length.

pub fn clear(&mut self)

Invalidate the record. Subsequent read calls return None until another capture writes a new one. Cheap: zeroes only the 4-byte magic.

Trait Implementations§

§

impl<'a> Debug for PanicSlot<'a>

§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for PanicSlot<'a>

§

impl<'a> RefUnwindSafe for PanicSlot<'a>

§

impl<'a> Send for PanicSlot<'a>

§

impl<'a> Sync for PanicSlot<'a>

§

impl<'a> Unpin for PanicSlot<'a>

§

impl<'a> !UnwindSafe for PanicSlot<'a>

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.