add example helper, translate more examples

update to wip servicepoint lib
This commit is contained in:
Vinzenz Schroeter 2025-05-10 14:58:50 +02:00
parent b8a55d0433
commit 4ab5305377
15 changed files with 195 additions and 61 deletions

View file

@ -1,3 +1,6 @@
#ifndef SERVICEPOINT_BINDINGS_C
#define SERVICEPOINT_BINDINGS_C
/* Generated with cbindgen:0.28.0 */
/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */
@ -446,12 +449,19 @@ typedef struct ValueGrid_u8 ValueGrid_u8;
* - accesses to the memory pointed to with `start` is never accessed outside `length`
* - the lifetime of the `CByteSlice` does not outlive the memory it points to, as described in
* the function returning this type.
* - if `start` is NULL or `length` is 0, do not dereference `start`.
*
* # Examples
*
* ```c
* ByteSlice empty = {.start: NULL, .length = 0};
* ```
*/
typedef struct {
/**
* The start address of the memory.
*/
uint8_t */*notnull*/ start;
uint8_t *start;
/**
* The amount of memory in bytes.
*/
@ -606,6 +616,13 @@ typedef struct {
/**
* Actual hardware limit is around 28-29ms/frame. Rounded up for less dropped packets.
*/
#define SP_FRAME_PACING_MS 30
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
@ -1703,8 +1720,7 @@ void sp_packet_free(Packet */*notnull*/ packet);
*
* returns: new instance. Will never return null.
*/
Packet */*notnull*/ sp_packet_from_parts(Header header,
const ByteSlice *payload);
Packet */*notnull*/ sp_packet_from_parts(Header header, ByteSlice payload);
/**
* Returns a pointer to the header field of the provided packet.
@ -1716,6 +1732,8 @@ Header */*notnull*/ sp_packet_get_header(Packet */*notnull*/ packet);
/**
* Returns a pointer to the current payload of the provided packet.
*
* Returns an [ByteSlice::INVALID] instance in case the packet does not have any payload.
*
* The returned memory can be changed and will be valid until a new payload is set.
*/
ByteSlice sp_packet_get_payload(Packet */*notnull*/ packet);
@ -1831,3 +1849,5 @@ bool sp_udp_send_packet(UdpSocket */*notnull*/ connection,
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#endif /* SERVICEPOINT_BINDINGS_C */