fix docs, misc tweaks

This commit is contained in:
Vinzenz Schroeter 2025-06-19 18:32:07 +02:00
parent b79a2534fc
commit 18f0be072a
7 changed files with 56 additions and 45 deletions

View file

@ -412,6 +412,8 @@ typedef struct Packet Packet;
/**
* This is a type only used by cbindgen to have a type for pointers.
*
* See [servicepoint::UdpSocketExt].
*/
typedef struct UdpSocket UdpSocket;
@ -641,7 +643,7 @@ extern "C" {
struct Bitmap */*notnull*/ sp_bitmap_clone(struct Bitmap */*notnull*/ instance);
/**
* Calls [`servicepoint::Bitmap::data_ref_mut`].
* Calls method [`servicepoint::Bitmap::data_ref_mut`].
*
* Gets an unsafe reference to the data of the [Bitmap] instance.
*
@ -652,7 +654,7 @@ struct Bitmap */*notnull*/ sp_bitmap_clone(struct Bitmap */*notnull*/ instance);
struct ByteSlice sp_bitmap_data_ref_mut(struct Bitmap */*notnull*/ instance);
/**
* Calls [`servicepoint::Bitmap::fill`].
* Calls method [`servicepoint::Bitmap::fill`].
*
* Sets the state of all pixels in the [Bitmap].
*
@ -683,7 +685,7 @@ void sp_bitmap_free(struct Bitmap */*notnull*/ instance);
struct Bitmap *sp_bitmap_from_bitvec(size_t width, BitVec */*notnull*/ bitvec);
/**
* Calls [`servicepoint::Bitmap::get`].
* Calls method [`servicepoint::Bitmap::get`].
*
* Gets the current value at the specified position.
*
@ -700,7 +702,7 @@ struct Bitmap *sp_bitmap_from_bitvec(size_t width, BitVec */*notnull*/ bitvec);
bool sp_bitmap_get(struct Bitmap */*notnull*/ instance, size_t x, size_t y);
/**
* Calls [`servicepoint::Bitmap::height`].
* Calls method [`servicepoint::Bitmap::height`].
*
* Gets the height in pixels.
*
@ -784,7 +786,7 @@ struct Bitmap *sp_bitmap_new(size_t width, size_t height);
struct Bitmap */*notnull*/ sp_bitmap_new_max_sized(void);
/**
* Calls [`servicepoint::Bitmap::set`].
* Calls method [`servicepoint::Bitmap::set`].
*
* Sets the value of the specified position.
*
@ -805,7 +807,7 @@ void sp_bitmap_set(struct Bitmap */*notnull*/ instance,
bool value);
/**
* Calls [`servicepoint::Bitmap::width`].
* Calls method [`servicepoint::Bitmap::width`].
*
* Gets the width in pixels.
*
@ -814,7 +816,7 @@ void sp_bitmap_set(struct Bitmap */*notnull*/ instance,
size_t sp_bitmap_width(struct Bitmap */*notnull*/ instance);
/**
* Calls [`servicepoint::DisplayBitVec::as_raw_mut_slice`].
* Calls method [`servicepoint::DisplayBitVec::as_raw_mut_slice`].
*
* Gets an unsafe reference to the data of the [DisplayBitVec] instance.
*
@ -832,7 +834,7 @@ struct ByteSlice sp_bitvec_as_raw_mut_slice(BitVec */*notnull*/ instance);
BitVec */*notnull*/ sp_bitvec_clone(BitVec */*notnull*/ instance);
/**
* Calls [`servicepoint::DisplayBitVec::fill`].
* Calls method [`servicepoint::DisplayBitVec::fill`].
*
* Sets the value of all bits.
*
@ -852,7 +854,7 @@ void sp_bitvec_fill(BitVec */*notnull*/ instance, bool value);
void sp_bitvec_free(BitVec */*notnull*/ instance);
/**
* Calls [`servicepoint::DisplayBitVec::get`].
* Calls method [`servicepoint::DisplayBitVec::get`].
*
* Gets the value of a bit.
*
@ -886,7 +888,7 @@ struct Packet *sp_bitvec_into_packet(BitVec */*notnull*/ bitvec,
CompressionCode compression);
/**
* Calls [`servicepoint::DisplayBitVec::is_empty`].
* Calls method [`servicepoint::DisplayBitVec::is_empty`].
*
* Returns true if length is 0.
*
@ -895,7 +897,7 @@ struct Packet *sp_bitvec_into_packet(BitVec */*notnull*/ bitvec,
bool sp_bitvec_is_empty(BitVec */*notnull*/ instance);
/**
* Calls [`servicepoint::DisplayBitVec::len`].
* Calls method [`servicepoint::DisplayBitVec::len`].
*
* Gets the length in bits.
*
@ -930,7 +932,7 @@ BitVec */*notnull*/ sp_bitvec_load(struct ByteSlice data);
BitVec */*notnull*/ sp_bitvec_new(size_t size);
/**
* Calls [`servicepoint::DisplayBitVec::set`].
* Calls method [`servicepoint::DisplayBitVec::set`].
*
* Sets the value of a bit.
*
@ -955,7 +957,7 @@ void sp_bitvec_set(BitVec */*notnull*/ instance, size_t index, bool value);
BrightnessGrid */*notnull*/ sp_brightness_grid_clone(BrightnessGrid */*notnull*/ instance);
/**
* Calls [`servicepoint::BrightnessGrid::data_ref_mut`].
* Calls method [`servicepoint::BrightnessGrid::data_ref_mut`].
*
* Gets an unsafe reference to the data of the instance.
*
@ -966,7 +968,7 @@ BrightnessGrid */*notnull*/ sp_brightness_grid_clone(BrightnessGrid */*notnull*/
struct ByteSlice sp_brightness_grid_data_ref_mut(BrightnessGrid */*notnull*/ instance);
/**
* Calls [`servicepoint::BrightnessGrid::fill`].
* Calls method [`servicepoint::BrightnessGrid::fill`].
*
* Sets the value of all cells.
*
@ -987,7 +989,7 @@ void sp_brightness_grid_fill(BrightnessGrid */*notnull*/ instance,
void sp_brightness_grid_free(BrightnessGrid */*notnull*/ instance);
/**
* Calls [`servicepoint::BrightnessGrid::get`].
* Calls method [`servicepoint::BrightnessGrid::get`].
*
* Gets the current value at the specified position.
*
@ -1007,7 +1009,7 @@ Brightness sp_brightness_grid_get(BrightnessGrid */*notnull*/ instance,
size_t y);
/**
* Calls [`servicepoint::BrightnessGrid::height`].
* Calls method [`servicepoint::BrightnessGrid::height`].
*
* Gets the height of the grid.
*
@ -1065,7 +1067,7 @@ BrightnessGrid *sp_brightness_grid_load(size_t width,
BrightnessGrid */*notnull*/ sp_brightness_grid_new(size_t width, size_t height);
/**
* Calls [`servicepoint::BrightnessGrid::set`].
* Calls method [`servicepoint::BrightnessGrid::set`].
*
* Sets the value of the specified position.
*
@ -1088,7 +1090,7 @@ void sp_brightness_grid_set(BrightnessGrid */*notnull*/ instance,
Brightness value);
/**
* Calls [`servicepoint::BrightnessGrid::width`].
* Calls method [`servicepoint::BrightnessGrid::width`].
*
* Gets the width of the grid.
*
@ -1104,7 +1106,7 @@ size_t sp_brightness_grid_width(BrightnessGrid */*notnull*/ instance);
CharGrid */*notnull*/ sp_char_grid_clone(CharGrid */*notnull*/ instance);
/**
* Calls [`servicepoint::CharGrid::fill`].
* Calls method [`servicepoint::CharGrid::fill`].
*
* Sets the value of all cells in the grid.
*
@ -1125,7 +1127,7 @@ void sp_char_grid_fill(CharGrid */*notnull*/ instance, uint32_t value);
void sp_char_grid_free(CharGrid */*notnull*/ instance);
/**
* Calls [`servicepoint::CharGrid::get`].
* Calls method [`servicepoint::CharGrid::get`].
*
* Returns the current value at the specified position.
*
@ -1142,7 +1144,7 @@ void sp_char_grid_free(CharGrid */*notnull*/ instance);
uint32_t sp_char_grid_get(CharGrid */*notnull*/ instance, size_t x, size_t y);
/**
* Calls [`servicepoint::CharGrid::height`].
* Calls method [`servicepoint::CharGrid::height`].
*
* Gets the height of the grid.
*
@ -1191,7 +1193,7 @@ CharGrid *sp_char_grid_load(size_t width, size_t height, struct ByteSlice data);
CharGrid */*notnull*/ sp_char_grid_new(size_t width, size_t height);
/**
* Calls [`servicepoint::CharGrid::set`].
* Calls method [`servicepoint::CharGrid::set`].
*
* Sets the value of the specified position in the grid.
*
@ -1215,7 +1217,7 @@ void sp_char_grid_set(CharGrid */*notnull*/ instance,
uint32_t value);
/**
* Calls [`servicepoint::CharGrid::width`].
* Calls method [`servicepoint::CharGrid::width`].
*
* Gets the width of the grid.
*
@ -1824,7 +1826,7 @@ struct HardResetCommand */*notnull*/ sp_cmd_hard_reset_new(void);
Cp437Grid */*notnull*/ sp_cp437_grid_clone(Cp437Grid */*notnull*/ instance);
/**
* Calls [`servicepoint::Cp437Grid::data_ref_mut`].
* Calls method [`servicepoint::Cp437Grid::data_ref_mut`].
*
* Gets an unsafe reference to the data of the grid.
*
@ -1835,7 +1837,7 @@ Cp437Grid */*notnull*/ sp_cp437_grid_clone(Cp437Grid */*notnull*/ instance);
struct ByteSlice sp_cp437_grid_data_ref_mut(Cp437Grid */*notnull*/ instance);
/**
* Calls [`servicepoint::Cp437Grid::fill`].
* Calls method [`servicepoint::Cp437Grid::fill`].
*
* Sets the value of all cells in the grid.
*
@ -1856,7 +1858,7 @@ void sp_cp437_grid_fill(Cp437Grid */*notnull*/ instance, uint8_t value);
void sp_cp437_grid_free(Cp437Grid */*notnull*/ instance);
/**
* Calls [`servicepoint::Cp437Grid::get`].
* Calls method [`servicepoint::Cp437Grid::get`].
*
* Gets the current value at the specified position.
*
@ -1873,7 +1875,7 @@ void sp_cp437_grid_free(Cp437Grid */*notnull*/ instance);
uint8_t sp_cp437_grid_get(Cp437Grid */*notnull*/ instance, size_t x, size_t y);
/**
* Calls [`servicepoint::Cp437Grid::height`].
* Calls method [`servicepoint::Cp437Grid::height`].
*
* Gets the height of the grid.
*
@ -1913,7 +1915,7 @@ Cp437Grid *sp_cp437_grid_load(size_t width,
Cp437Grid */*notnull*/ sp_cp437_grid_new(size_t width, size_t height);
/**
* Calls [`servicepoint::Cp437Grid::set`].
* Calls method [`servicepoint::Cp437Grid::set`].
*
* Sets the value at the specified position.
*
@ -1936,7 +1938,7 @@ void sp_cp437_grid_set(Cp437Grid */*notnull*/ instance,
uint8_t value);
/**
* Calls [`servicepoint::Cp437Grid::width`].
* Calls method [`servicepoint::Cp437Grid::width`].
*
* Gets the width of the grid.
*

View file

@ -1,7 +1,6 @@
use crate::macros::wrap_functions;
use crate::{
containers::ByteSlice,
macros::{wrap_clone, wrap_free, wrap_methods},
macros::{wrap_clone, wrap_free, wrap_functions, wrap_methods},
mem::{heap_move_nonnull, heap_move_ok, heap_move_some, heap_remove},
};
use servicepoint::{
@ -121,11 +120,13 @@ wrap_methods!(
///
/// The returned memory is valid for the lifetime of the grid.
mut fn data_ref_mut() -> ByteSlice {
return(br_slice) { unsafe {
return(br_slice) {
//noinspection RsAssertEqual
const _: () = assert!(size_of::<Brightness>() == 1);
ByteSlice::from_slice(transmute::<&mut [Brightness], &mut [u8]>(br_slice))
}};
unsafe {
ByteSlice::from_slice(transmute::<&mut [Brightness], &mut [u8]>(br_slice))
}
};
};
);

View file

@ -26,7 +26,8 @@ pub struct ByteSlice {
}
impl ByteSlice {
pub(crate) const INVALID: ByteSlice = ByteSlice {
/// Represents an invalid [ByteSlice] instance.
pub const INVALID: ByteSlice = ByteSlice {
start: std::ptr::null_mut(),
length: 0,
};

View file

@ -11,3 +11,8 @@ pub use brightness_grid::*;
pub use byte_slice::*;
pub use char_grid::*;
pub use cp437_grid::*;
mod _hidden {
/// This is a type only used by cbindgen to have a type for pointers.
pub struct DisplayBitVec;
}

View file

@ -29,22 +29,16 @@
pub mod commands;
/// Functions related to [servicepoint::Bitmap], [servicepoint::CharGrid] and friends.
pub mod containers;
mod macros;
pub(crate) mod macros;
pub(crate) mod mem;
/// Functions related to [Packet].
/// Functions related to [servicepoint::Packet].
pub mod packet;
/// Functions related to [UdpSocket].
/// Functions related to [servicepoint::UdpSocketExt].
pub mod udp;
/// Actual hardware limit is around 28-29ms/frame. Rounded up for less dropped packets.
pub const SP_FRAME_PACING_MS: u128 = 30;
/// This is a type only used by cbindgen to have a type for pointers.
pub struct UdpSocket;
/// This is a type only used by cbindgen to have a type for pointers.
pub struct DisplayBitVec;
#[cfg(feature = "env_logger")]
mod feature_env_logger {
use crate::macros::wrap_functions;

View file

@ -50,7 +50,7 @@ macro_rules! wrap_methods {
paste::paste! {
$crate::macros::wrap_functions!($prefix;
$(
#[doc = concat!(" Calls [`servicepoint::", stringify!($object_type),
#[doc = concat!(" Calls method [`servicepoint::", stringify!($object_type),
"::", stringify!($function), "`].")]
#[doc = ""]
$(#[$meta])*

View file

@ -129,3 +129,11 @@ wrap_functions!(sp_udp;
}
);
mod _hidden {
/// This is a type only used by cbindgen to have a type for pointers.
///
/// See [servicepoint::UdpSocketExt].
#[allow(unused)]
pub struct UdpSocket;
}