Skip to main content

PlaneRegion

Struct PlaneRegion 

Source
pub struct PlaneRegion<'a, T: Pixel> {
    data: *const T,
    pub plane_cfg: &'a PlaneConfig,
    rect: Rect,
    phantom: PhantomData<&'a T>,
}
Expand description

Bounded region of a plane

This allows giving access to a rectangular area of a plane without giving access to the whole plane.

Fields§

§data: *const T§plane_cfg: &'a PlaneConfig§rect: Rect§phantom: PhantomData<&'a T>

Implementations§

Source§

impl<'a, T: Pixel> PlaneRegion<'a, T>

Source

pub fn empty(plane_cfg: &'a PlaneConfig) -> Self

Source

pub fn from_slice(data: &'a [T], cfg: &'a PlaneConfig, rect: Rect) -> Self

§Panics
  • If the configured dimensions are invalid
Source

unsafe fn from_slice_unsafe( data: &'a [T], cfg: &'a PlaneConfig, rect: Rect, ) -> Self

Source

pub fn new(plane: &'a Plane<T>, rect: Rect) -> Self

Source

pub fn new_from_plane(plane: &'a Plane<T>) -> Self

Source

pub fn data_ptr(&self) -> *const T

Source

pub fn rect(&self) -> &Rect

Source

pub fn rows_iter(&self) -> PlaneRegionRowsIter<'_, T>

Source

pub fn vert_windows(&self, h: usize) -> VertWindows<'_, T>

Source

pub fn horz_windows(&self, w: usize) -> HorzWindows<'_, T>

Source

pub fn subregion(&self, area: Area) -> PlaneRegion<'_, T>

Return a view to a subregion of the plane

The subregion must be included in (i.e. must not exceed) this region.

It is described by an Area, relative to this region.

§Panics
  • If the requested dimensions are larger than the plane region size
§Example
// a subregion from (10, 8) to the end of the region
let subregion = region.subregion(Area::StartingAt { x: 10, y: 8 });
// a subregion from the top-left of block (2, 3) having size (64, 64)
let bo = BlockOffset { x: 2, y: 3 };
let subregion = region.subregion(Area::BlockRect { bo, width: 64, height: 64 });

Trait Implementations§

Source§

impl<'a, T: Debug + Pixel> Debug for PlaneRegion<'a, T>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T: Pixel> Index<usize> for PlaneRegion<'_, T>

Source§

type Output = [T]

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T: Pixel> Send for PlaneRegion<'_, T>

Source§

impl<T: Pixel> Sync for PlaneRegion<'_, T>

Auto Trait Implementations§

§

impl<'a, T> Freeze for PlaneRegion<'a, T>

§

impl<'a, T> RefUnwindSafe for PlaneRegion<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Unpin for PlaneRegion<'a, T>

§

impl<'a, T> UnsafeUnpin for PlaneRegion<'a, T>

§

impl<'a, T> UnwindSafe for PlaneRegion<'a, T>
where T: RefUnwindSafe,

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.