gfx_memory/
block.rs

1use crate::mapping::MappedRange;
2use hal::memory as m;
3
4/// Block that owns a `Segment` of the `Memory`.
5/// Implementor must ensure that there can't be any other blocks
6/// with overlapping range (either through type system or safety notes for unsafe functions).
7/// Provides access to safe memory range mapping.
8pub trait Block<B: hal::Backend> {
9    /// Get memory properties of the block.
10    fn properties(&self) -> m::Properties;
11
12    /// Get raw memory object.
13    fn memory(&self) -> &B::Memory;
14
15    /// Get memory segment owned by this block.
16    fn segment(&self) -> m::Segment;
17
18    /// Get mapping for the block segment.
19    /// Memory writes to the region performed by device become available for the host.
20    fn map<'a>(
21        &'a mut self,
22        device: &B::Device,
23        segment: m::Segment,
24    ) -> Result<MappedRange<'a, B>, hal::device::MapError>;
25}