From 3a966ad1a1f882dc46946dc2ce3b4f4374c96575 Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Sat, 12 Apr 2025 22:32:27 +0200 Subject: [PATCH] features, cargo fmt --- Cargo.toml | 5 +++-- example/Makefile | 4 +++- src/bitmap.rs | 6 ++++-- src/bitvec.rs | 6 ++++-- src/commands/mod.rs | 3 --- src/cp437_grid.rs | 4 +++- src/lib.rs | 12 ++++++++---- src/{commands/typed.rs => typed_command.rs} | 0 src/{connection.rs => udp.rs} | 0 9 files changed, 25 insertions(+), 15 deletions(-) delete mode 100644 src/commands/mod.rs rename src/{commands/typed.rs => typed_command.rs} (100%) rename src/{connection.rs => udp.rs} (100%) diff --git a/Cargo.toml b/Cargo.toml index e92ceb2..cc7b596 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,8 +26,9 @@ git = "https://git.berlin.ccc.de/servicepoint/servicepoint/" branch = "next" [features] -full = ["servicepoint/all_compressions", "servicepoint/default"] -default = ["full"] +protocol_udp = ["servicepoint/protocol_udp"] +all_compressions = ["servicepoint/all_compressions"] +default = ["all_compressions", "servicepoint/default", "protocol_udp"] [lints.rust] missing-docs = "warn" diff --git a/example/Makefile b/example/Makefile index f69f385..7e5bfe7 100644 --- a/example/Makefile +++ b/example/Makefile @@ -3,6 +3,7 @@ CARGO := rustup run nightly cargo TARGET := x86_64-unknown-linux-musl PROFILE := size-optimized +FEATURES := protocol_udp THIS_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) REPO_ROOT := $(THIS_DIR)/.. @@ -22,6 +23,7 @@ RUSTFLAGS := -Zlocation-detail=none \ CARGOFLAGS := --manifest-path=$(REPO_ROOT)/Cargo.toml \ --profile=$(PROFILE) \ --no-default-features \ + --features=$(FEATURES) \ --target=$(TARGET) \ -Zbuild-std="core,std,alloc,proc_macro,panic_abort" \ -Zbuild-std-features="panic_immediate_abort" \ @@ -53,7 +55,7 @@ _programs := $(basename $(_c_src)) _bins := $(addprefix out/, $(_programs)) _unstripped_bins := $(addsuffix _unstripped, $(_bins)) _run_programs := $(addprefix run_, $(_programs)) -_rs_src := $(wildcard ../src/**.rs) ../Cargo.lock +_rs_src := $(wildcard ../src/**.rs) ../Cargo.lock ../Cargo.toml ../cbindgen.toml all: $(_bins) diff --git a/src/bitmap.rs b/src/bitmap.rs index 358be48..5db4af0 100644 --- a/src/bitmap.rs +++ b/src/bitmap.rs @@ -1,6 +1,8 @@ use crate::byte_slice::ByteSlice; use crate::{heap_drop, heap_move, heap_move_nonnull, heap_remove, SPBitVec}; -use servicepoint::{Bitmap, BitmapCommand, CompressionCode, DataRef, Grid, Origin, Packet}; +use servicepoint::{ + Bitmap, BitmapCommand, CompressionCode, DataRef, Grid, Origin, Packet, +}; use std::ptr::NonNull; /// Creates a new [Bitmap] with the specified dimensions. @@ -210,7 +212,7 @@ pub unsafe extern "C" fn sp_bitmap_into_packet( bitmap: NonNull, x: usize, y: usize, - compression: CompressionCode + compression: CompressionCode, ) -> *mut Packet { let bitmap = unsafe { heap_remove(bitmap) }; match Packet::try_from(BitmapCommand { diff --git a/src/bitvec.rs b/src/bitvec.rs index 22f7545..82c0fbe 100644 --- a/src/bitvec.rs +++ b/src/bitvec.rs @@ -1,5 +1,7 @@ use crate::{heap_drop, heap_move, heap_move_nonnull, heap_remove, ByteSlice}; -use servicepoint::{BinaryOperation, BitVecCommand, BitVecU8Msb0, CompressionCode, Packet}; +use servicepoint::{ + BinaryOperation, BitVecCommand, BitVecU8Msb0, CompressionCode, Packet, +}; use std::ptr::NonNull; /// A vector of bits @@ -157,7 +159,7 @@ pub unsafe extern "C" fn sp_bitvec_into_packet( bitvec: NonNull, offset: usize, operation: BinaryOperation, - compression: CompressionCode + compression: CompressionCode, ) -> *mut Packet { let bitvec = unsafe { heap_remove(bitvec) }.0; match Packet::try_from(BitVecCommand { diff --git a/src/commands/mod.rs b/src/commands/mod.rs deleted file mode 100644 index 1ea03d5..0000000 --- a/src/commands/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -mod typed; - -pub use typed::*; diff --git a/src/cp437_grid.rs b/src/cp437_grid.rs index 01aeb1e..ff70d2b 100644 --- a/src/cp437_grid.rs +++ b/src/cp437_grid.rs @@ -1,5 +1,7 @@ use crate::{heap_drop, heap_move, heap_move_nonnull, heap_remove, ByteSlice}; -use servicepoint::{Cp437Grid, Cp437GridCommand, DataRef, Grid, Origin, Packet}; +use servicepoint::{ + Cp437Grid, Cp437GridCommand, DataRef, Grid, Origin, Packet, +}; use std::ptr::NonNull; /// Creates a new [Cp437Grid] with the specified dimensions. diff --git a/src/lib.rs b/src/lib.rs index 05fb009..57192e0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -30,22 +30,26 @@ pub use crate::bitvec::*; pub use crate::brightness_grid::*; pub use crate::byte_slice::*; pub use crate::char_grid::*; -pub use crate::commands::*; -pub use crate::connection::*; pub use crate::cp437_grid::*; pub use crate::packet::*; pub use servicepoint::CommandCode; use std::ptr::NonNull; +pub use typed_command::*; mod bitmap; mod bitvec; mod brightness_grid; mod byte_slice; mod char_grid; -mod commands; -mod connection; mod cp437_grid; mod packet; +mod typed_command; + +#[cfg(feature = "protocol_udp")] +mod udp; + +#[cfg(feature = "protocol_udp")] +pub use udp::*; use std::time::Duration; diff --git a/src/commands/typed.rs b/src/typed_command.rs similarity index 100% rename from src/commands/typed.rs rename to src/typed_command.rs diff --git a/src/connection.rs b/src/udp.rs similarity index 100% rename from src/connection.rs rename to src/udp.rs