formatting changes, mostly resulting from the shorter name
This commit is contained in:
		
							parent
							
								
									78a4d4dbcf
								
							
						
					
					
						commit
						a08d439366
					
				
					 9 changed files with 75 additions and 70 deletions
				
			
		|  | @ -1,7 +1,7 @@ | |||
| //! Example for how to use the WebSocket connection
 | ||||
| 
 | ||||
| use servicepoint::{ | ||||
|     Command, CompressionCode, Connection, Grid, Origin, Bitmap, | ||||
|     Bitmap, Command, CompressionCode, Connection, Grid, Origin, | ||||
| }; | ||||
| 
 | ||||
| fn main() { | ||||
|  |  | |||
|  | @ -197,7 +197,7 @@ impl<'t> Iterator for IterRows<'t> { | |||
| 
 | ||||
| #[cfg(test)] | ||||
| mod tests { | ||||
|     use crate::{DataRef, Grid, Bitmap}; | ||||
|     use crate::{Bitmap, DataRef, Grid}; | ||||
| 
 | ||||
|     #[test] | ||||
|     fn fill() { | ||||
|  |  | |||
|  | @ -4,7 +4,7 @@ use crate::{ | |||
|     command_code::CommandCode, | ||||
|     compression::into_decompressed, | ||||
|     packet::{Header, Packet}, | ||||
|     Brightness, BrightnessGrid, CompressionCode, Cp437Grid, Origin, Bitmap, | ||||
|     Bitmap, Brightness, BrightnessGrid, CompressionCode, Cp437Grid, Origin, | ||||
|     Pixels, PrimitiveGrid, SpBitVec, Tiles, TILE_SIZE, | ||||
| }; | ||||
| 
 | ||||
|  | @ -495,8 +495,8 @@ mod tests { | |||
|         command_code::CommandCode, | ||||
|         origin::Pixels, | ||||
|         packet::{Header, Packet}, | ||||
|         Brightness, BrightnessGrid, Command, CompressionCode, Origin, | ||||
|         Bitmap, PrimitiveGrid, | ||||
|         Bitmap, Brightness, BrightnessGrid, Command, CompressionCode, Origin, | ||||
|         PrimitiveGrid, | ||||
|     }; | ||||
| 
 | ||||
|     fn round_trip(original: Command) { | ||||
|  | @ -903,6 +903,7 @@ mod tests { | |||
|             Origin::new(1, 0) + Origin::new(3, 2) | ||||
|         ); | ||||
|     } | ||||
| 
 | ||||
|     #[test] | ||||
|     fn packet_into_char_brightness_invalid() { | ||||
|         let grid = BrightnessGrid::new(2, 2); | ||||
|  |  | |||
|  | @ -40,6 +40,7 @@ use std::time::Duration; | |||
| pub use bitvec; | ||||
| use bitvec::prelude::{BitVec, Msb0}; | ||||
| 
 | ||||
| pub use crate::bitmap::Bitmap; | ||||
| pub use crate::brightness::{Brightness, BrightnessGrid}; | ||||
| pub use crate::command::{Command, Offset}; | ||||
| pub use crate::compression_code::CompressionCode; | ||||
|  | @ -48,11 +49,11 @@ pub use crate::cp437::{CharGrid, Cp437Grid}; | |||
| pub use crate::data_ref::DataRef; | ||||
| pub use crate::grid::Grid; | ||||
| pub use crate::origin::{Origin, Pixels, Tiles}; | ||||
| pub use crate::bitmap::Bitmap; | ||||
| pub use crate::primitive_grid::PrimitiveGrid; | ||||
| 
 | ||||
| type SpBitVec = BitVec<u8, Msb0>; | ||||
| 
 | ||||
| mod bitmap; | ||||
| mod brightness; | ||||
| mod command; | ||||
| mod command_code; | ||||
|  | @ -64,7 +65,6 @@ mod data_ref; | |||
| mod grid; | ||||
| mod origin; | ||||
| pub mod packet; | ||||
| mod bitmap; | ||||
| mod primitive_grid; | ||||
| 
 | ||||
| /// size of a single tile in one dimension
 | ||||
|  |  | |||
|  | @ -27,8 +27,8 @@ use std::mem::size_of; | |||
| 
 | ||||
| use crate::compression::into_compressed; | ||||
| use crate::{ | ||||
|     command_code::CommandCode, Command, CompressionCode, Grid, Offset, Origin, | ||||
|     Bitmap, Pixels, Tiles, TILE_SIZE, | ||||
|     command_code::CommandCode, Bitmap, Command, CompressionCode, Grid, Offset, | ||||
|     Origin, Pixels, Tiles, TILE_SIZE, | ||||
| }; | ||||
| 
 | ||||
| /// A raw header.
 | ||||
|  |  | |||
|  | @ -210,10 +210,7 @@ pub unsafe extern "C" fn sp_bitmap_set( | |||
| /// - `bitmap` points to a valid [SPBitmap]
 | ||||
| /// - `bitmap` is not written to or read from concurrently
 | ||||
| #[no_mangle] | ||||
| pub unsafe extern "C" fn sp_bitmap_fill( | ||||
|     bitmap: *mut SPBitmap, | ||||
|     value: bool, | ||||
| ) { | ||||
| pub unsafe extern "C" fn sp_bitmap_fill(bitmap: *mut SPBitmap, value: bool) { | ||||
|     assert!(!bitmap.is_null()); | ||||
|     (*bitmap).0.fill(value); | ||||
| } | ||||
|  | @ -234,9 +231,7 @@ pub unsafe extern "C" fn sp_bitmap_fill( | |||
| ///
 | ||||
| /// - `bitmap` points to a valid [SPBitmap]
 | ||||
| #[no_mangle] | ||||
| pub unsafe extern "C" fn sp_bitmap_width( | ||||
|     bitmap: *const SPBitmap, | ||||
| ) -> usize { | ||||
| pub unsafe extern "C" fn sp_bitmap_width(bitmap: *const SPBitmap) -> usize { | ||||
|     assert!(!bitmap.is_null()); | ||||
|     (*bitmap).0.width() | ||||
| } | ||||
|  | @ -257,9 +252,7 @@ pub unsafe extern "C" fn sp_bitmap_width( | |||
| ///
 | ||||
| /// - `bitmap` points to a valid [SPBitmap]
 | ||||
| #[no_mangle] | ||||
| pub unsafe extern "C" fn sp_bitmap_height( | ||||
|     bitmap: *const SPBitmap, | ||||
| ) -> usize { | ||||
| pub unsafe extern "C" fn sp_bitmap_height(bitmap: *const SPBitmap) -> usize { | ||||
|     assert!(!bitmap.is_null()); | ||||
|     (*bitmap).0.height() | ||||
| } | ||||
|  |  | |||
|  | @ -7,8 +7,8 @@ use std::ptr::null_mut; | |||
| use servicepoint::{Brightness, Origin}; | ||||
| 
 | ||||
| use crate::{ | ||||
|     SPBitVec, SPBrightnessGrid, SPCompressionCode, SPCp437Grid, SPPacket, | ||||
|     SPBitmap, | ||||
|     SPBitVec, SPBitmap, SPBrightnessGrid, SPCompressionCode, SPCp437Grid, | ||||
|     SPPacket, | ||||
| }; | ||||
| 
 | ||||
| /// A low-level display command.
 | ||||
|  | @ -107,7 +107,8 @@ pub unsafe extern "C" fn sp_command_clone( | |||
| ///   by explicitly calling `sp_command_free`.
 | ||||
| #[no_mangle] | ||||
| pub unsafe extern "C" fn sp_command_clear() -> *mut SPCommand { | ||||
|     let result = Box::into_raw(Box::new(SPCommand(servicepoint::Command::Clear))); | ||||
|     let result = | ||||
|         Box::into_raw(Box::new(SPCommand(servicepoint::Command::Clear))); | ||||
|     assert!(!result.is_null()); | ||||
|     result | ||||
| } | ||||
|  | @ -126,7 +127,8 @@ pub unsafe extern "C" fn sp_command_clear() -> *mut SPCommand { | |||
| ///   by explicitly calling `sp_command_free`.
 | ||||
| #[no_mangle] | ||||
| pub unsafe extern "C" fn sp_command_hard_reset() -> *mut SPCommand { | ||||
|     let result = Box::into_raw(Box::new(SPCommand(servicepoint::Command::HardReset))); | ||||
|     let result = | ||||
|         Box::into_raw(Box::new(SPCommand(servicepoint::Command::HardReset))); | ||||
|     assert!(!result.is_null()); | ||||
|     result | ||||
| } | ||||
|  | @ -143,7 +145,8 @@ pub unsafe extern "C" fn sp_command_hard_reset() -> *mut SPCommand { | |||
| ///   by explicitly calling `sp_command_free`.
 | ||||
| #[no_mangle] | ||||
| pub unsafe extern "C" fn sp_command_fade_out() -> *mut SPCommand { | ||||
|     let result = Box::into_raw(Box::new(SPCommand(servicepoint::Command::FadeOut))); | ||||
|     let result = | ||||
|         Box::into_raw(Box::new(SPCommand(servicepoint::Command::FadeOut))); | ||||
|     assert!(!result.is_null()); | ||||
|     result | ||||
| } | ||||
|  | @ -168,9 +171,9 @@ pub unsafe extern "C" fn sp_command_brightness( | |||
| ) -> *mut SPCommand { | ||||
|     let brightness = | ||||
|         Brightness::try_from(brightness).expect("invalid brightness"); | ||||
|     let result = Box::into_raw(Box::new(SPCommand(servicepoint::Command::Brightness( | ||||
|         brightness, | ||||
|     )))); | ||||
|     let result = Box::into_raw(Box::new(SPCommand( | ||||
|         servicepoint::Command::Brightness(brightness), | ||||
|     ))); | ||||
|     assert!(!result.is_null()); | ||||
|     result | ||||
| } | ||||
|  | @ -201,10 +204,9 @@ pub unsafe extern "C" fn sp_command_char_brightness( | |||
| ) -> *mut SPCommand { | ||||
|     assert!(!grid.is_null()); | ||||
|     let byte_grid = *Box::from_raw(grid); | ||||
|     let result = Box::into_raw(Box::new(SPCommand(servicepoint::Command::CharBrightness( | ||||
|         Origin::new(x, y), | ||||
|         byte_grid.0, | ||||
|     )))); | ||||
|     let result = Box::into_raw(Box::new(SPCommand( | ||||
|         servicepoint::Command::CharBrightness(Origin::new(x, y), byte_grid.0), | ||||
|     ))); | ||||
|     assert!(!result.is_null()); | ||||
|     result | ||||
| } | ||||
|  | @ -242,11 +244,13 @@ pub unsafe extern "C" fn sp_command_bitmap_linear( | |||
| ) -> *mut SPCommand { | ||||
|     assert!(!bit_vec.is_null()); | ||||
|     let bit_vec = *Box::from_raw(bit_vec); | ||||
|     let result = Box::into_raw(Box::new(SPCommand(servicepoint::Command::BitmapLinear( | ||||
|     let result = Box::into_raw(Box::new(SPCommand( | ||||
|         servicepoint::Command::BitmapLinear( | ||||
|             offset, | ||||
|             bit_vec.into(), | ||||
|             compression.try_into().expect("invalid compression code"), | ||||
|     )))); | ||||
|         ), | ||||
|     ))); | ||||
|     assert!(!result.is_null()); | ||||
|     result | ||||
| } | ||||
|  | @ -284,11 +288,13 @@ pub unsafe extern "C" fn sp_command_bitmap_linear_and( | |||
| ) -> *mut SPCommand { | ||||
|     assert!(!bit_vec.is_null()); | ||||
|     let bit_vec = *Box::from_raw(bit_vec); | ||||
|     let result = Box::into_raw(Box::new(SPCommand(servicepoint::Command::BitmapLinearAnd( | ||||
|     let result = Box::into_raw(Box::new(SPCommand( | ||||
|         servicepoint::Command::BitmapLinearAnd( | ||||
|             offset, | ||||
|             bit_vec.into(), | ||||
|             compression.try_into().expect("invalid compression code"), | ||||
|     )))); | ||||
|         ), | ||||
|     ))); | ||||
|     assert!(!result.is_null()); | ||||
|     result | ||||
| } | ||||
|  | @ -326,11 +332,13 @@ pub unsafe extern "C" fn sp_command_bitmap_linear_or( | |||
| ) -> *mut SPCommand { | ||||
|     assert!(!bit_vec.is_null()); | ||||
|     let bit_vec = *Box::from_raw(bit_vec); | ||||
|     let result = Box::into_raw(Box::new(SPCommand(servicepoint::Command::BitmapLinearOr( | ||||
|     let result = Box::into_raw(Box::new(SPCommand( | ||||
|         servicepoint::Command::BitmapLinearOr( | ||||
|             offset, | ||||
|             bit_vec.into(), | ||||
|             compression.try_into().expect("invalid compression code"), | ||||
|     )))); | ||||
|         ), | ||||
|     ))); | ||||
|     assert!(!result.is_null()); | ||||
|     result | ||||
| } | ||||
|  | @ -368,11 +376,13 @@ pub unsafe extern "C" fn sp_command_bitmap_linear_xor( | |||
| ) -> *mut SPCommand { | ||||
|     assert!(!bit_vec.is_null()); | ||||
|     let bit_vec = *Box::from_raw(bit_vec); | ||||
|     let result = Box::into_raw(Box::new(SPCommand(servicepoint::Command::BitmapLinearXor( | ||||
|     let result = Box::into_raw(Box::new(SPCommand( | ||||
|         servicepoint::Command::BitmapLinearXor( | ||||
|             offset, | ||||
|             bit_vec.into(), | ||||
|             compression.try_into().expect("invalid compression code"), | ||||
|     )))); | ||||
|         ), | ||||
|     ))); | ||||
|     assert!(!result.is_null()); | ||||
|     result | ||||
| } | ||||
|  | @ -403,10 +413,9 @@ pub unsafe extern "C" fn sp_command_cp437_data( | |||
| ) -> *mut SPCommand { | ||||
|     assert!(!grid.is_null()); | ||||
|     let grid = *Box::from_raw(grid); | ||||
|     let result = Box::into_raw(Box::new(SPCommand(servicepoint::Command::Cp437Data( | ||||
|         Origin::new(x, y), | ||||
|         grid.0, | ||||
|     )))); | ||||
|     let result = Box::into_raw(Box::new(SPCommand( | ||||
|         servicepoint::Command::Cp437Data(Origin::new(x, y), grid.0), | ||||
|     ))); | ||||
|     assert!(!result.is_null()); | ||||
|     result | ||||
| } | ||||
|  | @ -440,13 +449,15 @@ pub unsafe extern "C" fn sp_command_bitmap_linear_win( | |||
| ) -> *mut SPCommand { | ||||
|     assert!(!bitmap.is_null()); | ||||
|     let byte_grid = (*Box::from_raw(bitmap)).0; | ||||
|     let result = Box::into_raw(Box::new(SPCommand(servicepoint::Command::BitmapLinearWin( | ||||
|     let result = Box::into_raw(Box::new(SPCommand( | ||||
|         servicepoint::Command::BitmapLinearWin( | ||||
|             Origin::new(x, y), | ||||
|             byte_grid, | ||||
|             compression_code | ||||
|                 .try_into() | ||||
|                 .expect("invalid compression code"), | ||||
|     )))); | ||||
|         ), | ||||
|     ))); | ||||
|     assert!(!result.is_null()); | ||||
|     result | ||||
| } | ||||
|  |  | |||
|  | @ -40,9 +40,9 @@ pub unsafe extern "C" fn sp_cp437_grid_new( | |||
|     width: usize, | ||||
|     height: usize, | ||||
| ) -> *mut SPCp437Grid { | ||||
|     let result = Box::into_raw(Box::new(SPCp437Grid(servicepoint::Cp437Grid::new( | ||||
|         width, height, | ||||
|     )))); | ||||
|     let result = Box::into_raw(Box::new(SPCp437Grid( | ||||
|         servicepoint::Cp437Grid::new(width, height), | ||||
|     ))); | ||||
|     assert!(!result.is_null()); | ||||
|     result | ||||
| } | ||||
|  | @ -73,9 +73,9 @@ pub unsafe extern "C" fn sp_cp437_grid_load( | |||
| ) -> *mut SPCp437Grid { | ||||
|     assert!(data.is_null()); | ||||
|     let data = std::slice::from_raw_parts(data, data_length); | ||||
|     let result = Box::into_raw(Box::new(SPCp437Grid(servicepoint::Cp437Grid::load( | ||||
|         width, height, data, | ||||
|     )))); | ||||
|     let result = Box::into_raw(Box::new(SPCp437Grid( | ||||
|         servicepoint::Cp437Grid::load(width, height, data), | ||||
|     ))); | ||||
|     assert!(!result.is_null()); | ||||
|     result | ||||
| } | ||||
|  |  | |||
|  | @ -26,6 +26,7 @@ | |||
| //! ```
 | ||||
| 
 | ||||
| pub use crate::bit_vec::*; | ||||
| pub use crate::bitmap::*; | ||||
| pub use crate::brightness_grid::*; | ||||
| pub use crate::byte_slice::*; | ||||
| pub use crate::command::*; | ||||
|  | @ -33,9 +34,9 @@ pub use crate::connection::*; | |||
| pub use crate::constants::*; | ||||
| pub use crate::cp437_grid::*; | ||||
| pub use crate::packet::*; | ||||
| pub use crate::bitmap::*; | ||||
| 
 | ||||
| mod bit_vec; | ||||
| mod bitmap; | ||||
| mod brightness_grid; | ||||
| mod byte_slice; | ||||
| mod command; | ||||
|  | @ -43,4 +44,3 @@ mod connection; | |||
| mod constants; | ||||
| mod cp437_grid; | ||||
| mod packet; | ||||
| mod bitmap; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Vinzenz Schroeter
						Vinzenz Schroeter