pub struct MockDisplay<C>(/* private fields */)
where
    C: PixelColor;
Expand description

Mock display struct

See the module documentation for usage and examples.

Implementations§

source§

impl<C> MockDisplay<C>
where C: PixelColor,

source

pub fn new() -> Self

Creates a new empty mock display.

source

pub fn width(&self) -> usize

Returns the width of the display.

source

pub fn height(&self) -> usize

Returns the height of the display.

source

pub fn get_pixel(&self, p: Point) -> Option<C>

Returns the color of a pixel.

source

pub fn set_pixel(&mut self, p: Point, color: Option<C>)

Changes the color of a pixel.

source§

impl<C> MockDisplay<C>
where C: PixelColor + ColorMapping<C>,

source

pub fn from_pattern(pattern: &[&str]) -> MockDisplay<C>

Creates a new mock display from a character pattern.

The color pattern is specified by a slice of string slices. Each string slice represents a row of pixels and every character a single pixel.

A space character in the pattern represents a pixel which wasn’t modified by any drawing routine and is left in the default state. All other characters are converted by implementations of the ColorMapping trait.

Trait Implementations§

source§

impl<C> Clone for MockDisplay<C>
where C: PixelColor + Clone,

source§

fn clone(&self) -> MockDisplay<C>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<C> Debug for MockDisplay<C>
where C: PixelColor + ColorMapping<C>,

source§

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

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

impl<C> Default for MockDisplay<C>
where C: PixelColor,

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<C> DrawTarget<C> for MockDisplay<C>
where C: PixelColor,

§

type Error = Infallible

Error type to return when a drawing operation fails. Read more
source§

fn draw_pixel(&mut self, pixel: Pixel<C>) -> Result<(), Self::Error>

Draws a pixel on the display.
source§

fn size(&self) -> Size

Returns the dimensions of the DrawTarget in pixels.
source§

fn draw_iter<T>(&mut self, item: T) -> Result<(), Self::Error>
where T: IntoIterator<Item = Pixel<C>>,

Draws an object from an iterator over its pixels.
source§

fn clear(&mut self, color: C) -> Result<(), Self::Error>
where Self: Sized,

Clears the display with the supplied color. Read more
source§

fn draw_line( &mut self, item: &Styled<Line, PrimitiveStyle<C>> ) -> Result<(), Self::Error>

Draws a styled line primitive. Read more
source§

fn draw_triangle( &mut self, item: &Styled<Triangle, PrimitiveStyle<C>> ) -> Result<(), Self::Error>

Draws a styled triangle primitive. Read more
source§

fn draw_rectangle( &mut self, item: &Styled<Rectangle, PrimitiveStyle<C>> ) -> Result<(), Self::Error>

Draws a styled rectangle primitive. Read more
source§

fn draw_circle( &mut self, item: &Styled<Circle, PrimitiveStyle<C>> ) -> Result<(), Self::Error>

Draws a styled circle primitive. Read more
source§

impl<C> PartialEq for MockDisplay<C>
where C: PixelColor,

source§

fn eq(&self, other: &MockDisplay<C>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<C> Copy for MockDisplay<C>
where C: PixelColor + Copy,

Auto Trait Implementations§

§

impl<C> RefUnwindSafe for MockDisplay<C>
where C: RefUnwindSafe,

§

impl<C> Send for MockDisplay<C>
where C: Send,

§

impl<C> Sync for MockDisplay<C>
where C: Sync,

§

impl<C> Unpin for MockDisplay<C>
where C: Unpin,

§

impl<C> UnwindSafe for MockDisplay<C>
where C: UnwindSafe,

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.