Compare commits
2 commits
82696b2d1a
...
c65b735f57
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c65b735f57 | ||
![]() |
5beea6151a |
|
@ -1,20 +1,19 @@
|
|||
use crate::{
|
||||
commands::{wrap_command, wrap_origin_accessors},
|
||||
macros::{wrap_fields, wrap_functions},
|
||||
macros::wrap,
|
||||
};
|
||||
use servicepoint::{Bitmap, BitmapCommand, CompressionCode, Origin};
|
||||
use std::ptr::NonNull;
|
||||
|
||||
wrap_command!(Bitmap);
|
||||
|
||||
wrap_fields!(BitmapCommand;
|
||||
prop bitmap: Bitmap { get mut; set move; };
|
||||
prop compression: CompressionCode { get; set; };
|
||||
);
|
||||
|
||||
wrap_origin_accessors!(BitmapCommand);
|
||||
|
||||
wrap_functions!(associate BitmapCommand;
|
||||
wrap! {
|
||||
BitmapCommand {
|
||||
properties:
|
||||
prop bitmap: Bitmap { get mut; set move; };
|
||||
prop compression: CompressionCode { get; set; };
|
||||
functions:
|
||||
/// Sets a window of pixels to the specified values.
|
||||
///
|
||||
/// The passed [Bitmap] gets consumed.
|
||||
|
@ -40,4 +39,5 @@ wrap_functions!(associate BitmapCommand;
|
|||
fn from_bitmap(bitmap: move NonNull<Bitmap>) -> move NonNull<BitmapCommand> {
|
||||
bitmap.into()
|
||||
};
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
use crate::{
|
||||
commands::wrap_command,
|
||||
macros::{wrap_fields, wrap_functions},
|
||||
};
|
||||
use crate::{commands::wrap_command, macros::wrap};
|
||||
use servicepoint::{
|
||||
BinaryOperation, BitVecCommand, CompressionCode, DisplayBitVec, Offset,
|
||||
};
|
||||
|
@ -9,14 +6,14 @@ use std::ptr::NonNull;
|
|||
|
||||
wrap_command!(BitVec);
|
||||
|
||||
wrap_fields!(BitVecCommand;
|
||||
wrap!(
|
||||
BitVecCommand {
|
||||
properties:
|
||||
prop bitvec: DisplayBitVec { get mut; set move; };
|
||||
prop offset: Offset { get; set; };
|
||||
prop operation: BinaryOperation { get; set; };
|
||||
prop compression: CompressionCode { get; set; };
|
||||
);
|
||||
|
||||
wrap_functions!(associate BitVecCommand;
|
||||
functions:
|
||||
/// Set pixel data starting at the pixel offset on screen.
|
||||
///
|
||||
/// The screen will continuously overwrite more pixel data without regarding the offset, meaning
|
||||
|
@ -42,4 +39,5 @@ wrap_functions!(associate BitVecCommand;
|
|||
compression,
|
||||
}
|
||||
};
|
||||
}
|
||||
);
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
use crate::{
|
||||
commands::{wrap_command, wrap_origin_accessors},
|
||||
macros::{wrap_fields, wrap_functions},
|
||||
macros::wrap,
|
||||
};
|
||||
use servicepoint::{BrightnessGrid, BrightnessGridCommand, Origin};
|
||||
use std::ptr::NonNull;
|
||||
|
||||
wrap_command!(BrightnessGrid);
|
||||
|
||||
wrap_fields!(BrightnessGridCommand;
|
||||
prop grid: BrightnessGrid { get mut; set move; };
|
||||
);
|
||||
|
||||
wrap_origin_accessors!(BrightnessGridCommand);
|
||||
|
||||
wrap_functions!(associate BrightnessGridCommand;
|
||||
wrap!(
|
||||
BrightnessGridCommand {
|
||||
properties:
|
||||
prop grid: BrightnessGrid { get mut; set move; };
|
||||
functions:
|
||||
/// Set the brightness of individual tiles in a rectangular area of the display.
|
||||
///
|
||||
/// The passed [BrightnessGrid] gets consumed.
|
||||
|
@ -35,4 +34,5 @@ wrap_functions!(associate BrightnessGridCommand;
|
|||
fn from_grid(grid: move NonNull<BrightnessGrid>) -> move NonNull<BrightnessGridCommand> {
|
||||
grid.into()
|
||||
};
|
||||
}
|
||||
);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{commands::wrap_command, macros::wrap_functions};
|
||||
use crate::commands::wrap_command;
|
||||
use servicepoint::{ClearCommand, FadeOutCommand, HardResetCommand};
|
||||
|
||||
macro_rules! wrap_cc_only {
|
||||
|
@ -6,14 +6,17 @@ macro_rules! wrap_cc_only {
|
|||
::paste::paste!{
|
||||
wrap_command!($command);
|
||||
|
||||
wrap_functions!(associate [< $command Command >];
|
||||
$crate::macros::wrap!{
|
||||
[< $command Command >] {
|
||||
functions:
|
||||
$(#[$meta])*
|
||||
///
|
||||
#[doc = " Returns: a new [`" [< $command Command >] "`] instance."]
|
||||
fn new() -> move ::core::ptr::NonNull<[< $command Command >]> {
|
||||
[< $command Command >]
|
||||
};
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
use crate::{
|
||||
commands::{wrap_command, wrap_origin_accessors},
|
||||
macros::{wrap_fields, wrap_functions},
|
||||
macros::wrap,
|
||||
};
|
||||
use servicepoint::{CharGrid, CharGridCommand, Origin};
|
||||
use std::ptr::NonNull;
|
||||
|
||||
wrap_command!(CharGrid);
|
||||
|
||||
wrap_fields!(CharGridCommand;
|
||||
prop grid: CharGrid { get mut; set move; };
|
||||
);
|
||||
|
||||
wrap_origin_accessors!(CharGridCommand);
|
||||
|
||||
wrap_functions!(associate CharGridCommand;
|
||||
wrap!(
|
||||
CharGridCommand {
|
||||
properties:
|
||||
prop grid: CharGrid { get mut; set move; };
|
||||
functions:
|
||||
/// Show UTF-8 encoded text on the screen.
|
||||
///
|
||||
/// The passed [CharGrid] gets consumed.
|
||||
|
@ -35,4 +34,5 @@ wrap_functions!(associate CharGridCommand;
|
|||
fn from_grid(grid: move NonNull<CharGrid>) -> move NonNull<CharGridCommand> {
|
||||
grid.into()
|
||||
};
|
||||
}
|
||||
);
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
use crate::{
|
||||
commands::{wrap_command, wrap_origin_accessors},
|
||||
macros::{wrap_fields, wrap_functions},
|
||||
macros::wrap,
|
||||
};
|
||||
use servicepoint::{Cp437Grid, Cp437GridCommand, Origin};
|
||||
use std::ptr::NonNull;
|
||||
|
||||
wrap_command!(Cp437Grid);
|
||||
|
||||
wrap_fields!(Cp437GridCommand;
|
||||
prop grid: Cp437Grid { get mut; set move; };
|
||||
);
|
||||
|
||||
wrap_origin_accessors!(Cp437GridCommand);
|
||||
|
||||
wrap_functions!(associate Cp437GridCommand;
|
||||
wrap!(
|
||||
Cp437GridCommand {
|
||||
properties:
|
||||
prop grid: Cp437Grid { get mut; set move; };
|
||||
functions:
|
||||
/// Show text on the screen.
|
||||
///
|
||||
/// The text is sent in the form of a 2D grid of [CP-437] encoded characters.
|
||||
|
@ -35,4 +34,5 @@ wrap_functions!(associate Cp437GridCommand;
|
|||
fn from_grid(grid: move NonNull<Cp437Grid>) -> move NonNull<Cp437GridCommand> {
|
||||
grid.into()
|
||||
};
|
||||
}
|
||||
);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
macros::{derive_clone, derive_free, wrap_functions, wrap_methods},
|
||||
macros::{derive_clone, derive_free, wrap},
|
||||
mem::{
|
||||
heap_clone, heap_drop, heap_move, heap_move_nonnull, heap_move_ok,
|
||||
heap_remove,
|
||||
|
@ -69,8 +69,6 @@ impl GenericCommand {
|
|||
};
|
||||
}
|
||||
|
||||
derive_clone!(GenericCommand);
|
||||
|
||||
impl Clone for GenericCommand {
|
||||
fn clone(&self) -> Self {
|
||||
unsafe {
|
||||
|
@ -144,8 +142,6 @@ impl Clone for GenericCommand {
|
|||
}
|
||||
}
|
||||
|
||||
derive_free!(GenericCommand);
|
||||
|
||||
impl Drop for GenericCommand {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
|
@ -172,7 +168,12 @@ impl Drop for GenericCommand {
|
|||
}
|
||||
}
|
||||
|
||||
wrap_functions!(associate GenericCommand;
|
||||
derive_clone!(GenericCommand);
|
||||
derive_free!(GenericCommand);
|
||||
|
||||
wrap! {
|
||||
GenericCommand {
|
||||
functions:
|
||||
/// Tries to turn a [Packet] into a [GenericCommand].
|
||||
///
|
||||
/// The packet is dropped in the process.
|
||||
|
@ -248,9 +249,7 @@ wrap_functions!(associate GenericCommand;
|
|||
data: CommandUnion { null: null_mut() },
|
||||
})
|
||||
};
|
||||
);
|
||||
|
||||
wrap_methods! { GenericCommand;
|
||||
methods:
|
||||
/// Tries to turn a [GenericCommand] into a [Packet].
|
||||
/// The [GenericCommand] gets consumed.
|
||||
///
|
||||
|
@ -290,4 +289,5 @@ wrap_methods! { GenericCommand;
|
|||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +1,19 @@
|
|||
use crate::{
|
||||
commands::wrap_command,
|
||||
macros::{wrap_fields, wrap_functions},
|
||||
};
|
||||
use crate::{commands::wrap_command, macros::wrap};
|
||||
use servicepoint::{Brightness, GlobalBrightnessCommand};
|
||||
use std::ptr::NonNull;
|
||||
|
||||
wrap_functions!(associate GlobalBrightnessCommand;
|
||||
wrap_command!(GlobalBrightness);
|
||||
|
||||
wrap!(
|
||||
GlobalBrightnessCommand {
|
||||
properties:
|
||||
prop brightness: Brightness { get; set; };
|
||||
functions:
|
||||
/// Set the brightness of all tiles to the same value.
|
||||
///
|
||||
/// Returns: a new [GlobalBrightnessCommand] instance.
|
||||
fn new(brightness: val Brightness) -> move NonNull<GlobalBrightnessCommand> {
|
||||
GlobalBrightnessCommand::from(brightness)
|
||||
};
|
||||
);
|
||||
|
||||
wrap_command!(GlobalBrightness);
|
||||
|
||||
wrap_fields!(GlobalBrightnessCommand;
|
||||
prop brightness: Brightness { get; set; };
|
||||
}
|
||||
);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
containers::{wrap_grid, ByteSlice},
|
||||
macros::{wrap_functions, wrap_methods},
|
||||
macros::wrap,
|
||||
};
|
||||
use servicepoint::{
|
||||
Bitmap, BitmapCommand, CompressionCode, DataRef, DisplayBitVec, Grid,
|
||||
|
@ -10,7 +10,9 @@ use std::ptr::NonNull;
|
|||
|
||||
wrap_grid!(Bitmap, bool);
|
||||
|
||||
wrap_functions!(associate Bitmap;
|
||||
wrap! {
|
||||
Bitmap {
|
||||
functions:
|
||||
/// Creates a new [Bitmap] with the specified dimensions.
|
||||
///
|
||||
/// # Arguments
|
||||
|
@ -72,9 +74,8 @@ wrap_functions!(associate Bitmap;
|
|||
) -> move_ok *mut Bitmap {
|
||||
Bitmap::from_bitvec(width, bitvec)
|
||||
};
|
||||
);
|
||||
|
||||
wrap_methods!(Bitmap;
|
||||
methods:
|
||||
/// Consumes the Bitmap and returns the contained BitVec.
|
||||
fn into_bitvec(move bitmap) -> move NonNull<DisplayBitVec> {
|
||||
bitmap.into()
|
||||
|
@ -97,4 +98,5 @@ wrap_methods!(Bitmap;
|
|||
///
|
||||
/// The returned memory is valid for the lifetime of the bitmap.
|
||||
fn data_ref_mut(mut instance) -> slice ByteSlice;
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
containers::{wrap_container, ByteSlice},
|
||||
macros::{wrap_functions, wrap_methods},
|
||||
macros::wrap,
|
||||
};
|
||||
use servicepoint::{
|
||||
BinaryOperation, BitVecCommand, CompressionCode, DisplayBitVec, Packet,
|
||||
|
@ -9,7 +9,9 @@ use std::ptr::NonNull;
|
|||
|
||||
wrap_container!(DisplayBitVec);
|
||||
|
||||
wrap_functions!(associate DisplayBitVec;
|
||||
wrap! {
|
||||
DisplayBitVec {
|
||||
functions:
|
||||
/// Creates a new [DisplayBitVec] instance.
|
||||
///
|
||||
/// # Arguments
|
||||
|
@ -31,9 +33,8 @@ wrap_functions!(associate DisplayBitVec;
|
|||
fn load(data: slice ByteSlice) -> move NonNull<DisplayBitVec> {
|
||||
DisplayBitVec::from_slice(data)
|
||||
};
|
||||
);
|
||||
|
||||
wrap_methods!(DisplayBitVec;
|
||||
methods:
|
||||
/// Creates a [BitVecCommand] and immediately turns that into a [Packet].
|
||||
///
|
||||
/// The provided [DisplayBitVec] gets consumed.
|
||||
|
@ -98,4 +99,5 @@ wrap_methods!(DisplayBitVec;
|
|||
///
|
||||
/// The returned memory is valid for the lifetime of the bitvec.
|
||||
fn as_raw_mut_slice(mut instance) -> slice ByteSlice;
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
containers::{wrap_grid, ByteSlice},
|
||||
macros::{wrap_functions, wrap_methods},
|
||||
macros::wrap,
|
||||
};
|
||||
use servicepoint::{
|
||||
Brightness, BrightnessGrid, BrightnessGridCommand, ByteGrid, DataRef, Grid,
|
||||
|
@ -10,7 +10,9 @@ use std::{mem::transmute, ptr::NonNull};
|
|||
|
||||
wrap_grid!(BrightnessGrid, Brightness);
|
||||
|
||||
wrap_functions!(associate BrightnessGrid;
|
||||
wrap! {
|
||||
BrightnessGrid {
|
||||
functions:
|
||||
/// Creates a new [BrightnessGrid] with the specified dimensions.
|
||||
///
|
||||
/// returns: [BrightnessGrid] initialized to 0.
|
||||
|
@ -45,9 +47,8 @@ wrap_functions!(associate BrightnessGrid;
|
|||
ByteGrid::load(width, height, data)
|
||||
.map(move |grid| grid.map(Brightness::saturating_from))
|
||||
};
|
||||
);
|
||||
|
||||
wrap_methods!(BrightnessGrid;
|
||||
methods:
|
||||
/// Creates a [BrightnessGridCommand] and immediately turns that into a [Packet].
|
||||
///
|
||||
/// The provided [BrightnessGrid] gets consumed.
|
||||
|
@ -72,4 +73,5 @@ wrap_methods!(BrightnessGrid;
|
|||
transmute::<&mut [Brightness], &mut [u8]>(br_slice)
|
||||
}
|
||||
};
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
containers::{derive_get_width_height, wrap_container, ByteSlice},
|
||||
macros::{wrap_functions, wrap_methods},
|
||||
macros::wrap,
|
||||
};
|
||||
use servicepoint::{CharGrid, CharGridCommand, Grid, Origin, Packet};
|
||||
use std::ptr::NonNull;
|
||||
|
@ -8,7 +8,9 @@ use std::ptr::NonNull;
|
|||
wrap_container!(CharGrid);
|
||||
derive_get_width_height!(CharGrid);
|
||||
|
||||
wrap_functions!(associate CharGrid;
|
||||
wrap! {
|
||||
CharGrid {
|
||||
functions:
|
||||
/// Creates a new [CharGrid] with the specified dimensions.
|
||||
///
|
||||
/// returns: [CharGrid] initialized to 0.
|
||||
|
@ -31,10 +33,7 @@ wrap_functions!(associate CharGrid;
|
|||
fn load(width: val usize, height: val usize, data: slice ByteSlice) -> move_ok *mut CharGrid {
|
||||
CharGrid::load_utf8(width, height, data.to_vec())
|
||||
};
|
||||
);
|
||||
|
||||
wrap_methods!(CharGrid;
|
||||
|
||||
methods:
|
||||
/// Returns the current value at the specified position.
|
||||
///
|
||||
/// # Arguments
|
||||
|
@ -86,4 +85,5 @@ wrap_methods!(CharGrid;
|
|||
origin: Origin::new(x, y),
|
||||
})
|
||||
};
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
containers::{wrap_grid, ByteSlice},
|
||||
macros::{wrap_functions, wrap_methods},
|
||||
macros::wrap,
|
||||
};
|
||||
use servicepoint::{
|
||||
Cp437Grid, Cp437GridCommand, DataRef, Grid, Origin, Packet,
|
||||
|
@ -9,7 +9,9 @@ use std::ptr::NonNull;
|
|||
|
||||
wrap_grid!(Cp437Grid, u8);
|
||||
|
||||
wrap_functions!(associate Cp437Grid;
|
||||
wrap! {
|
||||
Cp437Grid {
|
||||
functions:
|
||||
/// Creates a new [Cp437Grid] with the specified dimensions.
|
||||
///
|
||||
/// returns: [Cp437Grid] initialized to 0.
|
||||
|
@ -21,9 +23,8 @@ wrap_functions!(associate Cp437Grid;
|
|||
fn load(width: val usize, height: val usize, data: slice ByteSlice) -> move_some *mut Cp437Grid {
|
||||
Cp437Grid::load(width, height, data)
|
||||
};
|
||||
);
|
||||
|
||||
wrap_methods!(Cp437Grid;
|
||||
methods:
|
||||
/// Creates a [Cp437GridCommand] and immediately turns that into a [Packet].
|
||||
///
|
||||
/// The provided [Cp437Grid] gets consumed.
|
||||
|
@ -40,4 +41,5 @@ wrap_methods!(Cp437Grid;
|
|||
///
|
||||
/// The returned memory is valid for the lifetime of the instance.
|
||||
fn data_ref_mut(mut instance) -> slice ByteSlice;
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -263,8 +263,61 @@ macro_rules! wrap_functions {
|
|||
};
|
||||
}
|
||||
|
||||
macro_rules! wrap {
|
||||
(
|
||||
$object_type:ident {
|
||||
$(
|
||||
properties:
|
||||
$(
|
||||
prop $prop_name:ident : $prop_type:ty { $($accessor:ident $($modifier:ident)?;)+ };
|
||||
)*
|
||||
)?
|
||||
$(
|
||||
functions:
|
||||
$(
|
||||
$(#[$fn_meta:meta])+
|
||||
fn $fn_name:ident($($fn_param_name:ident: $fn_param_modifier:ident $fn_param_type:ty),*$(,)?)
|
||||
$(-> $fn_return_modifier:ident $fn_return_type:ty)?
|
||||
$fn_block:block;
|
||||
)*
|
||||
)?
|
||||
$(
|
||||
methods:
|
||||
$(
|
||||
$(#[$method_meta:meta])+
|
||||
fn $method_name:ident($method_instance_modifier:ident $method_instance:ident $(, $($method_param_name:ident: $method_param_modifier:ident $method_param_type:ty),*)?)
|
||||
$(-> $method_return_modifier:ident $method_return_type:ty)?
|
||||
$($method_impl:block)?;
|
||||
)*
|
||||
)?
|
||||
}
|
||||
) => {
|
||||
$($(
|
||||
$crate::macros::wrap_fields!($object_type;
|
||||
prop $prop_name : $prop_type { $($accessor $($modifier)?;)+ };
|
||||
);
|
||||
)*)?
|
||||
$($(
|
||||
$crate::macros::wrap_functions!(associate $object_type;
|
||||
$(#[$fn_meta])+
|
||||
fn $fn_name($($fn_param_name: $fn_param_modifier $fn_param_type),*)
|
||||
$(-> $fn_return_modifier $fn_return_type)?
|
||||
$fn_block;
|
||||
);
|
||||
)*)?
|
||||
$($(
|
||||
$crate::macros::wrap_method!($object_type;
|
||||
$(#[$method_meta])+
|
||||
fn $method_name($method_instance_modifier $method_instance $(, $($method_param_name: $method_param_modifier $method_param_type),*)?)
|
||||
$(-> $method_return_modifier $method_return_type)?
|
||||
$($method_impl)?;
|
||||
);
|
||||
)*)?
|
||||
};
|
||||
}
|
||||
|
||||
pub(crate) use {
|
||||
apply_param_modifier, apply_return_modifier, derive_clone, derive_free,
|
||||
wrap_fields, wrap_fields_accessor, wrap_function, wrap_functions,
|
||||
wrap, wrap_fields, wrap_fields_accessor, wrap_function, wrap_functions,
|
||||
wrap_method, wrap_methods,
|
||||
};
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
use crate::{
|
||||
containers::ByteSlice,
|
||||
macros::{
|
||||
derive_clone, derive_free, wrap_fields, wrap_functions, wrap_methods,
|
||||
},
|
||||
macros::{derive_clone, derive_free, wrap, wrap_functions},
|
||||
};
|
||||
use servicepoint::{CommandCode, Header, Packet};
|
||||
use std::ptr::NonNull;
|
||||
|
||||
wrap_functions!(associate Packet;
|
||||
derive_clone!(Packet);
|
||||
derive_free!(Packet);
|
||||
|
||||
wrap! {
|
||||
Packet {
|
||||
properties:
|
||||
prop header: Header { get; get mut; set; };
|
||||
functions:
|
||||
/// 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
|
||||
|
@ -27,16 +32,7 @@ wrap_functions!(associate Packet;
|
|||
|
||||
Packet { header, payload }
|
||||
};
|
||||
);
|
||||
|
||||
derive_clone!(Packet);
|
||||
derive_free!(Packet);
|
||||
|
||||
wrap_fields!(Packet;
|
||||
prop header: Header { get; get mut; set; };
|
||||
);
|
||||
|
||||
wrap_methods! { Packet;
|
||||
methods:
|
||||
/// Returns a pointer to the current payload of the provided packet.
|
||||
///
|
||||
/// Returns an [ByteSlice::INVALID] instance in case the packet does not have any payload.
|
||||
|
@ -70,10 +66,10 @@ wrap_methods! { Packet;
|
|||
packet.serialize_to(buffer.as_slice_mut()).unwrap_or(0)
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
wrap_functions!(sp;
|
||||
|
||||
/// Converts u16 into [CommandCode].
|
||||
///
|
||||
/// If the provided value is not valid, false is returned and result is not changed.
|
||||
|
|
11
src/udp.rs
11
src/udp.rs
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
commands::{CommandTag, GenericCommand},
|
||||
macros::{derive_free, wrap_functions, wrap_methods},
|
||||
macros::{derive_free, wrap},
|
||||
mem::heap_remove,
|
||||
};
|
||||
use servicepoint::{Header, Packet, UdpSocketExt};
|
||||
|
@ -12,7 +12,9 @@ use std::{
|
|||
|
||||
derive_free!(UdpSocket);
|
||||
|
||||
wrap_functions!(associate UdpSocket;
|
||||
wrap! {
|
||||
UdpSocket {
|
||||
functions:
|
||||
/// Creates a new instance of [UdpSocket].
|
||||
///
|
||||
/// returns: NULL if connection fails, or connected instance
|
||||
|
@ -46,9 +48,7 @@ wrap_functions!(associate UdpSocket;
|
|||
let addr = SocketAddrV4::new(Ipv4Addr::from([ip1, ip2, ip3, ip4]), port);
|
||||
UdpSocket::bind_connect(addr)
|
||||
};
|
||||
);
|
||||
|
||||
wrap_methods! {UdpSocket;
|
||||
methods:
|
||||
/// Sends a [Packet] to the display using the [UdpSocket].
|
||||
///
|
||||
/// The passed `packet` gets consumed.
|
||||
|
@ -105,6 +105,7 @@ wrap_methods! {UdpSocket;
|
|||
};
|
||||
udp_connection.send(&Vec::from(packet)).is_ok()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
mod _hidden {
|
||||
|
|
Loading…
Reference in a new issue