[][src]Struct rendy_memory::MappedRange

pub struct MappedRange<'a, B: Backend, C = MaybeCoherent> { /* fields omitted */ }

Represents range of the memory mapped to the host. Provides methods for safer host access to the memory.

Methods

impl<'a, B> MappedRange<'a, B> where
    B: Backend
[src]

pub unsafe fn new(
    memory: &'a Memory<B>,
    device: &impl Device<B>,
    range: Range<u64>
) -> Result<Self, Error>
[src]

Map range of memory.

Safety

  • Only one range for the given memory object can be mapped.
  • Memory object must be not mapped.
  • Memory object must be created with device specified.

pub unsafe fn from_raw(
    memory: &'a Memory<B>,
    ptr: NonNull<u8>,
    range: Range<u64>
) -> Self
[src]

Construct mapped range from raw mapping

Safety

memory range must be mapped to host memory region pointer by ptr.

pub fn ptr(&self) -> NonNull<u8>[src]

Get pointer to beginning of memory region.

pub fn range(&self) -> Range<u64>[src]

Get mapped range.

pub unsafe fn read<'b, T>(
    &'b mut self,
    device: &impl Device<B>,
    range: Range<u64>
) -> Result<&'b [T], Error> where
    'a: 'b,
    T: Copy
[src]

Fetch readable slice of sub-range to be read. Invalidating range if memory is not coherent. range.end - range.start must be multiple of size_of::(). mapping offset + range.start must be multiple of align_of::().

Safety

  • Caller must ensure that device won't write to the memory region until the borrowing ends.
  • T Must be plain-old-data type with memory layout compatible with data written by the device.

pub unsafe fn write<'b, T: 'b>(
    &'b mut self,
    device: &'b impl Device<B>,
    range: Range<u64>
) -> Result<impl Write<T> + 'b, Error> where
    'a: 'b,
    T: Copy
[src]

Fetch writer to the sub-region. This writer will flush data on drop if written at least once.

Safety

  • Caller must ensure that device won't write to or read from the memory region.

pub fn coherent(
    self
) -> Result<MappedRange<'a, B, Coherent>, MappedRange<'a, B, NonCoherent>>
[src]

Convert into mapped range with statically known coherency.

impl<'a, B> MappedRange<'a, B, Coherent> where
    B: Backend
[src]

pub unsafe fn write<'b, U: 'b>(
    &'b mut self,
    range: Range<u64>
) -> Result<impl Write<U> + 'b, Error> where
    U: Copy
[src]

Fetch writer to the sub-region.

Safety

  • Caller must ensure that device won't write to or read from the memory region.

Trait Implementations

impl<'a, B> From<MappedRange<'a, B, Coherent>> for MappedRange<'a, B> where
    B: Backend
[src]

impl<'a, B> From<MappedRange<'a, B, NonCoherent>> for MappedRange<'a, B> where
    B: Backend
[src]

impl<'a, B: Debug + Backend, C: Debug> Debug for MappedRange<'a, B, C>[src]

Auto Trait Implementations

impl<'a, B, C = MaybeCoherent> !Send for MappedRange<'a, B, C>

impl<'a, B, C = MaybeCoherent> !Sync for MappedRange<'a, B, C>

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Supports for T[src]