change typedef style, add optional logging
This commit is contained in:
parent
0c6efcee56
commit
389ced492c
102
Cargo.lock
generated
102
Cargo.lock
generated
|
@ -8,6 +8,15 @@ version = "2.0.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
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]]
|
||||
name = "anstream"
|
||||
version = "0.6.18"
|
||||
|
@ -173,6 +182,29 @@ dependencies = [
|
|||
"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]]
|
||||
name = "equivalent"
|
||||
version = "1.0.2"
|
||||
|
@ -257,6 +289,30 @@ version = "1.0.15"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
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]]
|
||||
name = "jobserver"
|
||||
version = "0.1.33"
|
||||
|
@ -312,6 +368,21 @@ version = "0.3.32"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
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]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.95"
|
||||
|
@ -342,6 +413,35 @@ version = "0.7.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
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]]
|
||||
name = "rust-lzma"
|
||||
version = "0.6.0"
|
||||
|
@ -415,7 +515,6 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "servicepoint"
|
||||
version = "0.14.1"
|
||||
source = "git+https://git.berlin.ccc.de/servicepoint/servicepoint.git?branch=next#d979d46d3e770222c5a7ca549e601b45eff48299"
|
||||
dependencies = [
|
||||
"bitvec",
|
||||
"bzip2",
|
||||
|
@ -432,6 +531,7 @@ name = "servicepoint_binding_c"
|
|||
version = "0.14.1"
|
||||
dependencies = [
|
||||
"cbindgen",
|
||||
"env_logger",
|
||||
"servicepoint",
|
||||
]
|
||||
|
||||
|
|
11
Cargo.toml
11
Cargo.toml
|
@ -18,14 +18,17 @@ crate-type = ["staticlib", "cdylib", "rlib"]
|
|||
cbindgen = "0.28.0"
|
||||
|
||||
[dependencies.servicepoint]
|
||||
# version = "0.14.1"
|
||||
version = "0.14.1"
|
||||
default-features = false
|
||||
git = "https://git.berlin.ccc.de/servicepoint/servicepoint.git"
|
||||
branch = "next"
|
||||
|
||||
[dependencies.env_logger]
|
||||
version = "0.11.8"
|
||||
optional = true
|
||||
|
||||
[features]
|
||||
all_compressions = ["servicepoint/all_compressions"]
|
||||
default = ["all_compressions", "servicepoint/default"]
|
||||
default = ["all_compressions", "servicepoint/default", "env_logger"]
|
||||
env_logger = ["dep:env_logger"]
|
||||
|
||||
[lints.rust]
|
||||
missing-docs = "warn"
|
||||
|
|
|
@ -16,7 +16,7 @@ line_endings = "LF"
|
|||
|
||||
############################# Codegen Options ##################################
|
||||
|
||||
style = "type"
|
||||
style = "both"
|
||||
usize_is_size_t = true
|
||||
|
||||
# this is needed because otherwise the order in the C bindings is different on different machines
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
CARGO ?= cargo
|
||||
STRIP ?= strip
|
||||
|
||||
FEATURES := ""
|
||||
FEATURES := "env_logger"
|
||||
|
||||
THIS_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||
REPO_ROOT := $(realpath $(THIS_DIR)/..)
|
||||
|
@ -99,7 +99,7 @@ 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
|
||||
$(CC) $< \
|
||||
-I $(SERVICEPOINT_HEADER_OUT) \
|
||||
|
|
|
@ -457,7 +457,7 @@ typedef struct ValueGrid_u8 ValueGrid_u8;
|
|||
* ByteSlice empty = {.start: NULL, .length = 0};
|
||||
* ```
|
||||
*/
|
||||
typedef struct {
|
||||
typedef struct ByteSlice {
|
||||
/**
|
||||
* The start address of the memory.
|
||||
*/
|
||||
|
@ -486,7 +486,7 @@ typedef struct {
|
|||
* }).unwrap()
|
||||
* ```
|
||||
*/
|
||||
typedef ValueGrid_Brightness BrightnessGrid;
|
||||
typedef struct ValueGrid_Brightness BrightnessGrid;
|
||||
|
||||
/**
|
||||
* A display brightness value, checked for correct value range
|
||||
|
@ -532,7 +532,7 @@ typedef uint8_t Brightness;
|
|||
* 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
|
||||
|
@ -544,23 +544,23 @@ typedef size_t Offset;
|
|||
*
|
||||
* The encoding is currently not enforced.
|
||||
*/
|
||||
typedef ValueGrid_u8 Cp437Grid;
|
||||
typedef struct ValueGrid_u8 Cp437Grid;
|
||||
|
||||
/**
|
||||
* Pointer to one of the available command structs.
|
||||
*/
|
||||
typedef union {
|
||||
typedef union CommandUnion {
|
||||
uint8_t *null;
|
||||
BitmapCommand */*notnull*/ bitmap;
|
||||
BitVecCommand */*notnull*/ bitvec;
|
||||
BrightnessGridCommand */*notnull*/ brightness_grid;
|
||||
CharGridCommand */*notnull*/ char_grid;
|
||||
Cp437GridCommand */*notnull*/ cp437_grid;
|
||||
GlobalBrightnessCommand */*notnull*/ global_brightness;
|
||||
ClearCommand */*notnull*/ clear;
|
||||
BitmapLegacyCommand */*notnull*/ bitmap_legacy;
|
||||
HardResetCommand */*notnull*/ hard_reset;
|
||||
FadeOutCommand */*notnull*/ fade_out;
|
||||
struct BitmapCommand */*notnull*/ bitmap;
|
||||
struct BitVecCommand */*notnull*/ bitvec;
|
||||
struct BrightnessGridCommand */*notnull*/ brightness_grid;
|
||||
struct CharGridCommand */*notnull*/ char_grid;
|
||||
struct Cp437GridCommand */*notnull*/ cp437_grid;
|
||||
struct GlobalBrightnessCommand */*notnull*/ global_brightness;
|
||||
struct ClearCommand */*notnull*/ clear;
|
||||
struct BitmapLegacyCommand */*notnull*/ bitmap_legacy;
|
||||
struct HardResetCommand */*notnull*/ hard_reset;
|
||||
struct FadeOutCommand */*notnull*/ fade_out;
|
||||
} CommandUnion;
|
||||
|
||||
/**
|
||||
|
@ -570,7 +570,7 @@ typedef union {
|
|||
*
|
||||
* Rust equivalent: [TypedCommand].
|
||||
*/
|
||||
typedef struct {
|
||||
typedef struct Command {
|
||||
/**
|
||||
* Specifies which kind of command struct is contained in `data`
|
||||
*/
|
||||
|
@ -578,7 +578,7 @@ typedef struct {
|
|||
/**
|
||||
* The pointer to the command struct
|
||||
*/
|
||||
CommandUnion data;
|
||||
union CommandUnion data;
|
||||
} Command;
|
||||
|
||||
/**
|
||||
|
@ -591,7 +591,7 @@ typedef struct {
|
|||
*
|
||||
* 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.
|
||||
*/
|
||||
|
@ -627,10 +627,12 @@ typedef struct {
|
|||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
void init_env_logger(void);
|
||||
|
||||
/**
|
||||
* 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].
|
||||
|
@ -640,12 +642,12 @@ Bitmap */*notnull*/ sp_bitmap_clone(Bitmap */*notnull*/ bitmap);
|
|||
* - `bitmap`: instance to write 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].
|
||||
*/
|
||||
void sp_bitmap_free(Bitmap */*notnull*/ bitmap);
|
||||
void sp_bitmap_free(struct Bitmap */*notnull*/ 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.
|
||||
*/
|
||||
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].
|
||||
|
@ -668,7 +670,7 @@ Bitmap *sp_bitmap_from_bitvec(size_t width, BitVec */*notnull*/ bitvec);
|
|||
*
|
||||
* - 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.
|
||||
|
@ -677,12 +679,12 @@ bool sp_bitmap_get(Bitmap */*notnull*/ bitmap, size_t x, size_t y);
|
|||
*
|
||||
* - `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
|
||||
*/
|
||||
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].
|
||||
|
@ -691,10 +693,10 @@ BitVec */*notnull*/ sp_bitmap_into_bitvec(Bitmap */*notnull*/ bitmap);
|
|||
*
|
||||
* Returns NULL in case of an error.
|
||||
*/
|
||||
Packet *sp_bitmap_into_packet(Bitmap */*notnull*/ bitmap,
|
||||
size_t x,
|
||||
size_t y,
|
||||
CompressionCode compression);
|
||||
struct Packet *sp_bitmap_into_packet(struct Bitmap */*notnull*/ bitmap,
|
||||
size_t x,
|
||||
size_t y,
|
||||
CompressionCode compression);
|
||||
|
||||
/**
|
||||
* Loads a [Bitmap] with the specified dimensions from the provided data.
|
||||
|
@ -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.
|
||||
*/
|
||||
Bitmap *sp_bitmap_load(size_t width,
|
||||
size_t height,
|
||||
ByteSlice data);
|
||||
struct Bitmap *sp_bitmap_load(size_t width,
|
||||
size_t height,
|
||||
struct ByteSlice data);
|
||||
|
||||
/**
|
||||
* Creates a new [Bitmap] with the specified dimensions.
|
||||
|
@ -735,14 +737,14 @@ Bitmap *sp_bitmap_load(size_t width,
|
|||
* 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.
|
||||
*
|
||||
* 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].
|
||||
|
@ -757,14 +759,17 @@ Bitmap */*notnull*/ sp_bitmap_new_max_sized(void);
|
|||
*
|
||||
* - 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.
|
||||
*
|
||||
* 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.
|
||||
|
@ -783,7 +788,7 @@ ByteSlice sp_bitmap_unsafe_data_ref(Bitmap */*notnull*/ 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].
|
||||
|
@ -828,10 +833,10 @@ bool sp_bitvec_get(BitVec */*notnull*/ bit_vec, size_t index);
|
|||
*
|
||||
* Returns NULL in case of an error.
|
||||
*/
|
||||
Packet *sp_bitvec_into_packet(BitVec */*notnull*/ bitvec,
|
||||
size_t offset,
|
||||
BinaryOperation operation,
|
||||
CompressionCode compression);
|
||||
struct Packet *sp_bitvec_into_packet(BitVec */*notnull*/ bitvec,
|
||||
size_t offset,
|
||||
BinaryOperation operation,
|
||||
CompressionCode compression);
|
||||
|
||||
/**
|
||||
* Returns true if length is 0.
|
||||
|
@ -856,7 +861,7 @@ size_t sp_bitvec_len(BitVec */*notnull*/ bit_vec);
|
|||
*
|
||||
* 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.
|
||||
|
@ -897,7 +902,7 @@ void sp_bitvec_set(BitVec */*notnull*/ bit_vec, size_t index, bool value);
|
|||
*
|
||||
* - `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].
|
||||
|
@ -955,9 +960,9 @@ size_t sp_brightness_grid_height(BrightnessGrid */*notnull*/ brightness_grid);
|
|||
*
|
||||
* Returns NULL in case of an error.
|
||||
*/
|
||||
Packet *sp_brightness_grid_into_packet(BrightnessGrid */*notnull*/ grid,
|
||||
size_t x,
|
||||
size_t y);
|
||||
struct Packet *sp_brightness_grid_into_packet(BrightnessGrid */*notnull*/ grid,
|
||||
size_t x,
|
||||
size_t y);
|
||||
|
||||
/**
|
||||
* Loads a [BrightnessGrid] with the specified dimensions from the provided data.
|
||||
|
@ -968,7 +973,7 @@ Packet *sp_brightness_grid_into_packet(BrightnessGrid */*notnull*/ grid,
|
|||
*/
|
||||
BrightnessGrid *sp_brightness_grid_load(size_t width,
|
||||
size_t height,
|
||||
ByteSlice data);
|
||||
struct ByteSlice data);
|
||||
|
||||
/**
|
||||
* 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`.
|
||||
*/
|
||||
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.
|
||||
|
@ -1085,16 +1090,16 @@ size_t sp_char_grid_height(CharGrid */*notnull*/ char_grid);
|
|||
*
|
||||
* Returns NULL in case of an error.
|
||||
*/
|
||||
Packet *sp_char_grid_into_packet(CharGrid */*notnull*/ grid,
|
||||
size_t x,
|
||||
size_t y);
|
||||
struct Packet *sp_char_grid_into_packet(CharGrid */*notnull*/ grid,
|
||||
size_t x,
|
||||
size_t y);
|
||||
|
||||
/**
|
||||
* Loads a [CharGrid] with the specified dimensions from the provided data.
|
||||
*
|
||||
* 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.
|
||||
|
@ -1146,12 +1151,12 @@ size_t sp_char_grid_width(CharGrid */*notnull*/ char_grid);
|
|||
*
|
||||
* 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.
|
||||
*/
|
||||
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],
|
||||
|
@ -1159,7 +1164,7 @@ void sp_cmd_bitmap_free(BitmapCommand */*notnull*/ command);
|
|||
*
|
||||
* 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`.
|
||||
|
@ -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 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].
|
||||
*/
|
||||
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].
|
||||
*/
|
||||
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_y);
|
||||
|
||||
|
@ -1190,27 +1195,27 @@ void sp_cmd_bitmap_get_origin(BitmapCommand */*notnull*/ command,
|
|||
*
|
||||
* Returns: a new [BitmapCommand] instance.
|
||||
*/
|
||||
BitmapCommand */*notnull*/ sp_cmd_bitmap_new(Bitmap */*notnull*/ bitmap,
|
||||
size_t origin_x,
|
||||
size_t origin_y,
|
||||
CompressionCode compression);
|
||||
struct BitmapCommand */*notnull*/ sp_cmd_bitmap_new(struct Bitmap */*notnull*/ bitmap,
|
||||
size_t origin_x,
|
||||
size_t origin_y,
|
||||
CompressionCode compression);
|
||||
|
||||
/**
|
||||
* Moves the provided [Bitmap] to be contained in the [BitmapCommand].
|
||||
*/
|
||||
void sp_cmd_bitmap_set(BitmapCommand */*notnull*/ command,
|
||||
Bitmap */*notnull*/ bitmap);
|
||||
void sp_cmd_bitmap_set(struct BitmapCommand */*notnull*/ command,
|
||||
struct Bitmap */*notnull*/ bitmap);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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_y);
|
||||
|
||||
|
@ -1219,39 +1224,39 @@ void sp_cmd_bitmap_set_origin(BitmapCommand */*notnull*/ 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.
|
||||
*
|
||||
* 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].
|
||||
*/
|
||||
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].
|
||||
*/
|
||||
BitVec *sp_cmd_bitvec_get(BitVecCommand */*notnull*/ command);
|
||||
BitVec *sp_cmd_bitvec_get(struct BitVecCommand */*notnull*/ command);
|
||||
|
||||
/**
|
||||
* 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].
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
|
@ -1267,33 +1272,33 @@ BinaryOperation sp_cmd_bitvec_get_operation(BitVecCommand */*notnull*/ command);
|
|||
*
|
||||
* The contained [`DisplayBitVec`] is always uncompressed.
|
||||
*/
|
||||
BitVecCommand */*notnull*/ sp_cmd_bitvec_new(BitVec */*notnull*/ bitvec,
|
||||
size_t offset,
|
||||
BinaryOperation operation,
|
||||
CompressionCode compression);
|
||||
struct BitVecCommand */*notnull*/ sp_cmd_bitvec_new(BitVec */*notnull*/ bitvec,
|
||||
size_t offset,
|
||||
BinaryOperation operation,
|
||||
CompressionCode compression);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
|
@ -1301,32 +1306,32 @@ void sp_cmd_bitvec_set_operation(BitVecCommand */*notnull*/ 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
void sp_cmd_brightness_global_set(GlobalBrightnessCommand */*notnull*/ command,
|
||||
void sp_cmd_brightness_global_set(struct GlobalBrightnessCommand */*notnull*/ command,
|
||||
Brightness brightness);
|
||||
|
||||
/**
|
||||
|
@ -1334,28 +1339,28 @@ void sp_cmd_brightness_global_set(GlobalBrightnessCommand */*notnull*/ command,
|
|||
*
|
||||
* 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].
|
||||
*/
|
||||
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],
|
||||
* 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].
|
||||
*/
|
||||
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].
|
||||
*/
|
||||
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_y);
|
||||
|
||||
|
@ -1364,7 +1369,7 @@ void sp_cmd_brightness_grid_get_origin(BrightnessGridCommand */*notnull*/ comman
|
|||
*
|
||||
* 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.
|
||||
|
@ -1373,20 +1378,20 @@ Packet *sp_cmd_brightness_grid_into_packet(BrightnessGridCommand */*notnull*/ co
|
|||
*
|
||||
* Returns: a new [BrightnessGridCommand] instance.
|
||||
*/
|
||||
BrightnessGridCommand */*notnull*/ sp_cmd_brightness_grid_new(BrightnessGrid */*notnull*/ grid,
|
||||
size_t origin_x,
|
||||
size_t origin_y);
|
||||
struct BrightnessGridCommand */*notnull*/ sp_cmd_brightness_grid_new(BrightnessGrid */*notnull*/ grid,
|
||||
size_t origin_x,
|
||||
size_t origin_y);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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_y);
|
||||
|
||||
|
@ -1395,28 +1400,28 @@ void sp_cmd_brightness_grid_set_origin(BrightnessGridCommand */*notnull*/ comman
|
|||
*
|
||||
* 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].
|
||||
*/
|
||||
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],
|
||||
* 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].
|
||||
*/
|
||||
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].
|
||||
*/
|
||||
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_y);
|
||||
|
||||
|
@ -1427,20 +1432,20 @@ void sp_cmd_char_grid_get_origin(CharGridCommand */*notnull*/ command,
|
|||
*
|
||||
* Returns: a new [CharGridCommand] instance.
|
||||
*/
|
||||
CharGridCommand */*notnull*/ sp_cmd_char_grid_new(CharGrid */*notnull*/ grid,
|
||||
size_t origin_x,
|
||||
size_t origin_y);
|
||||
struct CharGridCommand */*notnull*/ sp_cmd_char_grid_new(CharGrid */*notnull*/ grid,
|
||||
size_t origin_x,
|
||||
size_t origin_y);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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_y);
|
||||
|
||||
|
@ -1449,12 +1454,12 @@ void sp_cmd_char_grid_set_origin(CharGridCommand */*notnull*/ 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].
|
||||
*/
|
||||
void sp_cmd_clear_free(ClearCommand */*notnull*/ command);
|
||||
void sp_cmd_clear_free(struct ClearCommand */*notnull*/ command);
|
||||
|
||||
/**
|
||||
* Set all pixels to the off state.
|
||||
|
@ -1463,25 +1468,25 @@ void sp_cmd_clear_free(ClearCommand */*notnull*/ command);
|
|||
*
|
||||
* Returns: a new [ClearCommand] instance.
|
||||
*/
|
||||
ClearCommand */*notnull*/ sp_cmd_clear_new(void);
|
||||
struct ClearCommand */*notnull*/ sp_cmd_clear_new(void);
|
||||
|
||||
/**
|
||||
* Clones an [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].
|
||||
*/
|
||||
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],
|
||||
* 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.
|
||||
|
@ -1491,14 +1496,14 @@ Cp437GridCommand */*notnull*/ sp_cmd_cp437_grid_from_grid(Cp437Grid */*notnull*/
|
|||
*
|
||||
* [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].
|
||||
*
|
||||
* 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_y);
|
||||
|
||||
|
@ -1509,16 +1514,16 @@ void sp_cmd_cp437_grid_get_origin(Cp437GridCommand */*notnull*/ command,
|
|||
*
|
||||
* The origin is relative to the top-left of the display.
|
||||
*/
|
||||
Cp437GridCommand */*notnull*/ sp_cmd_cp437_grid_new(Cp437Grid */*notnull*/ grid,
|
||||
size_t origin_x,
|
||||
size_t origin_y);
|
||||
struct Cp437GridCommand */*notnull*/ sp_cmd_cp437_grid_new(Cp437Grid */*notnull*/ grid,
|
||||
size_t origin_x,
|
||||
size_t origin_y);
|
||||
|
||||
/**
|
||||
* Moves the provided bitmap into the provided command.
|
||||
*
|
||||
* 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);
|
||||
|
||||
/**
|
||||
|
@ -1526,7 +1531,7 @@ void sp_cmd_cp437_grid_set(Cp437GridCommand */*notnull*/ command,
|
|||
*
|
||||
* 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_y);
|
||||
|
||||
|
@ -1535,26 +1540,26 @@ void sp_cmd_cp437_grid_set_origin(Cp437GridCommand */*notnull*/ 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].
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* returns: a new [SPCommand] instance.
|
||||
*/
|
||||
Command sp_cmd_generic_clone(Command command);
|
||||
struct Command sp_cmd_generic_clone(struct Command command);
|
||||
|
||||
/**
|
||||
* Deallocates an [SPCommand].
|
||||
|
@ -1566,7 +1571,7 @@ Command sp_cmd_generic_clone(Command command);
|
|||
* 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].
|
||||
|
@ -1574,7 +1579,7 @@ void sp_cmd_generic_free(Command command);
|
|||
*
|
||||
* 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].
|
||||
|
@ -1583,12 +1588,12 @@ Packet *sp_cmd_generic_into_packet(Command command);
|
|||
*
|
||||
* 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].
|
||||
*/
|
||||
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.
|
||||
|
@ -1597,7 +1602,7 @@ void sp_cmd_hard_reset_free(ClearCommand */*notnull*/ command);
|
|||
*
|
||||
* 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].
|
||||
|
@ -1651,14 +1656,16 @@ size_t sp_cp437_grid_height(Cp437Grid */*notnull*/ cp437_grid);
|
|||
*
|
||||
* Returns NULL in case of an error.
|
||||
*/
|
||||
Packet *sp_cp437_grid_into_packet(Cp437Grid */*notnull*/ grid,
|
||||
size_t x,
|
||||
size_t y);
|
||||
struct Packet *sp_cp437_grid_into_packet(Cp437Grid */*notnull*/ grid,
|
||||
size_t x,
|
||||
size_t y);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
@ -1692,7 +1699,7 @@ void sp_cp437_grid_set(Cp437Grid */*notnull*/ cp437_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.
|
||||
|
@ -1708,26 +1715,27 @@ size_t sp_cp437_grid_width(Cp437Grid */*notnull*/ cp437_grid);
|
|||
*
|
||||
* 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].
|
||||
*/
|
||||
void sp_packet_free(Packet */*notnull*/ packet);
|
||||
void sp_packet_free(struct Packet */*notnull*/ packet);
|
||||
|
||||
/**
|
||||
* Creates a raw [Packet] from parts.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
|
@ -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.
|
||||
*/
|
||||
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.
|
||||
|
@ -1745,21 +1753,23 @@ ByteSlice sp_packet_get_payload(Packet */*notnull*/ packet);
|
|||
*
|
||||
* - 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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].
|
||||
|
@ -1772,7 +1782,7 @@ bool sp_u16_to_command_code(uint16_t code,
|
|||
/**
|
||||
* 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].
|
||||
|
@ -1787,7 +1797,7 @@ void sp_udp_free(UdpSocket */*notnull*/ connection);
|
|||
* 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].
|
||||
|
@ -1802,11 +1812,11 @@ UdpSocket *sp_udp_open(char */*notnull*/ host);
|
|||
* sp_udp_send_command(connection, sp_command_clear());
|
||||
* ```
|
||||
*/
|
||||
UdpSocket *sp_udp_open_ipv4(uint8_t ip1,
|
||||
uint8_t ip2,
|
||||
uint8_t ip3,
|
||||
uint8_t ip4,
|
||||
uint16_t port);
|
||||
struct UdpSocket *sp_udp_open_ipv4(uint8_t ip1,
|
||||
uint8_t ip2,
|
||||
uint8_t ip3,
|
||||
uint8_t ip4,
|
||||
uint16_t port);
|
||||
|
||||
/**
|
||||
* Sends a [SPCommand] to the display using the [UdpSocket].
|
||||
|
@ -1821,7 +1831,8 @@ UdpSocket *sp_udp_open_ipv4(uint8_t ip1,
|
|||
* 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].
|
||||
|
@ -1834,7 +1845,8 @@ bool sp_udp_send_command(UdpSocket */*notnull*/ connection, Command command);
|
|||
* 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].
|
||||
|
@ -1843,8 +1855,8 @@ bool sp_udp_send_header(UdpSocket */*notnull*/ udp_connection, Header header);
|
|||
*
|
||||
* returns: true in case of success
|
||||
*/
|
||||
bool sp_udp_send_packet(UdpSocket */*notnull*/ connection,
|
||||
Packet */*notnull*/ packet);
|
||||
bool sp_udp_send_packet(struct UdpSocket */*notnull*/ connection,
|
||||
struct Packet */*notnull*/ packet);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
|
|
@ -43,3 +43,11 @@ pub struct UdpSocket;
|
|||
|
||||
/// This is a type only used by cbindgen to have a type for pointers.
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue