Skip to main content

ModuleSource

Trait ModuleSource 

Source
pub trait ModuleSource {
    // Required methods
    fn get(&self, x: usize, y: usize) -> Color;
    fn width(&self) -> usize;
    fn height(&self) -> usize;
    fn modules(&self) -> &[Color];

    // Provided methods
    fn row(&self, y: usize) -> &[Color] { ... }
    fn is_empty(&self) -> bool { ... }
}
Expand description

Read-only access to a QR module grid.

Coordinates are zero-based and exclude any quiet zone. Implementations should store modules in row-major order when exposing modules.

Required Methods§

Source

fn get(&self, x: usize, y: usize) -> Color

Returns the color at (x, y).

§Panics

Implementations may panic when x >= width() or y >= height().

Source

fn width(&self) -> usize

Returns the number of modules per row.

Source

fn height(&self) -> usize

Returns the number of module rows.

Source

fn modules(&self) -> &[Color]

Returns all modules in row-major order.

Provided Methods§

Source

fn row(&self, y: usize) -> &[Color]

Returns row y as a contiguous row-major slice.

§Panics

Panics when y >= height() or when modules does not contain a complete row-major grid.

Source

fn is_empty(&self) -> bool

Returns whether this storage has no modules.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§