pub struct View<'a> {
base: *const u8,
pitch: usize,
dims: Dims,
format: Format,
_borrow: PhantomData<&'a [u8]>,
}Expand description
An immutable rectangle of pixels.
Created from a borrowed slice or from raw memory (MMIO, shared mapping). It records no damage and cannot be drawn into.
Fields§
§base: *const u8§pitch: usize§dims: Dims§format: Format§_borrow: PhantomData<&'a [u8]>Implementations§
Source§impl<'a> View<'a>
impl<'a> View<'a>
Sourcepub fn new(
buf: &'a [u8],
dims: Dims,
pitch: usize,
format: Format,
) -> Result<Self, Error>
pub fn new( buf: &'a [u8], dims: Dims, pitch: usize, format: Format, ) -> Result<Self, Error>
Build a view over a borrowed buffer.
pitch is a byte count, not a pixel count.
Sourcepub unsafe fn from_raw(
base: *const u8,
dims: Dims,
pitch: usize,
format: Format,
) -> Result<Self, Error>
pub unsafe fn from_raw( base: *const u8, dims: Dims, pitch: usize, format: Format, ) -> Result<Self, Error>
Build a view over raw memory.
§Safety
base must be readable for pitch * height bytes for the whole
lifetime 'a, and the memory must stay valid if the view is sent to
another CPU (View is Send + Sync).
pub fn dims(&self) -> Dims
pub fn format(&self) -> Format
pub fn pitch(&self) -> usize
pub fn bytes_per_pixel(&self) -> usize
pub fn bounds(&self) -> Rect
pub fn clip(&self, rect: Rect) -> Option<Rect>
Trait Implementations§
impl Send for View<'_>
impl Sync for View<'_>
Auto Trait Implementations§
impl<'a> Forget for View<'a>
impl<'a> Freeze for View<'a>
impl<'a> Move for View<'a>
impl<'a> RefUnwindSafe for View<'a>
impl<'a> Unpin for View<'a>
impl<'a> UnsafeUnpin for View<'a>
impl<'a> UnwindSafe for View<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more