Skip to main content

Heap

Struct Heap 

Source
pub struct Heap { /* private fields */ }
Expand description

Asynchronous file-backed heap allocator.

Manages variable-sized memory blocks within a file.

Implementations§

Source§

impl Heap

Source

pub async fn new(path: impl AsRef<Path>) -> TokioResult<Self>

Opens or creates a heap file at the given path.

Source

pub async fn size(&self) -> TokioResult<usize>

Returns the current size of the heap file in bytes.

Source

pub async fn alloc(&self, size: u64) -> TokioResult<HeapItem>

Allocates a new memory block of the given size.

Source

pub async fn realloc(&self, item: &mut HeapItem, size: u64) -> TokioResult<bool>

Resizes the memory block. Reallocates if the new size exceeds the block’s capacity. It returns true if reallocation happened else false.

Source

pub async fn update(&mut self, item: &HeapItem, block: &[u8]) -> TokioResult<()>

Writes data to the specified memory block.

Source

pub async fn get( &mut self, item: &HeapItem, block: &mut [u8], ) -> TokioResult<()>

Reads data from the specified memory block.

Auto Trait Implementations§

§

impl !Freeze for Heap

§

impl !RefUnwindSafe for Heap

§

impl Send for Heap

§

impl Sync for Heap

§

impl Unpin for Heap

§

impl UnsafeUnpin for Heap

§

impl !UnwindSafe for Heap

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 = Infallible

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

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

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.