Struct ext2::arena::Arena

source ·
pub struct Arena<'a> {
    mem: &'a mut MemoryMapping,
    block_size: usize,
    regions: RefCell<RegionManager>,
    mappings: RefCell<Vec<FileMappingInfo>>,
}
Expand description

Memory arena backed by base::MemoryMapping.

This struct takes a mutable referencet to the memory mapping so this arena won’t arena the region.

Fields§

§mem: &'a mut MemoryMapping§block_size: usize§regions: RefCell<RegionManager>

A set of regions that are not overlapping each other. Use RefCell for interior mutability because the mutablity of RegionManager should be independent from the mutability of the memory mapping.

§mappings: RefCell<Vec<FileMappingInfo>>

Implementations§

source§

impl<'a> Arena<'a>

source

pub fn new(block_size: usize, mem: &'a mut MemoryMapping) -> Result<Self>

Create a new arena backed by len bytes of base::MemoryMapping.

source

fn reserve(&self, mem_offset: usize, len: usize) -> Result<()>

A helper function to mark a region as reserved.

source

pub fn reserve_for_mmap( &self, mem_offset: usize, length: usize, file: File, file_offset: usize ) -> Result<()>

Reserves a region for mmap and stores the mmap information. Note that Arena will not call mmap(). Instead, the owner of Arena instance must call into_mapping_info() to retrieve the mapping information and call mmap later instead.

source

pub fn allocate_slice( &self, block: BlockId, block_offset: usize, len: usize ) -> Result<&'a mut [u8]>

Allocate a new slice on an anonymous memory. Arena structs guarantees that this area is not overlapping with other regions.

source

pub fn allocate<T: AsBytes + FromBytes + Sized>( &self, block: BlockId, block_offset: usize ) -> Result<&'a mut T>

Allocate a new region for a value with type T.

source

pub fn write_to_mem<T: AsBytes + FromBytes + Sized>( &self, block_id: BlockId, block_offset: usize, value: &T ) -> Result<()>

source

pub fn into_mapping_info(self) -> Vec<FileMappingInfo>

Consumes Arena and retrieve mmap information.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Arena<'a>

§

impl<'a> Send for Arena<'a>

§

impl<'a> !Sync for Arena<'a>

§

impl<'a> Unpin for Arena<'a>

§

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

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>,

§

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>,

§

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.