pub struct Canary<const MAGIC: u32> { /* private fields */ }Expand description
An embeddable structure guard.
To use fbl::Canary, choose a 4-byte guard value.
You can use the Canary::new() method to instantiate a Canary object.
The compiler will infer the magic value from the type definition.
struct MyStruct {
canary: fbl::Canary<{ fbl::magic(b"guar") }>,
// ...
}
impl MyStruct {
fn new() -> Self {
MyStruct {
canary: fbl::Canary::new(),
// ...
}
}
}The canary initializes itself with the guard value during construction and
checks it during destruction (on Drop). You can also manually check the
value during the lifetime of your object by calling the assert method.
If the value is not an ASCII string, you can directly use an integer literal as the const generic parameter.
struct MyStruct {
canary: fbl::Canary<0x12345678>,
// ...
}Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<const MAGIC: u32> Freeze for Canary<MAGIC>
impl<const MAGIC: u32> RefUnwindSafe for Canary<MAGIC>
impl<const MAGIC: u32> Send for Canary<MAGIC>
impl<const MAGIC: u32> Sync for Canary<MAGIC>
impl<const MAGIC: u32> Unpin for Canary<MAGIC>
impl<const MAGIC: u32> UnsafeUnpin for Canary<MAGIC>
impl<const MAGIC: u32> UnwindSafe for Canary<MAGIC>
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> PinInit<T> for T
impl<T> PinInit<T> for T
Source§unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
Initializes
slot. Read more