pub struct Arena { /* private fields */ }Expand description
Arena should be lock-free
Trait Implementations§
Source§impl Allocator for Arena
impl Allocator for Arena
Source§type Path = Arc<PathBuf>
type Path = Arc<PathBuf>
Available on crate feature
memmap and non-target_family="wasm" only.The path type of the allocator.
Source§fn reserved_bytes(&self) -> usize
fn reserved_bytes(&self) -> usize
Returns the number of bytes that are reserved by the allocator.
Source§fn reserved_slice(&self) -> &[u8] ⓘ
fn reserved_slice(&self) -> &[u8] ⓘ
Returns the reserved bytes of the allocator specified in the
Options::with_reserved.Source§unsafe fn reserved_slice_mut(&self) -> &mut [u8] ⓘ
unsafe fn reserved_slice_mut(&self) -> &mut [u8] ⓘ
Returns the mutable reserved bytes of the allocator specified in the
Options::with_reserved. Read moreSource§unsafe fn alloc<T>(&self) -> Result<RefMut<'_, T, Self>, Error>
unsafe fn alloc<T>(&self) -> Result<RefMut<'_, T, Self>, Error>
Allocates a
T in the allocator. Read moreSource§fn alloc_aligned_bytes<T>(
&self,
size: u32,
) -> Result<BytesRefMut<'_, Self>, Error>
fn alloc_aligned_bytes<T>( &self, size: u32, ) -> Result<BytesRefMut<'_, Self>, Error>
Source§fn alloc_bytes(&self, size: u32) -> Result<BytesRefMut<'_, Self>, Error>
fn alloc_bytes(&self, size: u32) -> Result<BytesRefMut<'_, Self>, Error>
Allocates a slice of memory in the allocator. Read more
Source§fn allocated(&self) -> usize
fn allocated(&self) -> usize
Returns the number of bytes allocated by the allocator. Read more
Source§fn raw_mut_ptr(&self) -> *mut u8
fn raw_mut_ptr(&self) -> *mut u8
Returns the start pointer of the main memory of the allocator.
Source§unsafe fn dealloc(&self, offset: u32, size: u32) -> bool
unsafe fn dealloc(&self, offset: u32, size: u32) -> bool
Deallocates the memory at the given offset and size, the
offset..offset + size will be made to a segment,
returns true if the deallocation is successful. Read moreSource§fn discard_freelist(&self) -> Result<u32, Error>
fn discard_freelist(&self) -> Result<u32, Error>
Discards all freelist nodes in the allocator. Read more
Source§fn increase_discarded(&self, size: u32)
fn increase_discarded(&self, size: u32)
Forcelly increases the discarded bytes. Read more
Source§fn magic_version(&self) -> u16
fn magic_version(&self) -> u16
Source§fn minimum_segment_size(&self) -> u32
fn minimum_segment_size(&self) -> u32
Returns the minimum segment size of the allocator. Read more
Source§fn set_minimum_segment_size(&self, size: u32)
fn set_minimum_segment_size(&self, size: u32)
Sets the minimum segment size of the allocator. Read more
Source§fn path(&self) -> Option<&Self::Path>
fn path(&self) -> Option<&Self::Path>
Available on crate feature
memmap and non-target_family="wasm" only.Returns the path of the mmap file, only returns
Some when the ARENA is backed by a mmap file. Read moreSource§unsafe fn offset(&self, ptr: *const u8) -> usize
unsafe fn offset(&self, ptr: *const u8) -> usize
Returns the offset to the start of the allocator. Read more
Source§fn remaining(&self) -> usize
fn remaining(&self) -> usize
Returns the number of bytes remaining bytes can be allocated by the allocator. Read more
Source§unsafe fn rewind(&self, pos: ArenaPosition)
unsafe fn rewind(&self, pos: ArenaPosition)
Set back the allocator’s main memory cursor to the given position. Read more
Source§fn alloc_bytes_owned(&self, size: u32) -> Result<BytesMut<Self>, Error>
fn alloc_bytes_owned(&self, size: u32) -> Result<BytesMut<Self>, Error>
Allocates an owned slice of memory in the allocator. Read more
Source§fn allocated_memory(&self) -> &[u8] ⓘ
fn allocated_memory(&self) -> &[u8] ⓘ
Returns the whole main memory of the allocator as a byte slice. Read more
Source§fn data_offset(&self) -> usize
fn data_offset(&self) -> usize
Returns the data offset of the allocator. The offset is the end of the reserved bytes of the allocator. Read more
Source§fn data(&self) -> &[u8] ⓘ
fn data(&self) -> &[u8] ⓘ
Returns the data section of the allocator as a byte slice, header is not included. Read more
Source§fn flush(&self) -> Result<()>
fn flush(&self) -> Result<()>
Available on crate feature
memmap and non-target_family="wasm" only.Flushes the memory-mapped file to disk. Read more
Source§fn flush_async(&self) -> Result<()>
fn flush_async(&self) -> Result<()>
Available on crate feature
memmap and non-target_family="wasm" only.Flushes the memory-mapped file to disk asynchronously. Read more
Source§fn flush_range(&self, offset: usize, len: usize) -> Result<()>
fn flush_range(&self, offset: usize, len: usize) -> Result<()>
Available on crate feature
memmap and non-target_family="wasm" only.Flushes outstanding memory map modifications in the range to disk. Read more
Source§fn flush_async_range(&self, offset: usize, len: usize) -> Result<()>
fn flush_async_range(&self, offset: usize, len: usize) -> Result<()>
Available on crate feature
memmap and non-target_family="wasm" only.Asynchronously flushes outstanding memory map modifications in the range to disk. Read more
Source§fn flush_header(&self) -> Result<()>
fn flush_header(&self) -> Result<()>
Available on crate feature
memmap and non-target_family="wasm" only.Flushes outstanding memory map modifications in
Allocator’s header to disk. Read moreSource§fn flush_async_header(&self) -> Result<()>
fn flush_async_header(&self) -> Result<()>
Available on crate feature
memmap and non-target_family="wasm" only.Asynchronously flushes outstanding memory map modifications
Allocator’s header to disk. Read moreSource§fn flush_header_and_range(&self, offset: usize, len: usize) -> Result<()>
fn flush_header_and_range(&self, offset: usize, len: usize) -> Result<()>
Available on crate feature
memmap and non-target_family="wasm" only.Flushes outstanding memory map modifications in the range and
Allocator’s header to disk. Read moreSource§fn flush_async_header_and_range(&self, offset: usize, len: usize) -> Result<()>
fn flush_async_header_and_range(&self, offset: usize, len: usize) -> Result<()>
Available on crate feature
memmap and non-target_family="wasm" only.Asynchronously flushes outstanding memory map modifications in the range and
Allocator’s header to disk. Read moreSource§unsafe fn get_pointer(&self, offset: usize) -> *const u8
unsafe fn get_pointer(&self, offset: usize) -> *const u8
Returns a pointer to the memory at the given offset. Read more
Source§unsafe fn get_pointer_mut(&self, offset: usize) -> *mut u8
unsafe fn get_pointer_mut(&self, offset: usize) -> *mut u8
Returns a pointer to the memory at the given offset.
If the allocator is read-only, then this method will return a null pointer. Read more
Source§unsafe fn get_aligned_pointer<T>(&self, offset: usize) -> *const T
unsafe fn get_aligned_pointer<T>(&self, offset: usize) -> *const T
Returns an aligned pointer to the memory at the given offset. Read more
Source§unsafe fn get_aligned_pointer_mut<T>(&self, offset: usize) -> NonNull<T>
unsafe fn get_aligned_pointer_mut<T>(&self, offset: usize) -> NonNull<T>
Returns an aligned pointer to the memory at the given offset.
If the allocator is read-only, then this method will return a null pointer. Read more
Source§unsafe fn get_bytes(&self, offset: usize, size: usize) -> &[u8] ⓘ
unsafe fn get_bytes(&self, offset: usize, size: usize) -> &[u8] ⓘ
Returns a bytes slice from the allocator. Read more
Source§unsafe fn get_u8_unchecked(&self, offset: usize) -> u8
unsafe fn get_u8_unchecked(&self, offset: usize) -> u8
Returns a
u8 from the allocator without bounds checking. Read moreSource§unsafe fn get_i8_unchecked(&self, offset: usize) -> i8
unsafe fn get_i8_unchecked(&self, offset: usize) -> i8
Returns a
i8 from the allocator without bounds checking. Read moreSource§unsafe fn get_u16_be_unchecked(&self, offset: usize) -> u16
unsafe fn get_u16_be_unchecked(&self, offset: usize) -> u16
Returns a
u16 from the allocator without bounds checking. Read moreSource§unsafe fn get_u16_le_unchecked(&self, offset: usize) -> u16
unsafe fn get_u16_le_unchecked(&self, offset: usize) -> u16
Returns a
u16 from the allocator without bounds checking. Read moreSource§unsafe fn get_u32_be_unchecked(&self, offset: usize) -> u32
unsafe fn get_u32_be_unchecked(&self, offset: usize) -> u32
Returns a
u32 from the allocator without bounds checking. Read moreSource§unsafe fn get_u32_le_unchecked(&self, offset: usize) -> u32
unsafe fn get_u32_le_unchecked(&self, offset: usize) -> u32
Returns a
u32 from the allocator without bounds checking. Read moreSource§unsafe fn get_u64_be_unchecked(&self, offset: usize) -> u64
unsafe fn get_u64_be_unchecked(&self, offset: usize) -> u64
Returns a
u64 from the allocator without bounds checking. Read moreSource§unsafe fn get_u64_le_unchecked(&self, offset: usize) -> u64
unsafe fn get_u64_le_unchecked(&self, offset: usize) -> u64
Returns a
u64 from the allocator without bounds checking. Read moreSource§fn get_u128_be(&self, offset: usize) -> Result<u128, Error>
fn get_u128_be(&self, offset: usize) -> Result<u128, Error>
Returns a
u128 from the allocator.Source§unsafe fn get_u128_be_unchecked(&self, offset: usize) -> u128
unsafe fn get_u128_be_unchecked(&self, offset: usize) -> u128
Returns a
u128 from the allocator without bounds checking. Read moreSource§fn get_u128_le(&self, offset: usize) -> Result<u128, Error>
fn get_u128_le(&self, offset: usize) -> Result<u128, Error>
Returns a
u128 from the allocator.Source§unsafe fn get_u128_le_unchecked(&self, offset: usize) -> u128
unsafe fn get_u128_le_unchecked(&self, offset: usize) -> u128
Returns a
u128 from the allocator without bounds checking. Read moreSource§unsafe fn get_i16_be_unchecked(&self, offset: usize) -> i16
unsafe fn get_i16_be_unchecked(&self, offset: usize) -> i16
Returns a
i16 from the allocator without bounds checking. Read moreSource§unsafe fn get_i16_le_unchecked(&self, offset: usize) -> i16
unsafe fn get_i16_le_unchecked(&self, offset: usize) -> i16
Returns a
i16 from the allocator without bounds checking. Read moreSource§unsafe fn get_i32_be_unchecked(&self, offset: usize) -> i32
unsafe fn get_i32_be_unchecked(&self, offset: usize) -> i32
Returns a
i32 from the allocator without bounds checking. Read moreSource§unsafe fn get_i32_le_unchecked(&self, offset: usize) -> i32
unsafe fn get_i32_le_unchecked(&self, offset: usize) -> i32
Returns a
i32 from the allocator without bounds checking. Read moreSource§unsafe fn get_i64_be_unchecked(&self, offset: usize) -> i64
unsafe fn get_i64_be_unchecked(&self, offset: usize) -> i64
Returns a
i64 from the allocator without bounds checking. Read moreSource§unsafe fn get_i64_le_unchecked(&self, offset: usize) -> i64
unsafe fn get_i64_le_unchecked(&self, offset: usize) -> i64
Returns a
i64 from the allocator without bounds checking. Read moreSource§fn get_i128_be(&self, offset: usize) -> Result<i128, Error>
fn get_i128_be(&self, offset: usize) -> Result<i128, Error>
Returns a
i128 from the allocator.Source§unsafe fn get_i128_be_unchecked(&self, offset: usize) -> i128
unsafe fn get_i128_be_unchecked(&self, offset: usize) -> i128
Returns a
i128 from the allocator without bounds checking. Read moreSource§fn get_i128_le(&self, offset: usize) -> Result<i128, Error>
fn get_i128_le(&self, offset: usize) -> Result<i128, Error>
Returns a
i128 from the allocator.Source§unsafe fn get_i128_le_unchecked(&self, offset: usize) -> i128
unsafe fn get_i128_le_unchecked(&self, offset: usize) -> i128
Returns a
i128 from the allocator without bounds checking. Read moreSource§fn get_i16_varint(&self, offset: usize) -> Result<(usize, i16), Error>
fn get_i16_varint(&self, offset: usize) -> Result<(usize, i16), Error>
Returns a
i16 in LEB128 format from the allocator at the given offset. Read moreSource§fn get_i32_varint(&self, offset: usize) -> Result<(usize, i32), Error>
fn get_i32_varint(&self, offset: usize) -> Result<(usize, i32), Error>
Returns a
i32 in LEB128 format from the allocator at the given offset. Read moreSource§fn get_i64_varint(&self, offset: usize) -> Result<(usize, i64), Error>
fn get_i64_varint(&self, offset: usize) -> Result<(usize, i64), Error>
Returns a
i64 in LEB128 format from the allocator at the given offset. Read moreSource§fn get_i128_varint(&self, offset: usize) -> Result<(usize, i128), Error>
fn get_i128_varint(&self, offset: usize) -> Result<(usize, i128), Error>
Returns a
i128 in LEB128 format from the allocator at the given offset. Read moreSource§fn get_u16_varint(&self, offset: usize) -> Result<(usize, u16), Error>
fn get_u16_varint(&self, offset: usize) -> Result<(usize, u16), Error>
Returns a
u16 in LEB128 format from the allocator at the given offset. Read moreSource§fn get_u32_varint(&self, offset: usize) -> Result<(usize, u32), Error>
fn get_u32_varint(&self, offset: usize) -> Result<(usize, u32), Error>
Returns a
u32 in LEB128 format from the allocator at the given offset. Read moreSource§fn get_u64_varint(&self, offset: usize) -> Result<(usize, u64), Error>
fn get_u64_varint(&self, offset: usize) -> Result<(usize, u64), Error>
Returns a
u64 in LEB128 format from the allocator at the given offset. Read moreSource§fn get_u128_varint(&self, offset: usize) -> Result<(usize, u128), Error>
fn get_u128_varint(&self, offset: usize) -> Result<(usize, u128), Error>
Returns a
u128 in LEB128 format from the allocator at the given offset. Read moreSource§unsafe fn get_bytes_mut(&self, offset: usize, size: usize) -> &mut [u8] ⓘ
unsafe fn get_bytes_mut(&self, offset: usize, size: usize) -> &mut [u8] ⓘ
Returns a mutable bytes slice from the allocator.
If the allocator is read-only, then this method will return an empty slice. Read more
Source§fn is_map(&self) -> bool
fn is_map(&self) -> bool
Available on crate feature
memmap and non-target_family="wasm" only.Returns
true if the allocator is created through memory map. Read moreSource§fn is_inmemory(&self) -> bool
fn is_inmemory(&self) -> bool
Returns
true if the allocator is in memory. Read moreSource§fn is_map_anon(&self) -> bool
fn is_map_anon(&self) -> bool
Available on crate feature
memmap and non-target_family="wasm" only.Returns
true if the allocator is on-disk and created through memory map. Read moreSource§fn is_map_file(&self) -> bool
fn is_map_file(&self) -> bool
Available on crate feature
memmap and non-target_family="wasm" only.Returns
true if the allocator is on-disk and created through memory map. Read moreSource§fn lock_exclusive(&self) -> Result<()>
fn lock_exclusive(&self) -> Result<()>
Available on crate feature
memmap and non-target_family="wasm" only.Locks the underlying file for exclusive access, only works on mmap with a file backend. Read more
Available on crate feature
memmap and non-target_family="wasm" only.Locks the underlying file for shared access, only works on mmap with a file backend. Read more
Source§fn memory(&self) -> &[u8] ⓘ
fn memory(&self) -> &[u8] ⓘ
Returns the whole main memory of the allocator as a byte slice. Read more
Source§fn checksum<S: BuildChecksumer>(&self, cks: &S) -> u64
fn checksum<S: BuildChecksumer>(&self, cks: &S) -> u64
Calculates the checksum of the allocated memory (excluding the reserved memory specified by users through
Options::with_reserved) of the allocator.Source§unsafe fn mlock(&self, offset: usize, len: usize) -> Result<()>
unsafe fn mlock(&self, offset: usize, len: usize) -> Result<()>
Available on crate feature
memmap and non-target_family="wasm" only.mlock(ptr, len)—Lock memory into RAM. Read moreSource§unsafe fn munlock(&self, offset: usize, len: usize) -> Result<()>
unsafe fn munlock(&self, offset: usize, len: usize) -> Result<()>
Available on crate feature
memmap and non-target_family="wasm" only.munlock(ptr, len)—Unlock memory. Read moreSource§fn remove_on_drop(&self, remove_on_drop: bool)
fn remove_on_drop(&self, remove_on_drop: bool)
Available on crate feature
memmap and non-target_family="wasm" only.Sets remove on drop, only works on mmap with a file backend. Read more
Source§fn try_lock_exclusive(&self) -> Result<()>
fn try_lock_exclusive(&self) -> Result<()>
Available on crate feature
memmap and non-target_family="wasm" only.Try to lock the underlying file for exclusive access, only works on mmap with a file backend. Read more
Available on crate feature
memmap and non-target_family="wasm" only.Try to lock the underlying file for shared access, only works on mmap with a file backend. Read more
impl Send for Arena
impl Sync for Arena
Auto Trait Implementations§
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<K, Q> Comparable<Q> for K
impl<K, Q> Comparable<Q> for K
Source§impl<K, Q> Equivalent<Q> for K
impl<K, Q> Equivalent<Q> for K
Source§fn equivalent(&self, key: &Q) -> bool
fn equivalent(&self, key: &Q) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more