add missing docs

This commit is contained in:
Vinzenz Schroeter 2024-06-03 22:10:52 +02:00
parent 947a3fe60e
commit a4d53d0e56
5 changed files with 31 additions and 3 deletions

View file

@ -45,10 +45,23 @@ impl ByteGrid {
} }
} }
/// Iterate over all cells in `ByteGrid`.
///
/// Order is equivalent to the following loop:
/// ```
/// # use servicepoint::{ByteGrid, Grid};
/// # let grid = ByteGrid::new(2,2);
/// for y in 0..grid.height() {
/// for x in 0..grid.width() {
/// grid.get(x, y)
/// }
/// }
/// ```
pub fn iter(&self) -> Iter<u8> { pub fn iter(&self) -> Iter<u8> {
self.data.iter() self.data.iter()
} }
/// Iterate over all rows in `ByteGrid` top to bottom.
pub fn iter_rows(&self) -> IterRows { pub fn iter_rows(&self) -> IterRows {
IterRows { IterRows {
byte_grid: self, byte_grid: self,

View file

@ -1,4 +1,4 @@
use bitvec::prelude::{BitVec, Msb0}; use bitvec::prelude::BitVec;
use crate::command_code::CommandCode; use crate::command_code::CommandCode;
use crate::compression::{into_compressed, into_decompressed}; use crate::compression::{into_compressed, into_decompressed};
@ -27,7 +27,6 @@ pub type Offset = usize;
/// Type alias for documenting the meaning of the u16 in enum values /// Type alias for documenting the meaning of the u16 in enum values
pub type Brightness = u8; pub type Brightness = u8;
// TODO: check order
/// A command to send to the display. /// A command to send to the display.
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
pub enum Command { pub enum Command {
@ -369,7 +368,7 @@ impl Command {
/// Helper method for Packets into `BitMapLinear*`-Commands /// Helper method for Packets into `BitMapLinear*`-Commands
fn packet_into_linear_bitmap( fn packet_into_linear_bitmap(
packet: Packet, packet: Packet,
) -> Result<(BitVec<u8, Msb0>, CompressionCode), TryFromPacketError> { ) -> Result<(SpBitVec, CompressionCode), TryFromPacketError> {
let Packet(Header(_, _, length, sub, reserved), payload) = packet; let Packet(Header(_, _, length, sub, reserved), payload) = packet;
if reserved != 0 { if reserved != 0 {
return Err(TryFromPacketError::ExtraneousHeaderValues); return Err(TryFromPacketError::ExtraneousHeaderValues);

View file

@ -63,10 +63,23 @@ impl PixelGrid {
} }
} }
/// Iterate over all cells in `PixelGrid`.
///
/// Order is equivalent to the following loop:
/// ```
/// # use servicepoint::{PixelGrid, Grid};
/// # let grid = PixelGrid::new(8,2);
/// for y in 0..grid.height() {
/// for x in 0..grid.width() {
/// grid.get(x, y)
/// }
/// }
/// ```
pub fn iter(&self) -> Iter<'_, u8, Msb0> { pub fn iter(&self) -> Iter<'_, u8, Msb0> {
self.bit_vec.iter() self.bit_vec.iter()
} }
/// Iterate over all rows in `PixelGrid` top to bottom.
pub fn iter_rows(&self) -> IterRows { pub fn iter_rows(&self) -> IterRows {
IterRows { IterRows {
pixel_grid: self, pixel_grid: self,

View file

@ -8,6 +8,7 @@ use servicepoint::bitvec::prelude::{BitVec, Msb0};
/// cbindgen:no-export /// cbindgen:no-export
type SpBitVec = BitVec<u8, Msb0>; type SpBitVec = BitVec<u8, Msb0>;
/// Opaque struct needed for correct code generation.
#[derive(Clone)] #[derive(Clone)]
pub struct CBitVec { pub struct CBitVec {
actual: SpBitVec, actual: SpBitVec,

View file

@ -1,3 +1,5 @@
//! FFI slice helper
#[repr(C)] #[repr(C)]
/// Represents a span of memory (`&mut [u8]` ) as a struct usable by C code. /// Represents a span of memory (`&mut [u8]` ) as a struct usable by C code.
/// ///