Enum p8n_types::Region

source ·
pub enum Region {
    Undefined {
        address_bits: usize,
        name: Str,
        uuid: Uuid,
    },
    Buffer {
        address_bits: usize,
        name: Str,
        uuid: Uuid,
        offset: u64,
        buffer: Arc<[u8]>,
    },
    File {
        address_bits: usize,
        name: Str,
        uuid: Uuid,
        offset: u64,
        file: Arc<Mmap>,
        path: Option<PathBuf>,
        file_offset: u64,
    },
}
Expand description

A continuous address space. Regions are an array of cells numbered from 0. Each cell is either undefined of carries a single byte value.

Variants

Undefined

Fields

address_bits: usize

Addressable space. All cells in a region have addresses between 0 and 2^address_bits - 1.

name: Str

Human readable name. This name can vary over the livetime of a region and bears no semantic meaning. It’s for use in UIs.

uuid: Uuid

Immutable UUID. The UUID of a region never changes. Can be used for housekeeping and associating additional data with this region.

All undefined values

Buffer

Fields

address_bits: usize

Addressable space. All cells in a region have addresses between 0 and 2^address_bits - 1.

name: Str

Human readable name. This name can vary over the livetime of a region and bears no semantic meaning. It’s for use in UIs.

uuid: Uuid

Immutable UUID. The UUID of a region never changes. Can be used for housekeeping and associating additional data with this region.

offset: u64

Positon of the buffer in the address space.

buffer: Arc<[u8]>

Region contents

In memory buffer

File

Fields

address_bits: usize

Addressable space. All cells in a region have addresses between 0 and 2^address_bits - 1.

name: Str

Human readable name. This name can vary over the livetime of a region and bears no semantic meaning. It’s for use in UIs.

uuid: Uuid

Immutable UUID. The UUID of a region never changes. Can be used for housekeeping and associating additional data with this region.

offset: u64

Positon of the file in the address space.

file: Arc<Mmap>

mmap()’d file.

path: Option<PathBuf>

Path to the mapped file

file_offset: u64

Start of mapping inside file

Memory mapped file.

Implementations

Creates a new completly undefined region with name and address_bits.

Creates a new region called name that is address_bits large. Maps mmap to offset.

Creates a new region called name that is address_bits large. Maps fd to offset.

Creates a new region called name that is address_bits large. Maps buf to offset.

If this is a mmap()’d file, return the path to it and mmap() starting position.

Returns the human readable name of this region.

Changes the human readable name to new.

Returns the immutable UUID of this region.

Size of this region.

Defined range

Fill buf the the values starting at address. Fails if address..address + buf.len() is outside of the addressable range or contains undefined values.

Trys to fill buf the the values starting at address. Returns early if address..address + buf.len() contains undefined values and fails if it’s outside of the addressable range. Returns the number of bytes read.

Reads an bytes large integer from address and zero-extends it to an u64. Fails if address..address + bytes is outside of the addressable range or contains undefined values.

Returns true if range is in the addressable space of this region, i.e. 0..address_bits^2 - .

Returns true if range is in the addressable space of this region and contains no undefined values.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
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.