79 lines
2.1 KiB
Rust
79 lines
2.1 KiB
Rust
mod bitmap;
|
|
mod bitvec;
|
|
mod brightness_grid;
|
|
mod byte_slice;
|
|
mod char_grid;
|
|
mod cp437_grid;
|
|
|
|
pub use bitmap::*;
|
|
pub use bitvec::*;
|
|
pub use brightness_grid::*;
|
|
pub use byte_slice::*;
|
|
pub use char_grid::*;
|
|
pub use cp437_grid::*;
|
|
|
|
macro_rules! wrap_container {
|
|
($object_type:ident) => {
|
|
derive_clone!($object_type);
|
|
derive_free!($object_type);
|
|
};
|
|
}
|
|
|
|
macro_rules! derive_get_width_height {
|
|
($object_type:ident) => {
|
|
$crate::macros::wrap_methods! {$object_type;
|
|
/// Gets the width.
|
|
ref fn width() -> usize;
|
|
|
|
/// Gets the height.
|
|
ref fn height() -> usize;
|
|
}
|
|
};
|
|
}
|
|
|
|
macro_rules! wrap_grid {
|
|
($object_type:ident, $value_type:ident) => {
|
|
$crate::containers::wrap_container!($object_type);
|
|
$crate::containers::derive_get_width_height!($object_type);
|
|
$crate::macros::wrap_methods! {$object_type;
|
|
/// Gets the current value at the specified position.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// - `x` and `y`: position of the cell to read
|
|
///
|
|
/// # Panics
|
|
///
|
|
/// - when accessing `x` or `y` out of bounds
|
|
ref fn get(x: usize, y: usize) -> $value_type;
|
|
|
|
/// Sets the value of the specified position.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// - `x` and `y`: position of the cell
|
|
/// - `value`: the value to write to the cell
|
|
///
|
|
/// # Panics
|
|
///
|
|
/// - when accessing `x` or `y` out of bounds
|
|
mut fn set(x: usize, y: usize, value: $value_type);
|
|
|
|
/// Sets the state of all cells in the grid.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// - `value`: the value to set all cells to
|
|
mut fn fill(value: $value_type);
|
|
}
|
|
};
|
|
}
|
|
|
|
pub(crate) use {derive_get_width_height, wrap_container, wrap_grid};
|
|
|
|
mod _hidden {
|
|
/// This is a type only used by cbindgen to have a type for pointers.
|
|
#[allow(unused)]
|
|
pub struct DisplayBitVec;
|
|
}
|