Struct wasmtime_jit::MmapVec[][src]

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

A type akin to Vec<u8>, but backed by mmap and able to be split.

This type is a non-growable owned list of bytes. It can be segmented into disjoint separately owned views akin to the split_at method on slices in Rust. An MmapVec is backed by an OS-level memory allocation and is not suitable for lots of small allocation (since it works at the page granularity).

An MmapVec is an owned value which means that owners have the ability to get exclusive access to the underlying bytes, enabling mutation.

Implementations

Consumes an existing mmap and wraps it up into an MmapVec.

The returned MmapVec will have the size specified, which can be smaller than the region mapped by the Mmap. The returned MmapVec will only have at most size bytes accessible.

Creates a new zero-initialized MmapVec with the given size.

This commit will return a new MmapVec suitably sized to hold size bytes. All bytes will be initialized to zero since this is a fresh OS page allocation.

Creates a new MmapVec from the contents of an existing slice.

A new MmapVec is allocated to hold the contents of slice and then slice is copied into the new mmap. It’s recommended to avoid this method if possible to avoid the need to copy data around.

Creates a new MmapVec from serializing the specified obj.

The returned MmapVec will contain the serialized version of obj and is sized appropriately to the exact size of the object serialized.

Creates a new MmapVec which is the path specified mmap’d into memory.

This function will attempt to open the file located at path and will then use that file to learn about its size and map the full contents into memory. This will return an error if the file doesn’t exist or if it’s too large to be fully mapped into memory.

Returns whether the original mmap was created from a readonly mapping.

“Drains” leading bytes up to the end specified in range from this MmapVec, returning a separately owned MmapVec which retains access to the bytes.

This method is similar to the Vec type’s drain method, except that the return value is not an iterator but rather a new MmapVec. The purpose of this method is the ability to split-off new MmapVec values which are sub-slices of the original one.

Once data has been drained from an MmapVec it is no longer accessible from the original MmapVec, it’s only accessible from the returned MmapVec. In other words ownership of the drain’d bytes is returned through the MmapVec return value.

This MmapVec will shrink by range.end bytes, and it will only refer to the bytes that come after the drain range.

This is an O(1) operation which does not involve copies.

Makes the specified range within this mmap to be read/write.

Makes the specified range within this mmap to be read/execute.

Trait Implementations

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.