change typedef style, add optional logging
Some checks failed
Rust / build-gnu-apt (pull_request) Failing after 1m24s
Rust / build-size-gnu-unstable (pull_request) Failing after 1m28s

This commit is contained in:
Vinzenz Schroeter 2025-05-16 00:33:27 +02:00
parent 0c6efcee56
commit 389ced492c
6 changed files with 286 additions and 163 deletions

102
Cargo.lock generated
View file

@ -8,6 +8,15 @@ version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
[[package]]
name = "aho-corasick"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
dependencies = [
"memchr",
]
[[package]] [[package]]
name = "anstream" name = "anstream"
version = "0.6.18" version = "0.6.18"
@ -173,6 +182,29 @@ dependencies = [
"cfg-if", "cfg-if",
] ]
[[package]]
name = "env_filter"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0"
dependencies = [
"log",
"regex",
]
[[package]]
name = "env_logger"
version = "0.11.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13c863f0904021b108aa8b2f55046443e6b1ebde8fd4a15c399893aae4fa069f"
dependencies = [
"anstream",
"anstyle",
"env_filter",
"jiff",
"log",
]
[[package]] [[package]]
name = "equivalent" name = "equivalent"
version = "1.0.2" version = "1.0.2"
@ -257,6 +289,30 @@ version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
[[package]]
name = "jiff"
version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f02000660d30638906021176af16b17498bd0d12813dbfe7b276d8bc7f3c0806"
dependencies = [
"jiff-static",
"log",
"portable-atomic",
"portable-atomic-util",
"serde",
]
[[package]]
name = "jiff-static"
version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3c30758ddd7188629c6713fc45d1188af4f44c90582311d0c8d8c9907f60c48"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "jobserver" name = "jobserver"
version = "0.1.33" version = "0.1.33"
@ -312,6 +368,21 @@ version = "0.3.32"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
[[package]]
name = "portable-atomic"
version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e"
[[package]]
name = "portable-atomic-util"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507"
dependencies = [
"portable-atomic",
]
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.95" version = "1.0.95"
@ -342,6 +413,35 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09"
[[package]]
name = "regex"
version = "1.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
[[package]] [[package]]
name = "rust-lzma" name = "rust-lzma"
version = "0.6.0" version = "0.6.0"
@ -415,7 +515,6 @@ dependencies = [
[[package]] [[package]]
name = "servicepoint" name = "servicepoint"
version = "0.14.1" version = "0.14.1"
source = "git+https://git.berlin.ccc.de/servicepoint/servicepoint.git?branch=next#d979d46d3e770222c5a7ca549e601b45eff48299"
dependencies = [ dependencies = [
"bitvec", "bitvec",
"bzip2", "bzip2",
@ -432,6 +531,7 @@ name = "servicepoint_binding_c"
version = "0.14.1" version = "0.14.1"
dependencies = [ dependencies = [
"cbindgen", "cbindgen",
"env_logger",
"servicepoint", "servicepoint",
] ]

View file

@ -18,14 +18,17 @@ crate-type = ["staticlib", "cdylib", "rlib"]
cbindgen = "0.28.0" cbindgen = "0.28.0"
[dependencies.servicepoint] [dependencies.servicepoint]
# version = "0.14.1" version = "0.14.1"
default-features = false default-features = false
git = "https://git.berlin.ccc.de/servicepoint/servicepoint.git"
branch = "next" [dependencies.env_logger]
version = "0.11.8"
optional = true
[features] [features]
all_compressions = ["servicepoint/all_compressions"] all_compressions = ["servicepoint/all_compressions"]
default = ["all_compressions", "servicepoint/default"] default = ["all_compressions", "servicepoint/default", "env_logger"]
env_logger = ["dep:env_logger"]
[lints.rust] [lints.rust]
missing-docs = "warn" missing-docs = "warn"

View file

@ -16,7 +16,7 @@ line_endings = "LF"
############################# Codegen Options ################################## ############################# Codegen Options ##################################
style = "type" style = "both"
usize_is_size_t = true usize_is_size_t = true
# this is needed because otherwise the order in the C bindings is different on different machines # this is needed because otherwise the order in the C bindings is different on different machines

View file

@ -1,7 +1,7 @@
CARGO ?= cargo CARGO ?= cargo
STRIP ?= strip STRIP ?= strip
FEATURES := "" FEATURES := "env_logger"
THIS_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) THIS_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
REPO_ROOT := $(realpath $(THIS_DIR)/..) REPO_ROOT := $(realpath $(THIS_DIR)/..)
@ -99,7 +99,7 @@ clean-rust:
.PHONY: all clean sizes $(_run_programs) clean-c clean-rust .PHONY: all clean sizes $(_run_programs) clean-c clean-rust
$(_unstripped_bins): out/%_unstripped: src/%.c $(SERVICEPOINT_HEADER_OUT)/servicepoint.h $(_sp_artifacts) $(_unstripped_bins): out/%_unstripped: src/%.c $(SERVICEPOINT_HEADER_OUT)/servicepoint.h src/helpers.h $(_sp_artifacts)
mkdir -p out || true mkdir -p out || true
$(CC) $< \ $(CC) $< \
-I $(SERVICEPOINT_HEADER_OUT) \ -I $(SERVICEPOINT_HEADER_OUT) \

View file

@ -457,7 +457,7 @@ typedef struct ValueGrid_u8 ValueGrid_u8;
* ByteSlice empty = {.start: NULL, .length = 0}; * ByteSlice empty = {.start: NULL, .length = 0};
* ``` * ```
*/ */
typedef struct { typedef struct ByteSlice {
/** /**
* The start address of the memory. * The start address of the memory.
*/ */
@ -486,7 +486,7 @@ typedef struct {
* }).unwrap() * }).unwrap()
* ``` * ```
*/ */
typedef ValueGrid_Brightness BrightnessGrid; typedef struct ValueGrid_Brightness BrightnessGrid;
/** /**
* A display brightness value, checked for correct value range * A display brightness value, checked for correct value range
@ -532,7 +532,7 @@ typedef uint8_t Brightness;
* connection.send_command(command).unwrap() * connection.send_command(command).unwrap()
* ``` * ```
*/ */
typedef ValueGrid_char CharGrid; typedef struct ValueGrid_char CharGrid;
/** /**
* Type alias for documenting the meaning of the u16 in enum values * Type alias for documenting the meaning of the u16 in enum values
@ -544,23 +544,23 @@ typedef size_t Offset;
* *
* The encoding is currently not enforced. * The encoding is currently not enforced.
*/ */
typedef ValueGrid_u8 Cp437Grid; typedef struct ValueGrid_u8 Cp437Grid;
/** /**
* Pointer to one of the available command structs. * Pointer to one of the available command structs.
*/ */
typedef union { typedef union CommandUnion {
uint8_t *null; uint8_t *null;
BitmapCommand */*notnull*/ bitmap; struct BitmapCommand */*notnull*/ bitmap;
BitVecCommand */*notnull*/ bitvec; struct BitVecCommand */*notnull*/ bitvec;
BrightnessGridCommand */*notnull*/ brightness_grid; struct BrightnessGridCommand */*notnull*/ brightness_grid;
CharGridCommand */*notnull*/ char_grid; struct CharGridCommand */*notnull*/ char_grid;
Cp437GridCommand */*notnull*/ cp437_grid; struct Cp437GridCommand */*notnull*/ cp437_grid;
GlobalBrightnessCommand */*notnull*/ global_brightness; struct GlobalBrightnessCommand */*notnull*/ global_brightness;
ClearCommand */*notnull*/ clear; struct ClearCommand */*notnull*/ clear;
BitmapLegacyCommand */*notnull*/ bitmap_legacy; struct BitmapLegacyCommand */*notnull*/ bitmap_legacy;
HardResetCommand */*notnull*/ hard_reset; struct HardResetCommand */*notnull*/ hard_reset;
FadeOutCommand */*notnull*/ fade_out; struct FadeOutCommand */*notnull*/ fade_out;
} CommandUnion; } CommandUnion;
/** /**
@ -570,7 +570,7 @@ typedef union {
* *
* Rust equivalent: [TypedCommand]. * Rust equivalent: [TypedCommand].
*/ */
typedef struct { typedef struct Command {
/** /**
* Specifies which kind of command struct is contained in `data` * Specifies which kind of command struct is contained in `data`
*/ */
@ -578,7 +578,7 @@ typedef struct {
/** /**
* The pointer to the command struct * The pointer to the command struct
*/ */
CommandUnion data; union CommandUnion data;
} Command; } Command;
/** /**
@ -591,7 +591,7 @@ typedef struct {
* *
* The contained values are in platform endian-ness and may need to be converted before sending. * The contained values are in platform endian-ness and may need to be converted before sending.
*/ */
typedef struct { typedef struct Header {
/** /**
* The first two bytes specify which command this packet represents. * The first two bytes specify which command this packet represents.
*/ */
@ -627,10 +627,12 @@ typedef struct {
extern "C" { extern "C" {
#endif // __cplusplus #endif // __cplusplus
void init_env_logger(void);
/** /**
* Clones a [Bitmap]. * Clones a [Bitmap].
*/ */
Bitmap */*notnull*/ sp_bitmap_clone(Bitmap */*notnull*/ bitmap); struct Bitmap */*notnull*/ sp_bitmap_clone(struct Bitmap */*notnull*/ bitmap);
/** /**
* Sets the state of all pixels in the [Bitmap]. * Sets the state of all pixels in the [Bitmap].
@ -640,12 +642,12 @@ Bitmap */*notnull*/ sp_bitmap_clone(Bitmap */*notnull*/ bitmap);
* - `bitmap`: instance to write to * - `bitmap`: instance to write to
* - `value`: the value to set all pixels to * - `value`: the value to set all pixels to
*/ */
void sp_bitmap_fill(Bitmap */*notnull*/ bitmap, bool value); void sp_bitmap_fill(struct Bitmap */*notnull*/ bitmap, bool value);
/** /**
* Deallocates a [Bitmap]. * Deallocates a [Bitmap].
*/ */
void sp_bitmap_free(Bitmap */*notnull*/ bitmap); void sp_bitmap_free(struct Bitmap */*notnull*/ bitmap);
/** /**
* Tries to convert the BitVec to a Bitmap. * Tries to convert the BitVec to a Bitmap.
@ -654,7 +656,7 @@ void sp_bitmap_free(Bitmap */*notnull*/ bitmap);
* *
* Returns NULL in case of error. * Returns NULL in case of error.
*/ */
Bitmap *sp_bitmap_from_bitvec(size_t width, BitVec */*notnull*/ bitvec); struct Bitmap *sp_bitmap_from_bitvec(size_t width, BitVec */*notnull*/ bitvec);
/** /**
* Gets the current value at the specified position in the [Bitmap]. * Gets the current value at the specified position in the [Bitmap].
@ -668,7 +670,7 @@ Bitmap *sp_bitmap_from_bitvec(size_t width, BitVec */*notnull*/ bitvec);
* *
* - when accessing `x` or `y` out of bounds * - when accessing `x` or `y` out of bounds
*/ */
bool sp_bitmap_get(Bitmap */*notnull*/ bitmap, size_t x, size_t y); bool sp_bitmap_get(struct Bitmap */*notnull*/ bitmap, size_t x, size_t y);
/** /**
* Gets the height in pixels of the [Bitmap] instance. * Gets the height in pixels of the [Bitmap] instance.
@ -677,12 +679,12 @@ bool sp_bitmap_get(Bitmap */*notnull*/ bitmap, size_t x, size_t y);
* *
* - `bitmap`: instance to read from * - `bitmap`: instance to read from
*/ */
size_t sp_bitmap_height(Bitmap */*notnull*/ bitmap); size_t sp_bitmap_height(struct Bitmap */*notnull*/ bitmap);
/** /**
* Consumes the Bitmap and returns the contained BitVec * Consumes the Bitmap and returns the contained BitVec
*/ */
BitVec */*notnull*/ sp_bitmap_into_bitvec(Bitmap */*notnull*/ bitmap); BitVec */*notnull*/ sp_bitmap_into_bitvec(struct Bitmap */*notnull*/ bitmap);
/** /**
* Creates a [BitmapCommand] and immediately turns that into a [Packet]. * Creates a [BitmapCommand] and immediately turns that into a [Packet].
@ -691,7 +693,7 @@ BitVec */*notnull*/ sp_bitmap_into_bitvec(Bitmap */*notnull*/ bitmap);
* *
* Returns NULL in case of an error. * Returns NULL in case of an error.
*/ */
Packet *sp_bitmap_into_packet(Bitmap */*notnull*/ bitmap, struct Packet *sp_bitmap_into_packet(struct Bitmap */*notnull*/ bitmap,
size_t x, size_t x,
size_t y, size_t y,
CompressionCode compression); CompressionCode compression);
@ -706,9 +708,9 @@ Packet *sp_bitmap_into_packet(Bitmap */*notnull*/ bitmap,
* *
* returns: [Bitmap] that contains a copy of the provided data, or NULL in case of an error. * returns: [Bitmap] that contains a copy of the provided data, or NULL in case of an error.
*/ */
Bitmap *sp_bitmap_load(size_t width, struct Bitmap *sp_bitmap_load(size_t width,
size_t height, size_t height,
ByteSlice data); struct ByteSlice data);
/** /**
* Creates a new [Bitmap] with the specified dimensions. * Creates a new [Bitmap] with the specified dimensions.
@ -735,14 +737,14 @@ Bitmap *sp_bitmap_load(size_t width,
* sp_bitmap_free(grid); * sp_bitmap_free(grid);
* ``` * ```
*/ */
Bitmap *sp_bitmap_new(size_t width, size_t height); struct Bitmap *sp_bitmap_new(size_t width, size_t height);
/** /**
* Creates a new [Bitmap] with a size matching the screen. * Creates a new [Bitmap] with a size matching the screen.
* *
* returns: [Bitmap] initialized to all pixels off. * returns: [Bitmap] initialized to all pixels off.
*/ */
Bitmap */*notnull*/ sp_bitmap_new_max_sized(void); struct Bitmap */*notnull*/ sp_bitmap_new_max_sized(void);
/** /**
* Sets the value of the specified position in the [Bitmap]. * Sets the value of the specified position in the [Bitmap].
@ -757,14 +759,17 @@ Bitmap */*notnull*/ sp_bitmap_new_max_sized(void);
* *
* - when accessing `x` or `y` out of bounds * - when accessing `x` or `y` out of bounds
*/ */
void sp_bitmap_set(Bitmap */*notnull*/ bitmap, size_t x, size_t y, bool value); void sp_bitmap_set(struct Bitmap */*notnull*/ bitmap,
size_t x,
size_t y,
bool value);
/** /**
* Gets an unsafe reference to the data of the [Bitmap] instance. * Gets an unsafe reference to the data of the [Bitmap] instance.
* *
* The returned memory is valid for the lifetime of the bitmap. * The returned memory is valid for the lifetime of the bitmap.
*/ */
ByteSlice sp_bitmap_unsafe_data_ref(Bitmap */*notnull*/ bitmap); struct ByteSlice sp_bitmap_unsafe_data_ref(struct Bitmap */*notnull*/ bitmap);
/** /**
* Gets the width in pixels of the [Bitmap] instance. * Gets the width in pixels of the [Bitmap] instance.
@ -783,7 +788,7 @@ ByteSlice sp_bitmap_unsafe_data_ref(Bitmap */*notnull*/ bitmap);
* *
* - `bitmap` points to a valid [Bitmap] * - `bitmap` points to a valid [Bitmap]
*/ */
size_t sp_bitmap_width(Bitmap */*notnull*/ bitmap); size_t sp_bitmap_width(struct Bitmap */*notnull*/ bitmap);
/** /**
* Clones a [DisplayBitVec]. * Clones a [DisplayBitVec].
@ -828,7 +833,7 @@ bool sp_bitvec_get(BitVec */*notnull*/ bit_vec, size_t index);
* *
* Returns NULL in case of an error. * Returns NULL in case of an error.
*/ */
Packet *sp_bitvec_into_packet(BitVec */*notnull*/ bitvec, struct Packet *sp_bitvec_into_packet(BitVec */*notnull*/ bitvec,
size_t offset, size_t offset,
BinaryOperation operation, BinaryOperation operation,
CompressionCode compression); CompressionCode compression);
@ -856,7 +861,7 @@ size_t sp_bitvec_len(BitVec */*notnull*/ bit_vec);
* *
* returns: [DisplayBitVec] instance containing data. * returns: [DisplayBitVec] instance containing data.
*/ */
BitVec */*notnull*/ sp_bitvec_load(ByteSlice data); BitVec */*notnull*/ sp_bitvec_load(struct ByteSlice data);
/** /**
* Creates a new [DisplayBitVec] instance. * Creates a new [DisplayBitVec] instance.
@ -897,7 +902,7 @@ void sp_bitvec_set(BitVec */*notnull*/ bit_vec, size_t index, bool value);
* *
* - `bit_vec`: instance to write to * - `bit_vec`: instance to write to
*/ */
ByteSlice sp_bitvec_unsafe_data_ref(BitVec */*notnull*/ bit_vec); struct ByteSlice sp_bitvec_unsafe_data_ref(BitVec */*notnull*/ bit_vec);
/** /**
* Clones a [BrightnessGrid]. * Clones a [BrightnessGrid].
@ -955,7 +960,7 @@ size_t sp_brightness_grid_height(BrightnessGrid */*notnull*/ brightness_grid);
* *
* Returns NULL in case of an error. * Returns NULL in case of an error.
*/ */
Packet *sp_brightness_grid_into_packet(BrightnessGrid */*notnull*/ grid, struct Packet *sp_brightness_grid_into_packet(BrightnessGrid */*notnull*/ grid,
size_t x, size_t x,
size_t y); size_t y);
@ -968,7 +973,7 @@ Packet *sp_brightness_grid_into_packet(BrightnessGrid */*notnull*/ grid,
*/ */
BrightnessGrid *sp_brightness_grid_load(size_t width, BrightnessGrid *sp_brightness_grid_load(size_t width,
size_t height, size_t height,
ByteSlice data); struct ByteSlice data);
/** /**
* Creates a new [BrightnessGrid] with the specified dimensions. * Creates a new [BrightnessGrid] with the specified dimensions.
@ -1022,7 +1027,7 @@ void sp_brightness_grid_set(BrightnessGrid */*notnull*/ brightness_grid,
* *
* returns: slice of bytes underlying the `brightness_grid`. * returns: slice of bytes underlying the `brightness_grid`.
*/ */
ByteSlice sp_brightness_grid_unsafe_data_ref(BrightnessGrid */*notnull*/ brightness_grid); struct ByteSlice sp_brightness_grid_unsafe_data_ref(BrightnessGrid */*notnull*/ brightness_grid);
/** /**
* Gets the width of the [BrightnessGrid] instance. * Gets the width of the [BrightnessGrid] instance.
@ -1085,7 +1090,7 @@ size_t sp_char_grid_height(CharGrid */*notnull*/ char_grid);
* *
* Returns NULL in case of an error. * Returns NULL in case of an error.
*/ */
Packet *sp_char_grid_into_packet(CharGrid */*notnull*/ grid, struct Packet *sp_char_grid_into_packet(CharGrid */*notnull*/ grid,
size_t x, size_t x,
size_t y); size_t y);
@ -1094,7 +1099,7 @@ Packet *sp_char_grid_into_packet(CharGrid */*notnull*/ grid,
* *
* returns: new CharGrid or NULL in case of an error * returns: new CharGrid or NULL in case of an error
*/ */
CharGrid *sp_char_grid_load(size_t width, size_t height, ByteSlice data); CharGrid *sp_char_grid_load(size_t width, size_t height, struct ByteSlice data);
/** /**
* Creates a new [CharGrid] with the specified dimensions. * Creates a new [CharGrid] with the specified dimensions.
@ -1146,12 +1151,12 @@ size_t sp_char_grid_width(CharGrid */*notnull*/ char_grid);
* *
* returns: a new [BitmapCommand] instance. * returns: a new [BitmapCommand] instance.
*/ */
BitmapCommand */*notnull*/ sp_cmd_bitmap_clone(BitmapCommand */*notnull*/ command); struct BitmapCommand */*notnull*/ sp_cmd_bitmap_clone(struct BitmapCommand */*notnull*/ command);
/** /**
* Deallocates a [BitmapCommand] instance. * Deallocates a [BitmapCommand] instance.
*/ */
void sp_cmd_bitmap_free(BitmapCommand */*notnull*/ command); void sp_cmd_bitmap_free(struct BitmapCommand */*notnull*/ command);
/** /**
* Move the provided [Bitmap] into a new [BitmapCommand], * Move the provided [Bitmap] into a new [BitmapCommand],
@ -1159,7 +1164,7 @@ void sp_cmd_bitmap_free(BitmapCommand */*notnull*/ command);
* *
* Rust equivalent: `BitmapCommand::from(bitmap)` * Rust equivalent: `BitmapCommand::from(bitmap)`
*/ */
BitmapCommand */*notnull*/ sp_cmd_bitmap_from_bitmap(Bitmap */*notnull*/ bitmap); struct BitmapCommand */*notnull*/ sp_cmd_bitmap_from_bitmap(struct Bitmap */*notnull*/ bitmap);
/** /**
* Returns a pointer to the provided `BitmapCommand`. * Returns a pointer to the provided `BitmapCommand`.
@ -1169,17 +1174,17 @@ BitmapCommand */*notnull*/ sp_cmd_bitmap_from_bitmap(Bitmap */*notnull*/ bitmap)
* - The returned bitmap inherits the lifetime of the command in which it is contained. * - The returned bitmap inherits the lifetime of the command in which it is contained.
* - The returned pointer may not be used in a function that consumes the instance, e.g. to create a command. * - The returned pointer may not be used in a function that consumes the instance, e.g. to create a command.
*/ */
Bitmap */*notnull*/ sp_cmd_bitmap_get(BitmapCommand */*notnull*/ command); struct Bitmap */*notnull*/ sp_cmd_bitmap_get(struct BitmapCommand */*notnull*/ command);
/** /**
* Reads the compression kind of the [BitmapCommand]. * Reads the compression kind of the [BitmapCommand].
*/ */
CompressionCode sp_cmd_bitmap_get_compression(BitmapCommand */*notnull*/ command); CompressionCode sp_cmd_bitmap_get_compression(struct BitmapCommand */*notnull*/ command);
/** /**
* Reads the origin field of the [BitmapCommand]. * Reads the origin field of the [BitmapCommand].
*/ */
void sp_cmd_bitmap_get_origin(BitmapCommand */*notnull*/ command, void sp_cmd_bitmap_get_origin(struct BitmapCommand */*notnull*/ command,
size_t */*notnull*/ origin_x, size_t */*notnull*/ origin_x,
size_t */*notnull*/ origin_y); size_t */*notnull*/ origin_y);
@ -1190,7 +1195,7 @@ void sp_cmd_bitmap_get_origin(BitmapCommand */*notnull*/ command,
* *
* Returns: a new [BitmapCommand] instance. * Returns: a new [BitmapCommand] instance.
*/ */
BitmapCommand */*notnull*/ sp_cmd_bitmap_new(Bitmap */*notnull*/ bitmap, struct BitmapCommand */*notnull*/ sp_cmd_bitmap_new(struct Bitmap */*notnull*/ bitmap,
size_t origin_x, size_t origin_x,
size_t origin_y, size_t origin_y,
CompressionCode compression); CompressionCode compression);
@ -1198,19 +1203,19 @@ BitmapCommand */*notnull*/ sp_cmd_bitmap_new(Bitmap */*notnull*/ bitmap,
/** /**
* Moves the provided [Bitmap] to be contained in the [BitmapCommand]. * Moves the provided [Bitmap] to be contained in the [BitmapCommand].
*/ */
void sp_cmd_bitmap_set(BitmapCommand */*notnull*/ command, void sp_cmd_bitmap_set(struct BitmapCommand */*notnull*/ command,
Bitmap */*notnull*/ bitmap); struct Bitmap */*notnull*/ bitmap);
/** /**
* Overwrites the compression kind of the [BitmapCommand]. * Overwrites the compression kind of the [BitmapCommand].
*/ */
void sp_cmd_bitmap_set_compression(BitmapCommand */*notnull*/ command, void sp_cmd_bitmap_set_compression(struct BitmapCommand */*notnull*/ command,
CompressionCode compression); CompressionCode compression);
/** /**
* Overwrites the origin field of the [BitmapCommand]. * Overwrites the origin field of the [BitmapCommand].
*/ */
void sp_cmd_bitmap_set_origin(BitmapCommand */*notnull*/ command, void sp_cmd_bitmap_set_origin(struct BitmapCommand */*notnull*/ command,
size_t origin_x, size_t origin_x,
size_t origin_y); size_t origin_y);
@ -1219,39 +1224,39 @@ void sp_cmd_bitmap_set_origin(BitmapCommand */*notnull*/ command,
* *
* Returns: NULL or a [Packet] containing the command. * Returns: NULL or a [Packet] containing the command.
*/ */
Packet *sp_cmd_bitmap_try_into_packet(BitmapCommand */*notnull*/ command); struct Packet *sp_cmd_bitmap_try_into_packet(struct BitmapCommand */*notnull*/ command);
/** /**
* Clones an [BitVecCommand] instance. * Clones an [BitVecCommand] instance.
* *
* returns: a new [BitVecCommand] instance. * returns: a new [BitVecCommand] instance.
*/ */
BitVecCommand */*notnull*/ sp_cmd_bitvec_clone(BitVecCommand */*notnull*/ command); struct BitVecCommand */*notnull*/ sp_cmd_bitvec_clone(struct BitVecCommand */*notnull*/ command);
/** /**
* Deallocates a [BitVecCommand]. * Deallocates a [BitVecCommand].
*/ */
void sp_cmd_bitvec_free(BitVecCommand */*notnull*/ command); void sp_cmd_bitvec_free(struct BitVecCommand */*notnull*/ command);
/** /**
* Returns a pointer to the [BitVec] contained in the [BitVecCommand]. * Returns a pointer to the [BitVec] contained in the [BitVecCommand].
*/ */
BitVec *sp_cmd_bitvec_get(BitVecCommand */*notnull*/ command); BitVec *sp_cmd_bitvec_get(struct BitVecCommand */*notnull*/ command);
/** /**
* Reads the compression kind of the [BitVecCommand]. * Reads the compression kind of the [BitVecCommand].
*/ */
CompressionCode sp_cmd_bitvec_get_compression(BitVecCommand */*notnull*/ command); CompressionCode sp_cmd_bitvec_get_compression(struct BitVecCommand */*notnull*/ command);
/** /**
* Reads the offset field of the [BitVecCommand]. * Reads the offset field of the [BitVecCommand].
*/ */
Offset sp_cmd_bitvec_get_offset(BitVecCommand */*notnull*/ command); Offset sp_cmd_bitvec_get_offset(struct BitVecCommand */*notnull*/ command);
/** /**
* Returns the [BinaryOperation] of the command. * Returns the [BinaryOperation] of the command.
*/ */
BinaryOperation sp_cmd_bitvec_get_operation(BitVecCommand */*notnull*/ command); BinaryOperation sp_cmd_bitvec_get_operation(struct BitVecCommand */*notnull*/ command);
/** /**
* Set pixel data starting at the pixel offset on screen. * Set pixel data starting at the pixel offset on screen.
@ -1267,7 +1272,7 @@ BinaryOperation sp_cmd_bitvec_get_operation(BitVecCommand */*notnull*/ command);
* *
* The contained [`DisplayBitVec`] is always uncompressed. * The contained [`DisplayBitVec`] is always uncompressed.
*/ */
BitVecCommand */*notnull*/ sp_cmd_bitvec_new(BitVec */*notnull*/ bitvec, struct BitVecCommand */*notnull*/ sp_cmd_bitvec_new(BitVec */*notnull*/ bitvec,
size_t offset, size_t offset,
BinaryOperation operation, BinaryOperation operation,
CompressionCode compression); CompressionCode compression);
@ -1275,25 +1280,25 @@ BitVecCommand */*notnull*/ sp_cmd_bitvec_new(BitVec */*notnull*/ bitvec,
/** /**
* Moves the provided [BitVec] to be contained in the [BitVecCommand]. * Moves the provided [BitVec] to be contained in the [BitVecCommand].
*/ */
void sp_cmd_bitvec_set(BitVecCommand */*notnull*/ command, void sp_cmd_bitvec_set(struct BitVecCommand */*notnull*/ command,
BitVec */*notnull*/ bitvec); BitVec */*notnull*/ bitvec);
/** /**
* Overwrites the compression kind of the [BitVecCommand]. * Overwrites the compression kind of the [BitVecCommand].
*/ */
void sp_cmd_bitvec_set_compression(BitVecCommand */*notnull*/ command, void sp_cmd_bitvec_set_compression(struct BitVecCommand */*notnull*/ command,
CompressionCode compression); CompressionCode compression);
/** /**
* Overwrites the offset field of the [BitVecCommand]. * Overwrites the offset field of the [BitVecCommand].
*/ */
void sp_cmd_bitvec_set_offset(BitVecCommand */*notnull*/ command, void sp_cmd_bitvec_set_offset(struct BitVecCommand */*notnull*/ command,
Offset offset); Offset offset);
/** /**
* Overwrites the [BinaryOperation] of the command. * Overwrites the [BinaryOperation] of the command.
*/ */
void sp_cmd_bitvec_set_operation(BitVecCommand */*notnull*/ command, void sp_cmd_bitvec_set_operation(struct BitVecCommand */*notnull*/ command,
BinaryOperation operation); BinaryOperation operation);
/** /**
@ -1301,32 +1306,32 @@ void sp_cmd_bitvec_set_operation(BitVecCommand */*notnull*/ command,
* *
* Returns: NULL or a [Packet] containing the command. * Returns: NULL or a [Packet] containing the command.
*/ */
Packet *sp_cmd_bitvec_try_into_packet(BitVecCommand */*notnull*/ command); struct Packet *sp_cmd_bitvec_try_into_packet(struct BitVecCommand */*notnull*/ command);
/** /**
* Clones an [GlobalBrightnessCommand] instance. * Clones an [GlobalBrightnessCommand] instance.
* *
* returns: a new [GlobalBrightnessCommand] instance. * returns: a new [GlobalBrightnessCommand] instance.
*/ */
GlobalBrightnessCommand */*notnull*/ sp_cmd_brightness_global_clone(GlobalBrightnessCommand */*notnull*/ command); struct GlobalBrightnessCommand */*notnull*/ sp_cmd_brightness_global_clone(struct GlobalBrightnessCommand */*notnull*/ command);
void sp_cmd_brightness_global_free(BitmapCommand */*notnull*/ command); void sp_cmd_brightness_global_free(struct BitmapCommand */*notnull*/ command);
Brightness *sp_cmd_brightness_global_get(GlobalBrightnessCommand */*notnull*/ command); Brightness *sp_cmd_brightness_global_get(struct GlobalBrightnessCommand */*notnull*/ command);
Packet */*notnull*/ sp_cmd_brightness_global_into_packet(GlobalBrightnessCommand */*notnull*/ command); struct Packet */*notnull*/ sp_cmd_brightness_global_into_packet(struct GlobalBrightnessCommand */*notnull*/ command);
/** /**
* Set the brightness of all tiles to the same value. * Set the brightness of all tiles to the same value.
* *
* Returns: a new [GlobalBrightnessCommand] instance. * Returns: a new [GlobalBrightnessCommand] instance.
*/ */
GlobalBrightnessCommand */*notnull*/ sp_cmd_brightness_global_new(Brightness brightness); struct GlobalBrightnessCommand */*notnull*/ sp_cmd_brightness_global_new(Brightness brightness);
/** /**
* Moves the provided bitmap to be contained in the command. * Moves the provided bitmap to be contained in the command.
*/ */
void sp_cmd_brightness_global_set(GlobalBrightnessCommand */*notnull*/ command, void sp_cmd_brightness_global_set(struct GlobalBrightnessCommand */*notnull*/ command,
Brightness brightness); Brightness brightness);
/** /**
@ -1334,28 +1339,28 @@ void sp_cmd_brightness_global_set(GlobalBrightnessCommand */*notnull*/ command,
* *
* returns: a new [BrightnessGridCommand] instance. * returns: a new [BrightnessGridCommand] instance.
*/ */
BrightnessGridCommand */*notnull*/ sp_cmd_brightness_grid_clone(BrightnessGridCommand */*notnull*/ command); struct BrightnessGridCommand */*notnull*/ sp_cmd_brightness_grid_clone(struct BrightnessGridCommand */*notnull*/ command);
/** /**
* Deallocates a [BitmapCommand]. * Deallocates a [BitmapCommand].
*/ */
void sp_cmd_brightness_grid_free(BitmapCommand */*notnull*/ command); void sp_cmd_brightness_grid_free(struct BitmapCommand */*notnull*/ command);
/** /**
* Moves the provided [BrightnessGrid] into a new [BrightnessGridCommand], * Moves the provided [BrightnessGrid] into a new [BrightnessGridCommand],
* leaving other fields as their default values. * leaving other fields as their default values.
*/ */
BrightnessGridCommand */*notnull*/ sp_cmd_brightness_grid_from_grid(BrightnessGrid */*notnull*/ grid); struct BrightnessGridCommand */*notnull*/ sp_cmd_brightness_grid_from_grid(BrightnessGrid */*notnull*/ grid);
/** /**
* Returns a pointer to the [BrightnessGrid] contained in the [BrightnessGridCommand]. * Returns a pointer to the [BrightnessGrid] contained in the [BrightnessGridCommand].
*/ */
BrightnessGrid *sp_cmd_brightness_grid_get(BrightnessGridCommand */*notnull*/ command); BrightnessGrid *sp_cmd_brightness_grid_get(struct BrightnessGridCommand */*notnull*/ command);
/** /**
* Overwrites the origin field of the [BrightnessGridCommand]. * Overwrites the origin field of the [BrightnessGridCommand].
*/ */
void sp_cmd_brightness_grid_get_origin(BrightnessGridCommand */*notnull*/ command, void sp_cmd_brightness_grid_get_origin(struct BrightnessGridCommand */*notnull*/ command,
size_t */*notnull*/ origin_x, size_t */*notnull*/ origin_x,
size_t */*notnull*/ origin_y); size_t */*notnull*/ origin_y);
@ -1364,7 +1369,7 @@ void sp_cmd_brightness_grid_get_origin(BrightnessGridCommand */*notnull*/ comman
* *
* Returns: NULL or a [Packet] containing the command. * Returns: NULL or a [Packet] containing the command.
*/ */
Packet *sp_cmd_brightness_grid_into_packet(BrightnessGridCommand */*notnull*/ command); struct Packet *sp_cmd_brightness_grid_into_packet(struct BrightnessGridCommand */*notnull*/ command);
/** /**
* Set the brightness of individual tiles in a rectangular area of the display. * Set the brightness of individual tiles in a rectangular area of the display.
@ -1373,20 +1378,20 @@ Packet *sp_cmd_brightness_grid_into_packet(BrightnessGridCommand */*notnull*/ co
* *
* Returns: a new [BrightnessGridCommand] instance. * Returns: a new [BrightnessGridCommand] instance.
*/ */
BrightnessGridCommand */*notnull*/ sp_cmd_brightness_grid_new(BrightnessGrid */*notnull*/ grid, struct BrightnessGridCommand */*notnull*/ sp_cmd_brightness_grid_new(BrightnessGrid */*notnull*/ grid,
size_t origin_x, size_t origin_x,
size_t origin_y); size_t origin_y);
/** /**
* Moves the provided [BrightnessGrid] to be contained in the [BrightnessGridCommand]. * Moves the provided [BrightnessGrid] to be contained in the [BrightnessGridCommand].
*/ */
void sp_cmd_brightness_grid_set(BrightnessGridCommand */*notnull*/ command, void sp_cmd_brightness_grid_set(struct BrightnessGridCommand */*notnull*/ command,
BrightnessGrid */*notnull*/ grid); BrightnessGrid */*notnull*/ grid);
/** /**
* Reads the origin field of the [BrightnessGridCommand]. * Reads the origin field of the [BrightnessGridCommand].
*/ */
void sp_cmd_brightness_grid_set_origin(BrightnessGridCommand */*notnull*/ command, void sp_cmd_brightness_grid_set_origin(struct BrightnessGridCommand */*notnull*/ command,
size_t origin_x, size_t origin_x,
size_t origin_y); size_t origin_y);
@ -1395,28 +1400,28 @@ void sp_cmd_brightness_grid_set_origin(BrightnessGridCommand */*notnull*/ comman
* *
* returns: a new [CharGridCommand] instance. * returns: a new [CharGridCommand] instance.
*/ */
CharGridCommand */*notnull*/ sp_cmd_char_grid_clone(CharGridCommand */*notnull*/ command); struct CharGridCommand */*notnull*/ sp_cmd_char_grid_clone(struct CharGridCommand */*notnull*/ command);
/** /**
* Deallocates a [BitmapCommand]. * Deallocates a [BitmapCommand].
*/ */
void sp_cmd_char_grid_free(BitmapCommand */*notnull*/ command); void sp_cmd_char_grid_free(struct BitmapCommand */*notnull*/ command);
/** /**
* Moves the provided [CharGrid] into a new [CharGridCommand], * Moves the provided [CharGrid] into a new [CharGridCommand],
* leaving other fields as their default values. * leaving other fields as their default values.
*/ */
CharGridCommand */*notnull*/ sp_cmd_char_grid_from_grid(CharGrid */*notnull*/ grid); struct CharGridCommand */*notnull*/ sp_cmd_char_grid_from_grid(CharGrid */*notnull*/ grid);
/** /**
* Returns a pointer to the [CharGrid] contained in the [CharGridCommand]. * Returns a pointer to the [CharGrid] contained in the [CharGridCommand].
*/ */
CharGrid *sp_cmd_char_grid_get(CharGridCommand */*notnull*/ command); CharGrid *sp_cmd_char_grid_get(struct CharGridCommand */*notnull*/ command);
/** /**
* Reads the origin field of the [CharGridCommand]. * Reads the origin field of the [CharGridCommand].
*/ */
void sp_cmd_char_grid_get_origin(CharGridCommand */*notnull*/ command, void sp_cmd_char_grid_get_origin(struct CharGridCommand */*notnull*/ command,
size_t */*notnull*/ origin_x, size_t */*notnull*/ origin_x,
size_t */*notnull*/ origin_y); size_t */*notnull*/ origin_y);
@ -1427,20 +1432,20 @@ void sp_cmd_char_grid_get_origin(CharGridCommand */*notnull*/ command,
* *
* Returns: a new [CharGridCommand] instance. * Returns: a new [CharGridCommand] instance.
*/ */
CharGridCommand */*notnull*/ sp_cmd_char_grid_new(CharGrid */*notnull*/ grid, struct CharGridCommand */*notnull*/ sp_cmd_char_grid_new(CharGrid */*notnull*/ grid,
size_t origin_x, size_t origin_x,
size_t origin_y); size_t origin_y);
/** /**
* Moves the provided [CharGrid] to be contained in the [CharGridCommand]. * Moves the provided [CharGrid] to be contained in the [CharGridCommand].
*/ */
void sp_cmd_char_grid_set(CharGridCommand */*notnull*/ command, void sp_cmd_char_grid_set(struct CharGridCommand */*notnull*/ command,
CharGrid */*notnull*/ grid); CharGrid */*notnull*/ grid);
/** /**
* Overwrites the origin field of the [CharGridCommand]. * Overwrites the origin field of the [CharGridCommand].
*/ */
void sp_cmd_char_grid_set_origin(CharGridCommand */*notnull*/ command, void sp_cmd_char_grid_set_origin(struct CharGridCommand */*notnull*/ command,
size_t origin_x, size_t origin_x,
size_t origin_y); size_t origin_y);
@ -1449,12 +1454,12 @@ void sp_cmd_char_grid_set_origin(CharGridCommand */*notnull*/ command,
* *
* Returns: NULL or a [Packet] containing the command. * Returns: NULL or a [Packet] containing the command.
*/ */
Packet *sp_cmd_char_grid_try_into_packet(CharGridCommand */*notnull*/ command); struct Packet *sp_cmd_char_grid_try_into_packet(struct CharGridCommand */*notnull*/ command);
/** /**
* Deallocates a [ClearCommand]. * Deallocates a [ClearCommand].
*/ */
void sp_cmd_clear_free(ClearCommand */*notnull*/ command); void sp_cmd_clear_free(struct ClearCommand */*notnull*/ command);
/** /**
* Set all pixels to the off state. * Set all pixels to the off state.
@ -1463,25 +1468,25 @@ void sp_cmd_clear_free(ClearCommand */*notnull*/ command);
* *
* Returns: a new [ClearCommand] instance. * Returns: a new [ClearCommand] instance.
*/ */
ClearCommand */*notnull*/ sp_cmd_clear_new(void); struct ClearCommand */*notnull*/ sp_cmd_clear_new(void);
/** /**
* Clones an [Cp437GridCommand] instance. * Clones an [Cp437GridCommand] instance.
* *
* returns: a new [Cp437GridCommand] instance. * returns: a new [Cp437GridCommand] instance.
*/ */
Cp437GridCommand */*notnull*/ sp_cmd_cp437_grid_clone(Cp437GridCommand */*notnull*/ command); struct Cp437GridCommand */*notnull*/ sp_cmd_cp437_grid_clone(struct Cp437GridCommand */*notnull*/ command);
/** /**
* Deallocates a [Cp437GridCommand]. * Deallocates a [Cp437GridCommand].
*/ */
void sp_cmd_cp437_grid_free(BitmapCommand */*notnull*/ command); void sp_cmd_cp437_grid_free(struct BitmapCommand */*notnull*/ command);
/** /**
* Moves the provided [Cp437Grid] into a new [Cp437GridCommand], * Moves the provided [Cp437Grid] into a new [Cp437GridCommand],
* leaving other fields as their default values. * leaving other fields as their default values.
*/ */
Cp437GridCommand */*notnull*/ sp_cmd_cp437_grid_from_grid(Cp437Grid */*notnull*/ grid); struct Cp437GridCommand */*notnull*/ sp_cmd_cp437_grid_from_grid(Cp437Grid */*notnull*/ grid);
/** /**
* Show text on the screen. * Show text on the screen.
@ -1491,14 +1496,14 @@ Cp437GridCommand */*notnull*/ sp_cmd_cp437_grid_from_grid(Cp437Grid */*notnull*/
* *
* [CP-437]: https://en.wikipedia.org/wiki/Code_page_437 * [CP-437]: https://en.wikipedia.org/wiki/Code_page_437
*/ */
Cp437Grid *sp_cmd_cp437_grid_get(Cp437GridCommand */*notnull*/ command); Cp437Grid *sp_cmd_cp437_grid_get(struct Cp437GridCommand */*notnull*/ command);
/** /**
* Gets the origin field of the [Cp437GridCommand]. * Gets the origin field of the [Cp437GridCommand].
* *
* Rust equivalent: `cp437_command.origin` * Rust equivalent: `cp437_command.origin`
*/ */
void sp_cmd_cp437_grid_get_origin(Cp437GridCommand */*notnull*/ command, void sp_cmd_cp437_grid_get_origin(struct Cp437GridCommand */*notnull*/ command,
size_t */*notnull*/ origin_x, size_t */*notnull*/ origin_x,
size_t */*notnull*/ origin_y); size_t */*notnull*/ origin_y);
@ -1509,7 +1514,7 @@ void sp_cmd_cp437_grid_get_origin(Cp437GridCommand */*notnull*/ command,
* *
* The origin is relative to the top-left of the display. * The origin is relative to the top-left of the display.
*/ */
Cp437GridCommand */*notnull*/ sp_cmd_cp437_grid_new(Cp437Grid */*notnull*/ grid, struct Cp437GridCommand */*notnull*/ sp_cmd_cp437_grid_new(Cp437Grid */*notnull*/ grid,
size_t origin_x, size_t origin_x,
size_t origin_y); size_t origin_y);
@ -1518,7 +1523,7 @@ Cp437GridCommand */*notnull*/ sp_cmd_cp437_grid_new(Cp437Grid */*notnull*/ grid,
* *
* This drops the previously contained [Cp437Grid]. * This drops the previously contained [Cp437Grid].
*/ */
void sp_cmd_cp437_grid_set(Cp437GridCommand */*notnull*/ command, void sp_cmd_cp437_grid_set(struct Cp437GridCommand */*notnull*/ command,
Cp437Grid */*notnull*/ grid); Cp437Grid */*notnull*/ grid);
/** /**
@ -1526,7 +1531,7 @@ void sp_cmd_cp437_grid_set(Cp437GridCommand */*notnull*/ command,
* *
* Rust equivalent: `cp437_command.origin = Origin::new(origin_x, origin_y)` * Rust equivalent: `cp437_command.origin = Origin::new(origin_x, origin_y)`
*/ */
void sp_cmd_cp437_grid_set_origin(Cp437GridCommand */*notnull*/ command, void sp_cmd_cp437_grid_set_origin(struct Cp437GridCommand */*notnull*/ command,
size_t origin_x, size_t origin_x,
size_t origin_y); size_t origin_y);
@ -1535,26 +1540,26 @@ void sp_cmd_cp437_grid_set_origin(Cp437GridCommand */*notnull*/ command,
* *
* Returns: NULL or a [Packet] containing the command. * Returns: NULL or a [Packet] containing the command.
*/ */
Packet *sp_cmd_cp437_grid_try_into_packet(Cp437GridCommand */*notnull*/ command); struct Packet *sp_cmd_cp437_grid_try_into_packet(struct Cp437GridCommand */*notnull*/ command);
/** /**
* Deallocates a [FadeOutCommand]. * Deallocates a [FadeOutCommand].
*/ */
void sp_cmd_fade_out_free(ClearCommand */*notnull*/ command); void sp_cmd_fade_out_free(struct ClearCommand */*notnull*/ command);
/** /**
* A yet-to-be-tested command. * A yet-to-be-tested command.
* *
* Returns: a new [FadeOutCommand] instance. * Returns: a new [FadeOutCommand] instance.
*/ */
FadeOutCommand */*notnull*/ sp_cmd_fade_out_new(void); struct FadeOutCommand */*notnull*/ sp_cmd_fade_out_new(void);
/** /**
* Clones an [SPCommand] instance. * Clones an [SPCommand] instance.
* *
* returns: a new [SPCommand] instance. * returns: a new [SPCommand] instance.
*/ */
Command sp_cmd_generic_clone(Command command); struct Command sp_cmd_generic_clone(struct Command command);
/** /**
* Deallocates an [SPCommand]. * Deallocates an [SPCommand].
@ -1566,7 +1571,7 @@ Command sp_cmd_generic_clone(Command command);
* sp_command_free(c); * sp_command_free(c);
* ``` * ```
*/ */
void sp_cmd_generic_free(Command command); void sp_cmd_generic_free(struct Command command);
/** /**
* Tries to turn a [SPCommand] into a [Packet]. * Tries to turn a [SPCommand] into a [Packet].
@ -1574,7 +1579,7 @@ void sp_cmd_generic_free(Command command);
* *
* Returns tag [CommandTag::Invalid] in case of an error. * Returns tag [CommandTag::Invalid] in case of an error.
*/ */
Packet *sp_cmd_generic_into_packet(Command command); struct Packet *sp_cmd_generic_into_packet(struct Command command);
/** /**
* Tries to turn a [Packet] into a [SPCommand]. * Tries to turn a [Packet] into a [SPCommand].
@ -1583,12 +1588,12 @@ Packet *sp_cmd_generic_into_packet(Command command);
* *
* Returns: pointer to new [SPCommand] instance or NULL if parsing failed. * Returns: pointer to new [SPCommand] instance or NULL if parsing failed.
*/ */
Command *sp_cmd_generic_try_from_packet(Packet */*notnull*/ packet); struct Command *sp_cmd_generic_try_from_packet(struct Packet */*notnull*/ packet);
/** /**
* Deallocates a [HardResetCommand]. * Deallocates a [HardResetCommand].
*/ */
void sp_cmd_hard_reset_free(ClearCommand */*notnull*/ command); void sp_cmd_hard_reset_free(struct ClearCommand */*notnull*/ command);
/** /**
* Kills the udp daemon on the display, which usually results in a restart. * Kills the udp daemon on the display, which usually results in a restart.
@ -1597,7 +1602,7 @@ void sp_cmd_hard_reset_free(ClearCommand */*notnull*/ command);
* *
* Returns: a new [HardResetCommand] instance. * Returns: a new [HardResetCommand] instance.
*/ */
HardResetCommand */*notnull*/ sp_cmd_hard_reset_new(void); struct HardResetCommand */*notnull*/ sp_cmd_hard_reset_new(void);
/** /**
* Clones a [Cp437Grid]. * Clones a [Cp437Grid].
@ -1651,14 +1656,16 @@ size_t sp_cp437_grid_height(Cp437Grid */*notnull*/ cp437_grid);
* *
* Returns NULL in case of an error. * Returns NULL in case of an error.
*/ */
Packet *sp_cp437_grid_into_packet(Cp437Grid */*notnull*/ grid, struct Packet *sp_cp437_grid_into_packet(Cp437Grid */*notnull*/ grid,
size_t x, size_t x,
size_t y); size_t y);
/** /**
* Loads a [Cp437Grid] with the specified dimensions from the provided data. * Loads a [Cp437Grid] with the specified dimensions from the provided data.
*/ */
Cp437Grid *sp_cp437_grid_load(size_t width, size_t height, ByteSlice data); Cp437Grid *sp_cp437_grid_load(size_t width,
size_t height,
struct ByteSlice data);
/** /**
* Creates a new [Cp437Grid] with the specified dimensions. * Creates a new [Cp437Grid] with the specified dimensions.
@ -1692,7 +1699,7 @@ void sp_cp437_grid_set(Cp437Grid */*notnull*/ cp437_grid,
* *
* The returned memory is valid for the lifetime of the grid. * The returned memory is valid for the lifetime of the grid.
*/ */
ByteSlice sp_cp437_grid_unsafe_data_ref(Cp437Grid */*notnull*/ cp437_grid); struct ByteSlice sp_cp437_grid_unsafe_data_ref(Cp437Grid */*notnull*/ cp437_grid);
/** /**
* Gets the width of the [Cp437Grid] instance. * Gets the width of the [Cp437Grid] instance.
@ -1708,26 +1715,27 @@ size_t sp_cp437_grid_width(Cp437Grid */*notnull*/ cp437_grid);
* *
* returns: a new [Packet] instance. * returns: a new [Packet] instance.
*/ */
Packet */*notnull*/ sp_packet_clone(Packet */*notnull*/ packet); struct Packet */*notnull*/ sp_packet_clone(struct Packet */*notnull*/ packet);
/** /**
* Deallocates a [Packet]. * Deallocates a [Packet].
*/ */
void sp_packet_free(Packet */*notnull*/ packet); void sp_packet_free(struct Packet */*notnull*/ packet);
/** /**
* Creates a raw [Packet] from parts. * Creates a raw [Packet] from parts.
* *
* returns: new instance. Will never return null. * returns: new instance. Will never return null.
*/ */
Packet */*notnull*/ sp_packet_from_parts(Header header, ByteSlice payload); struct Packet */*notnull*/ sp_packet_from_parts(struct Header header,
struct ByteSlice payload);
/** /**
* Returns a pointer to the header field of the provided packet. * Returns a pointer to the header field of the provided packet.
* *
* The returned header can be changed and will be valid for the lifetime of the packet. * The returned header can be changed and will be valid for the lifetime of the packet.
*/ */
Header */*notnull*/ sp_packet_get_header(Packet */*notnull*/ packet); struct Header */*notnull*/ sp_packet_get_header(struct Packet */*notnull*/ packet);
/** /**
* Returns a pointer to the current payload of the provided packet. * Returns a pointer to the current payload of the provided packet.
@ -1736,7 +1744,7 @@ Header */*notnull*/ sp_packet_get_header(Packet */*notnull*/ packet);
* *
* The returned memory can be changed and will be valid until a new payload is set. * The returned memory can be changed and will be valid until a new payload is set.
*/ */
ByteSlice sp_packet_get_payload(Packet */*notnull*/ packet); struct ByteSlice sp_packet_get_payload(struct Packet */*notnull*/ packet);
/** /**
* Serialize the packet into the provided buffer. * Serialize the packet into the provided buffer.
@ -1745,21 +1753,23 @@ ByteSlice sp_packet_get_payload(Packet */*notnull*/ packet);
* *
* - if the buffer is not big enough to hold header+payload. * - if the buffer is not big enough to hold header+payload.
*/ */
void sp_packet_serialize_to(Packet */*notnull*/ packet, ByteSlice buffer); void sp_packet_serialize_to(struct Packet */*notnull*/ packet,
struct ByteSlice buffer);
/** /**
* Sets the payload of the provided packet to the provided data. * Sets the payload of the provided packet to the provided data.
* *
* This makes previous payload pointers invalid. * This makes previous payload pointers invalid.
*/ */
void sp_packet_set_payload(Packet */*notnull*/ packet, ByteSlice data); void sp_packet_set_payload(struct Packet */*notnull*/ packet,
struct ByteSlice data);
/** /**
* Tries to load a [Packet] from the passed array with the specified length. * Tries to load a [Packet] from the passed array with the specified length.
* *
* returns: NULL in case of an error, pointer to the allocated packet otherwise * returns: NULL in case of an error, pointer to the allocated packet otherwise
*/ */
Packet *sp_packet_try_load(ByteSlice data); struct Packet *sp_packet_try_load(struct ByteSlice data);
/** /**
* Converts u16 into [CommandCode]. * Converts u16 into [CommandCode].
@ -1772,7 +1782,7 @@ bool sp_u16_to_command_code(uint16_t code,
/** /**
* Closes and deallocates a [UdpSocket]. * Closes and deallocates a [UdpSocket].
*/ */
void sp_udp_free(UdpSocket */*notnull*/ connection); void sp_udp_free(struct UdpSocket */*notnull*/ connection);
/** /**
* Creates a new instance of [UdpSocket]. * Creates a new instance of [UdpSocket].
@ -1787,7 +1797,7 @@ void sp_udp_free(UdpSocket */*notnull*/ connection);
* sp_udp_send_command(connection, sp_command_clear()); * sp_udp_send_command(connection, sp_command_clear());
* ``` * ```
*/ */
UdpSocket *sp_udp_open(char */*notnull*/ host); struct UdpSocket *sp_udp_open(char */*notnull*/ host);
/** /**
* Creates a new instance of [UdpSocket]. * Creates a new instance of [UdpSocket].
@ -1802,7 +1812,7 @@ UdpSocket *sp_udp_open(char */*notnull*/ host);
* sp_udp_send_command(connection, sp_command_clear()); * sp_udp_send_command(connection, sp_command_clear());
* ``` * ```
*/ */
UdpSocket *sp_udp_open_ipv4(uint8_t ip1, struct UdpSocket *sp_udp_open_ipv4(uint8_t ip1,
uint8_t ip2, uint8_t ip2,
uint8_t ip3, uint8_t ip3,
uint8_t ip4, uint8_t ip4,
@ -1821,7 +1831,8 @@ UdpSocket *sp_udp_open_ipv4(uint8_t ip1,
* sp_udp_send_command(connection, sp_command_brightness(5)); * sp_udp_send_command(connection, sp_command_brightness(5));
* ``` * ```
*/ */
bool sp_udp_send_command(UdpSocket */*notnull*/ connection, Command command); bool sp_udp_send_command(struct UdpSocket */*notnull*/ connection,
struct Command command);
/** /**
* Sends a [Header] to the display using the [UdpSocket]. * Sends a [Header] to the display using the [UdpSocket].
@ -1834,7 +1845,8 @@ bool sp_udp_send_command(UdpSocket */*notnull*/ connection, Command command);
* sp_udp_send_header(connection, sp_command_brightness(5)); * sp_udp_send_header(connection, sp_command_brightness(5));
* ``` * ```
*/ */
bool sp_udp_send_header(UdpSocket */*notnull*/ udp_connection, Header header); bool sp_udp_send_header(struct UdpSocket */*notnull*/ udp_connection,
struct Header header);
/** /**
* Sends a [Packet] to the display using the [UdpSocket]. * Sends a [Packet] to the display using the [UdpSocket].
@ -1843,8 +1855,8 @@ bool sp_udp_send_header(UdpSocket */*notnull*/ udp_connection, Header header);
* *
* returns: true in case of success * returns: true in case of success
*/ */
bool sp_udp_send_packet(UdpSocket */*notnull*/ connection, bool sp_udp_send_packet(struct UdpSocket */*notnull*/ connection,
Packet */*notnull*/ packet); struct Packet */*notnull*/ packet);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"

View file

@ -43,3 +43,11 @@ pub struct UdpSocket;
/// This is a type only used by cbindgen to have a type for pointers. /// This is a type only used by cbindgen to have a type for pointers.
pub struct DisplayBitVec; pub struct DisplayBitVec;
#[cfg(feature = "env_logger")]
pub mod feature_env_logger {
#[no_mangle]
pub unsafe extern "C" fn init_env_logger() {
env_logger::init();
}
}