[−][src]Enum p8n_types::Region
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 of Undefined
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 of Buffer
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 of File
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
Methods
impl Region
[src]
pub fn undefined<S, U>(name: S, address_bits: usize, uuid: U) -> Region where
S: Into<Str>,
U: Into<Option<UUID>>,
[src]
S: Into<Str>,
U: Into<Option<UUID>>,
Creates a new completly undefined region with name
and address_bits
.
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>>,
[src]
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
.
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>>,
[src]
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
.
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>>,
[src]
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
.
pub fn file<'a>(&'a self) -> Option<(&'a Path, u64)>
[src]
If this is a mmap()'d file, return the path to it and mmap() starting position.
pub fn name<'a>(&'a self) -> &'a Str
[src]
Returns the human readable name of this region.
pub fn rename(&mut self, new: Str)
[src]
Changes the human readable name to new
.
pub fn uuid<'a>(&'a self) -> &'a UUID
[src]
Returns the immutable UUID of this region.
pub fn address_bits(&self) -> usize
[src]
Size of this region.
pub fn defined(&self) -> Range<u64>
[src]
Defined range
pub fn read<'a>(&'a self, start: u64, len: usize) -> Result<&'a [u8]>
[src]
Fill buf
the the values starting at address
. Fails if address..address + buf.len()
is outside of the addressable range or contains undefined values.
pub fn try_read(&self, address: u64, buf: &mut [u8]) -> Result<usize>
[src]
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.
pub fn read_integer(
&self,
address: u64,
endianess: Endianess,
bytes: usize
) -> Result<u64>
[src]
&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.
pub fn in_range(&self, range: Range<u64>) -> bool
[src]
Returns true if range is in the addressable space of this region, i.e. 0..address_bits^2 -
.
pub fn is_defined(&self, range: Range<u64>) -> bool
[src]
Returns true if range is in the addressable space of this region and contains no undefined values.
Trait Implementations
impl Clone for Region
[src]
fn clone(&self) -> Region
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for Region
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,