doc changes

This commit is contained in:
Vinzenz Schroeter 2025-05-07 08:29:16 +02:00
parent a4bacd53a2
commit e7cad5b5a3
6 changed files with 87 additions and 31 deletions

View file

@ -26,7 +26,7 @@ pub unsafe extern "C" fn sp_cmd_bitmap_new(
/// Move the provided [Bitmap] into a new [BitmapCommand],
/// leaving other fields as their default values.
///
/// Rust equivalent: [`<BitmapCommand as From<Bitmap>>::from`]
/// Rust equivalent: `BitmapCommand::from(bitmap)`
#[no_mangle]
pub unsafe extern "C" fn sp_cmd_bitmap_from_bitmap(
bitmap: NonNull<Bitmap>,

View file

@ -46,7 +46,9 @@ pub unsafe extern "C" fn sp_cmd_cp437_grid_free(
unsafe { heap_drop(command) }
}
/// Moves the provided bitmap to be contained in the command.
/// Moves the provided bitmap into the provided command.
///
/// This drops the previously contained [Cp437Grid].
#[no_mangle]
pub unsafe extern "C" fn sp_cmd_cp437_grid_set(
mut command: NonNull<Cp437GridCommand>,
@ -64,6 +66,9 @@ pub unsafe extern "C" fn sp_cmd_cp437_grid_get(
&mut unsafe { command.as_mut() }.grid
}
/// Gets the origin field of the [Cp437GridCommand].
///
/// Rust equivalent: `cp437_command.origin`
#[no_mangle]
pub unsafe extern "C" fn sp_cmd_cp437_grid_get_origin(
command: NonNull<Cp437GridCommand>,
@ -77,6 +82,10 @@ pub unsafe extern "C" fn sp_cmd_cp437_grid_get_origin(
}
}
/// Sets the origin field of the [Cp437GridCommand].
///
/// Rust equivalent: `cp437_command.origin = Origin::new(origin_x, origin_y)`
#[no_mangle]
pub unsafe extern "C" fn sp_cmd_cp437_grid_set_origin(
mut command: NonNull<Cp437GridCommand>,

View file

@ -8,7 +8,9 @@ use servicepoint::{
};
use std::ptr::{null_mut, NonNull};
/// Pointer to one of the available command structs.
#[repr(C)]
#[allow(missing_docs)]
pub union CommandUnion {
pub null: *mut u8,
pub bitmap: NonNull<BitmapCommand>,
@ -24,7 +26,11 @@ pub union CommandUnion {
pub fade_out: NonNull<FadeOutCommand>,
}
/// Specifies the kind of command struct.
///
/// This is _not_ equivalent to the [servicepoint::CommandCode]s.
#[repr(u8)]
#[allow(missing_docs)]
pub enum CommandTag {
Invalid = 0,
Bitmap,
@ -39,6 +45,11 @@ pub enum CommandTag {
BitmapLegacy,
}
/// This struct represents a pointer to one of the possible command structs.
///
/// Only ever access `data` with the correct data type as specified by `tag`!
///
/// Rust equivalent: [TypedCommand].
#[repr(C)]
pub struct SPCommand {
/// Specifies which kind of command struct is contained in `data`
@ -59,7 +70,7 @@ impl SPCommand {
/// The packet is deallocated in the process.
///
/// Returns: pointer to new [TypedCommand] instance or NULL if parsing failed.
/// #[no_mangle]
#[no_mangle]
pub unsafe extern "C" fn sp_cmd_generic_try_from_packet(
packet: NonNull<Packet>,
) -> *mut SPCommand {