Enum 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

All undefined values

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.

§

Buffer

In memory 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

§

File

Memory mapped 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

Implementations§

Source§

impl Region

Source

pub fn undefined<S, U>(name: S, address_bits: usize, uuid: U) -> Region
where S: Into<Str>, U: Into<Option<UUID>>,

Creates a new completly undefined region with name and address_bits.

Source

pub fn from_mmap<S, O, P, U>( name: S, address_bits: usize, mmap: Mmap, path: P, file_offset: O, offset: O, uuid: U, ) -> Region
where S: Into<Str>, O: Into<Option<u64>>, P: Into<Option<PathBuf>>, U: Into<Option<UUID>>,

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

Source

pub fn from_file<S, O, P, U>( name: S, address_bits: usize, fd: File, path: P, offset: O, uuid: U, ) -> Result<Region>
where S: Into<Str>, O: Into<Option<u64>>, P: Into<Option<PathBuf>>, U: Into<Option<UUID>>,

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

Source

pub fn from_buf<S, O, B, U>( name: S, address_bits: usize, buf: B, offset: O, uuid: U, ) -> Region
where S: Into<Str>, O: Into<Option<u64>>, B: Into<Arc<[u8]>>, U: Into<Option<UUID>>,

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

Source

pub fn file<'a>(&'a self) -> Option<(&'a Path, u64)>

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

Source

pub fn name<'a>(&'a self) -> &'a Str

Returns the human readable name of this region.

Source

pub fn rename(&mut self, new: Str)

Changes the human readable name to new.

Source

pub fn uuid<'a>(&'a self) -> &'a UUID

Returns the immutable UUID of this region.

Source

pub fn address_bits(&self) -> usize

Size of this region.

Source

pub fn defined(&self) -> Range<u64>

Defined range

Source

pub fn read<'a>(&'a self, start: u64, len: usize) -> Result<&'a [u8]>

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

Source

pub fn try_read(&self, address: u64, buf: &mut [u8]) -> Result<usize>

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.

Source

pub fn read_integer( &self, address: u64, endianess: Endianess, bytes: usize, ) -> Result<u64>

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.

Source

pub fn in_range(&self, range: Range<u64>) -> bool

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

Source

pub fn is_defined(&self, range: Range<u64>) -> bool

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

Trait Implementations§

Source§

impl Clone for Region

Source§

fn clone(&self) -> Region

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Region

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Region

§

impl RefUnwindSafe for Region

§

impl Send for Region

§

impl Sync for Region

§

impl Unpin for Region

§

impl UnwindSafe for Region

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.