servicepoint-binding-c/src/lib.rs
2025-06-26 17:29:03 +02:00

54 lines
1.6 KiB
Rust

//! C API wrapper for the [servicepoint](https://docs.rs/servicepoint/latest/servicepoint/) crate.
//!
//! # Examples
//!
//! ```C
//! #include <stdio.h>
//! #include "servicepoint.h"
//!
//! int main(void) {
//! UdpSocket *connection = sp_udp_open("172.23.42.29:2342");
//! if (connection == NULL)
//! return 1;
//!
//! Bitmap *pixels = sp_bitmap_new(SP_PIXEL_WIDTH, SP_PIXEL_HEIGHT);
//! sp_bitmap_fill(pixels, true);
//!
//! TypedCommand *command = sp_command_bitmap_linear_win(0, 0, pixels, Uncompressed);
//! while (sp_udp_send_command(connection, sp_command_clone(command)));
//!
//! sp_command_free(command);
//! sp_udp_free(connection);
//! return 0;
//! }
//! ```
//!
//! There are more examples in the source repository.
/// Functions related to commands.
pub mod commands;
/// Functions related to [servicepoint::Bitmap], [servicepoint::CharGrid] and friends.
pub mod containers;
pub(crate) mod macros;
pub(crate) mod mem;
/// Functions related to [servicepoint::Packet].
pub mod packet;
/// Functions related to [servicepoint::UdpSocketExt].
pub mod udp;
/// Actual hardware limit is around 28-29ms/frame. Rounded up for less dropped packets.
pub const SP_FRAME_PACING_MS: u128 = 30;
#[cfg(feature = "env_logger")]
mod feature_env_logger {
use crate::macros::wrap_functions;
wrap_functions!(envlogger;
/// Call this function at the beginning of main to enable rust logging controlled by the
/// `RUST_LOG` environment variable. See [env_logger](https://docs.rs/env_logger/latest/env_logger/).
fn init() {
env_logger::init();
};
);
}