Struct kalloc::guard::AllocGuard[][src]

pub struct AllocGuard { /* fields omitted */ }
Expand description

Smart pointer guard.

Implementations

impl AllocGuard[src]

pub fn new(layout: Layout) -> Result<Self, AllocError>[src]

Create a new smart pointer.

pub fn ptr(&self) -> NonNull<u8>[src]

Get the pointer inside.

pub fn as_slice(&self) -> &[u8]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

Extract the slice.

pub fn as_mut_slice(&self) -> &mut [u8]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

Extract the mutable slice.

pub fn consume(self)[src]

Drop and don’t deallocate the pointer.

Often called when the ownership of the pointer is transfered.

pub unsafe fn from_ptr(ptr: NonNull<u8>, layout: Layout) -> Self[src]

Create a new smart pointer from raw pointer.

SAFETY: You must guarantee that

  • ptr and layout are valid.
  • [consume] is called before anyone uses ptr.

Trait Implementations

impl Drop for AllocGuard[src]

fn drop(&mut self)[src]

Executes the destructor for this type. Read more

impl Send for AllocGuard[src]

impl Sync for AllocGuard[src]

Auto Trait Implementations

impl RefUnwindSafe for AllocGuard

impl Unpin for AllocGuard

impl UnwindSafe for AllocGuard

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.