diff --git a/crates/servicepoint_binding_c/examples/lang_c/include/servicepoint.h b/crates/servicepoint_binding_c/examples/lang_c/include/servicepoint.h index 465a89a..075f61c 100644 --- a/crates/servicepoint_binding_c/examples/lang_c/include/servicepoint.h +++ b/crates/servicepoint_binding_c/examples/lang_c/include/servicepoint.h @@ -735,7 +735,12 @@ bool sp_connection_send(const struct sp_Connection *connection, /** * Deallocates a `Packet`. * - * Note: do not call this if the instance has been consumed in another way, e.g. by sending it. + * # Safety + * + * The caller has to make sure that: + * + * - `this` points to a valid `Packet` + * - `this` is not used concurrently or after this call */ void sp_packet_dealloc(struct sp_Packet *this_); diff --git a/crates/servicepoint_binding_c/src/bit_vec.rs b/crates/servicepoint_binding_c/src/bit_vec.rs index 582e97d..ba4233d 100644 --- a/crates/servicepoint_binding_c/src/bit_vec.rs +++ b/crates/servicepoint_binding_c/src/bit_vec.rs @@ -1,5 +1,8 @@ -pub use servicepoint::BitVec; -use servicepoint::DataRef; +//! C functions for interacting with `BitVec`s +//! +//! prefix `sp_bit_vec_` + +use servicepoint::{BitVec, DataRef}; use crate::c_slice::CByteSlice; diff --git a/crates/servicepoint_binding_c/src/byte_grid.rs b/crates/servicepoint_binding_c/src/byte_grid.rs index d5dabb1..9b4425f 100644 --- a/crates/servicepoint_binding_c/src/byte_grid.rs +++ b/crates/servicepoint_binding_c/src/byte_grid.rs @@ -1,5 +1,8 @@ -pub use servicepoint::ByteGrid; -use servicepoint::{DataRef, Grid}; +//! C functions for interacting with `ByteGrid`s +//! +//! prefix `sp_byte_grid_` + +use servicepoint::{ByteGrid, DataRef, Grid}; use crate::c_slice::CByteSlice; diff --git a/crates/servicepoint_binding_c/src/command.rs b/crates/servicepoint_binding_c/src/command.rs index 23b9b7a..0c981f6 100644 --- a/crates/servicepoint_binding_c/src/command.rs +++ b/crates/servicepoint_binding_c/src/command.rs @@ -1,9 +1,13 @@ +//! C functions for interacting with `Command`s +//! +//! prefix `sp_command_` + use std::ptr::null_mut; use servicepoint::{ - BitVec, ByteGrid, CompressionCode, Origin, Packet, PixelGrid, + BitVec, Brightness, ByteGrid, Command, CompressionCode, Offset, Origin, + Packet, PixelGrid, }; -pub use servicepoint::{Brightness, Command, Offset}; /// Tries to turn a `Packet` into a `Command`. The packet is deallocated in the process. /// diff --git a/crates/servicepoint_binding_c/src/connection.rs b/crates/servicepoint_binding_c/src/connection.rs index 355dd7c..25b9cf7 100644 --- a/crates/servicepoint_binding_c/src/connection.rs +++ b/crates/servicepoint_binding_c/src/connection.rs @@ -1,8 +1,11 @@ +//! C functions for interacting with `Connection`s +//! +//! prefix `sp_connection_` + use std::ffi::{c_char, CStr}; use std::ptr::null_mut; -pub use servicepoint::Connection; -use servicepoint::Packet; +use servicepoint::{Connection, Packet}; /// Creates a new instance of `Connection`. /// diff --git a/crates/servicepoint_binding_c/src/lib.rs b/crates/servicepoint_binding_c/src/lib.rs index 48aa258..47ce5cb 100644 --- a/crates/servicepoint_binding_c/src/lib.rs +++ b/crates/servicepoint_binding_c/src/lib.rs @@ -7,34 +7,16 @@ pub use servicepoint::{ pub use crate::c_slice::CByteSlice; -/// C functions for interacting with `BitVec`s -/// -/// prefix `sp_bit_vec_` pub mod bit_vec; -/// C functions for interacting with `ByteGrid`s -/// -/// prefix `sp_byte_grid_` pub mod byte_grid; -/// C functions for interacting with `Command`s -/// -/// prefix `sp_command_` pub mod command; -/// C functions for interacting with `Connection`s -/// -/// prefix `sp_connection_` pub mod connection; -/// C functions for interacting with `Packet`s -/// -/// prefix `sp_packet_` pub mod packet; -/// C functions for interacting with `PixelGrid`s -/// -/// prefix `sp_pixel_grid_` pub mod pixel_grid; /// The minimum time needed for the display to refresh the screen in ms. diff --git a/crates/servicepoint_binding_c/src/packet.rs b/crates/servicepoint_binding_c/src/packet.rs index 48cdd9b..952ef1e 100644 --- a/crates/servicepoint_binding_c/src/packet.rs +++ b/crates/servicepoint_binding_c/src/packet.rs @@ -1,7 +1,10 @@ +//! C functions for interacting with `Packet`s +//! +//! prefix `sp_packet_` + use std::ptr::null_mut; -use servicepoint::Command; -pub use servicepoint::Packet; +use servicepoint::{Command, Packet}; /// Turns a `Command` into a `Packet`. /// The `Command` gets consumed. @@ -49,7 +52,12 @@ pub unsafe extern "C" fn sp_packet_try_load( /// Deallocates a `Packet`. /// -/// Note: do not call this if the instance has been consumed in another way, e.g. by sending it. +/// # Safety +/// +/// The caller has to make sure that: +/// +/// - `this` points to a valid `Packet` +/// - `this` is not used concurrently or after this call #[no_mangle] pub unsafe extern "C" fn sp_packet_dealloc(this: *mut Packet) { _ = Box::from_raw(this) diff --git a/crates/servicepoint_binding_c/src/pixel_grid.rs b/crates/servicepoint_binding_c/src/pixel_grid.rs index 0f07f5d..10cff60 100644 --- a/crates/servicepoint_binding_c/src/pixel_grid.rs +++ b/crates/servicepoint_binding_c/src/pixel_grid.rs @@ -1,3 +1,7 @@ +//! C functions for interacting with `PixelGrid`s +//! +//! prefix `sp_pixel_grid_` + use servicepoint::{DataRef, Grid, PixelGrid}; use crate::c_slice::CByteSlice; diff --git a/crates/servicepoint_binding_cs/ServicePoint/BindGen/ServicePoint.g.cs b/crates/servicepoint_binding_cs/ServicePoint/BindGen/ServicePoint.g.cs index 0d926ef..98fe381 100644 --- a/crates/servicepoint_binding_cs/ServicePoint/BindGen/ServicePoint.g.cs +++ b/crates/servicepoint_binding_cs/ServicePoint/BindGen/ServicePoint.g.cs @@ -220,7 +220,7 @@ namespace ServicePoint.BindGen [DllImport(__DllName, EntryPoint = "sp_packet_try_load", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Packet* sp_packet_try_load(byte* data, nuint length); - /// Deallocates a `Packet`. Note: do not call this if the instance has been consumed in another way, e.g. by sending it. + /// Deallocates a `Packet`. # Safety The caller has to make sure that: - `this` points to a valid `Packet` - `this` is not used concurrently or after this call [DllImport(__DllName, EntryPoint = "sp_packet_dealloc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void sp_packet_dealloc(Packet* @this);