Skip to main content

ModuleStorage

Trait ModuleStorage 

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

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

Read/write access to a QR module grid.

Rendering and inspection APIs should prefer ModuleSource when they only need read access. This trait remains available for in-place mutation and testing utilities.

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 set(&mut self, x: usize, y: usize, color: Color)

Sets 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 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§