update servicepoint library
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Rust / build (pull_request) Successful in 1m59s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Rust / build (pull_request) Successful in 1m59s
				
			This commit is contained in:
		
							parent
							
								
									1169d9f1d2
								
							
						
					
					
						commit
						022106e2db
					
				
					 8 changed files with 116 additions and 141 deletions
				
			
		
							
								
								
									
										89
									
								
								Cargo.lock
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										89
									
								
								Cargo.lock
									
										
									
										generated
									
									
									
								
							|  | @ -209,9 +209,9 @@ checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" | |||
| 
 | ||||
| [[package]] | ||||
| name = "goblin" | ||||
| version = "0.6.1" | ||||
| version = "0.8.2" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "0d6b4de4a8eb6c46a8c77e1d3be942cb9a8bf073c22374578e5ba4b08ed0ff68" | ||||
| checksum = "1b363a30c165f666402fe6a3024d3bec7ebc898f96a4a23bd1c99f8dbf3f4f47" | ||||
| dependencies = [ | ||||
|  "log", | ||||
|  "plain", | ||||
|  | @ -220,9 +220,9 @@ dependencies = [ | |||
| 
 | ||||
| [[package]] | ||||
| name = "heck" | ||||
| version = "0.4.1" | ||||
| version = "0.5.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" | ||||
| checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "itoa" | ||||
|  | @ -304,12 +304,6 @@ version = "1.20.2" | |||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "oneshot-uniffi" | ||||
| version = "0.1.6" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "6c548d5c78976f6955d72d0ced18c48ca07030f7a1d4024529fedd7c1c01b29c" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "paste" | ||||
| version = "1.0.15" | ||||
|  | @ -370,18 +364,18 @@ checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" | |||
| 
 | ||||
| [[package]] | ||||
| name = "scroll" | ||||
| version = "0.11.0" | ||||
| version = "0.12.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "04c565b551bafbef4157586fa379538366e4385d42082f255bfd96e4fe8519da" | ||||
| checksum = "6ab8598aa408498679922eff7fa985c25d58a90771bd6be794434c5277eab1a6" | ||||
| dependencies = [ | ||||
|  "scroll_derive", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "scroll_derive" | ||||
| version = "0.11.1" | ||||
| version = "0.12.1" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "1db149f81d46d2deba7cd3c50772474707729550221e69588478ebf9ada425ae" | ||||
| checksum = "1783eabc414609e28a5ba76aee5ddd52199f7107a0b24c2e9746a1ecc34a683d" | ||||
| dependencies = [ | ||||
|  "proc-macro2", | ||||
|  "quote", | ||||
|  | @ -431,9 +425,9 @@ dependencies = [ | |||
| 
 | ||||
| [[package]] | ||||
| name = "servicepoint" | ||||
| version = "0.13.1" | ||||
| version = "0.14.1" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "93b52049be55a15fe37c13249d7f96aa8a5de56e1a41838e74a822ee8316a0c4" | ||||
| checksum = "f6bd5cfa49c73aeecb344680ffbf697abf73e0563a441b93b9723ae43867500f" | ||||
| dependencies = [ | ||||
|  "bitvec", | ||||
|  "bzip2", | ||||
|  | @ -466,6 +460,12 @@ version = "0.3.11" | |||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "smawk" | ||||
| version = "0.3.2" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "static_assertions" | ||||
| version = "1.1.0" | ||||
|  | @ -489,6 +489,15 @@ version = "1.0.1" | |||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "textwrap" | ||||
| version = "0.16.2" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "c13547615a44dc9c452a8a534638acdf07120d4b6847c8178705da06306a3057" | ||||
| dependencies = [ | ||||
|  "smawk", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "thiserror" | ||||
| version = "1.0.69" | ||||
|  | @ -552,11 +561,13 @@ checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" | |||
| 
 | ||||
| [[package]] | ||||
| name = "uniffi" | ||||
| version = "0.25.3" | ||||
| version = "0.28.3" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "21345172d31092fd48c47fd56c53d4ae9e41c4b1f559fb8c38c1ab1685fd919f" | ||||
| checksum = "4cb08c58c7ed7033150132febe696bef553f891b1ede57424b40d87a89e3c170" | ||||
| dependencies = [ | ||||
|  "anyhow", | ||||
|  "cargo_metadata", | ||||
|  "uniffi_bindgen", | ||||
|  "uniffi_build", | ||||
|  "uniffi_core", | ||||
|  "uniffi_macros", | ||||
|  | @ -564,9 +575,9 @@ dependencies = [ | |||
| 
 | ||||
| [[package]] | ||||
| name = "uniffi_bindgen" | ||||
| version = "0.25.3" | ||||
| version = "0.28.3" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "fd992f2929a053829d5875af1eff2ee3d7a7001cb3b9a46cc7895f2caede6940" | ||||
| checksum = "cade167af943e189a55020eda2c314681e223f1e42aca7c4e52614c2b627698f" | ||||
| dependencies = [ | ||||
|  "anyhow", | ||||
|  "askama", | ||||
|  | @ -579,17 +590,17 @@ dependencies = [ | |||
|  "once_cell", | ||||
|  "paste", | ||||
|  "serde", | ||||
|  "textwrap", | ||||
|  "toml", | ||||
|  "uniffi_meta", | ||||
|  "uniffi_testing", | ||||
|  "uniffi_udl", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "uniffi_build" | ||||
| version = "0.25.3" | ||||
| version = "0.28.3" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "001964dd3682d600084b3aaf75acf9c3426699bc27b65e96bb32d175a31c74e9" | ||||
| checksum = "4c7cf32576e08104b7dc2a6a5d815f37616e66c6866c2a639fe16e6d2286b75b" | ||||
| dependencies = [ | ||||
|  "anyhow", | ||||
|  "camino", | ||||
|  | @ -598,9 +609,9 @@ dependencies = [ | |||
| 
 | ||||
| [[package]] | ||||
| name = "uniffi_checksum_derive" | ||||
| version = "0.25.3" | ||||
| version = "0.28.3" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "55137c122f712d9330fd985d66fa61bdc381752e89c35708c13ce63049a3002c" | ||||
| checksum = "802d2051a700e3ec894c79f80d2705b69d85844dafbbe5d1a92776f8f48b563a" | ||||
| dependencies = [ | ||||
|  "quote", | ||||
|  "syn", | ||||
|  | @ -608,25 +619,23 @@ dependencies = [ | |||
| 
 | ||||
| [[package]] | ||||
| name = "uniffi_core" | ||||
| version = "0.25.3" | ||||
| version = "0.28.3" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "6121a127a3af1665cd90d12dd2b3683c2643c5103281d0fed5838324ca1fad5b" | ||||
| checksum = "bc7687007d2546c454d8ae609b105daceb88175477dac280707ad6d95bcd6f1f" | ||||
| dependencies = [ | ||||
|  "anyhow", | ||||
|  "bytes", | ||||
|  "camino", | ||||
|  "log", | ||||
|  "once_cell", | ||||
|  "oneshot-uniffi", | ||||
|  "paste", | ||||
|  "static_assertions", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "uniffi_macros" | ||||
| version = "0.25.3" | ||||
| version = "0.28.3" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "11cf7a58f101fcedafa5b77ea037999b88748607f0ef3a33eaa0efc5392e92e4" | ||||
| checksum = "12c65a5b12ec544ef136693af8759fb9d11aefce740fb76916721e876639033b" | ||||
| dependencies = [ | ||||
|  "bincode", | ||||
|  "camino", | ||||
|  | @ -637,15 +646,14 @@ dependencies = [ | |||
|  "serde", | ||||
|  "syn", | ||||
|  "toml", | ||||
|  "uniffi_build", | ||||
|  "uniffi_meta", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "uniffi_meta" | ||||
| version = "0.25.3" | ||||
| version = "0.28.3" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "71dc8573a7b1ac4b71643d6da34888273ebfc03440c525121f1b3634ad3417a2" | ||||
| checksum = "4a74ed96c26882dac1ca9b93ca23c827e284bacbd7ec23c6f0b0372f747d59e4" | ||||
| dependencies = [ | ||||
|  "anyhow", | ||||
|  "bytes", | ||||
|  | @ -655,9 +663,9 @@ dependencies = [ | |||
| 
 | ||||
| [[package]] | ||||
| name = "uniffi_testing" | ||||
| version = "0.25.3" | ||||
| version = "0.28.3" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "118448debffcb676ddbe8c5305fb933ab7e0123753e659a71dc4a693f8d9f23c" | ||||
| checksum = "6a6f984f0781f892cc864a62c3a5c60361b1ccbd68e538e6c9fbced5d82268ac" | ||||
| dependencies = [ | ||||
|  "anyhow", | ||||
|  "camino", | ||||
|  | @ -668,11 +676,12 @@ dependencies = [ | |||
| 
 | ||||
| [[package]] | ||||
| name = "uniffi_udl" | ||||
| version = "0.25.3" | ||||
| version = "0.28.3" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "889edb7109c6078abe0e53e9b4070cf74a6b3468d141bdf5ef1bd4d1dc24a1c3" | ||||
| checksum = "037820a4cfc4422db1eaa82f291a3863c92c7d1789dc513489c36223f9b4cdfc" | ||||
| dependencies = [ | ||||
|  "anyhow", | ||||
|  "textwrap", | ||||
|  "uniffi_meta", | ||||
|  "uniffi_testing", | ||||
|  "weedle2", | ||||
|  | @ -686,9 +695,9 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" | |||
| 
 | ||||
| [[package]] | ||||
| name = "weedle2" | ||||
| version = "4.0.0" | ||||
| version = "5.0.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "2e79c5206e1f43a2306fd64bdb95025ee4228960f2e6c5a8b173f3caaf807741" | ||||
| checksum = "998d2c24ec099a87daf9467808859f9d82b61f1d9c9701251aea037f514eae0e" | ||||
| dependencies = [ | ||||
|  "nom", | ||||
| ] | ||||
|  |  | |||
|  | @ -14,14 +14,14 @@ keywords = ["cccb", "cccb-servicepoint", "uniffi"] | |||
| crate-type = ["cdylib"] | ||||
| 
 | ||||
| [build-dependencies] | ||||
| uniffi = { version = "0.25.3", features = ["build"] } | ||||
| uniffi = { version = "0.28.3", features = ["build"] } | ||||
| 
 | ||||
| [dependencies] | ||||
| uniffi = { version = "0.25.3" } | ||||
| uniffi = { version = "0.28.3" } | ||||
| thiserror = "2.0" | ||||
| 
 | ||||
| [dependencies.servicepoint] | ||||
| version = "0.13.1" | ||||
| version = "0.14.1" | ||||
| features = ["all_compressions"] | ||||
| 
 | ||||
| [package.metadata.docs.rs] | ||||
|  |  | |||
|  | @ -21,7 +21,7 @@ impl Bitmap { | |||
|         Self::internal_new(servicepoint::Bitmap::new( | ||||
|             width as usize, | ||||
|             height as usize, | ||||
|         )) | ||||
|         ).unwrap()) | ||||
|     } | ||||
| 
 | ||||
|     #[uniffi::constructor] | ||||
|  | @ -35,7 +35,7 @@ impl Bitmap { | |||
|             width as usize, | ||||
|             height as usize, | ||||
|             &data, | ||||
|         )) | ||||
|         ).unwrap()) | ||||
|     } | ||||
| 
 | ||||
|     #[uniffi::constructor] | ||||
|  |  | |||
|  | @ -2,11 +2,11 @@ use std::sync::{Arc, RwLock}; | |||
| 
 | ||||
| #[derive(uniffi::Object)] | ||||
| pub struct BitVec { | ||||
|     pub(crate) actual: RwLock<servicepoint::BitVec>, | ||||
|     pub(crate) actual: RwLock<servicepoint::DisplayBitVec>, | ||||
| } | ||||
| 
 | ||||
| impl BitVec { | ||||
|     fn internal_new(actual: servicepoint::BitVec) -> Arc<Self> { | ||||
|     fn internal_new(actual: servicepoint::DisplayBitVec) -> Arc<Self> { | ||||
|         Arc::new(Self { | ||||
|             actual: RwLock::new(actual), | ||||
|         }) | ||||
|  | @ -17,11 +17,11 @@ impl BitVec { | |||
| impl BitVec { | ||||
|     #[uniffi::constructor] | ||||
|     pub fn new(size: u64) -> Arc<Self> { | ||||
|         Self::internal_new(servicepoint::BitVec::repeat(false, size as usize)) | ||||
|         Self::internal_new(servicepoint::DisplayBitVec::repeat(false, size as usize)) | ||||
|     } | ||||
|     #[uniffi::constructor] | ||||
|     pub fn load(data: Vec<u8>) -> Arc<Self> { | ||||
|         Self::internal_new(servicepoint::BitVec::from_slice(&data)) | ||||
|         Self::internal_new(servicepoint::DisplayBitVec::from_slice(&data)) | ||||
|     } | ||||
| 
 | ||||
|     #[uniffi::constructor] | ||||
|  |  | |||
|  | @ -30,7 +30,7 @@ impl BrightnessGrid { | |||
|             width as usize, | ||||
|             height as usize, | ||||
|             &data, | ||||
|         )) | ||||
|         ).unwrap()) | ||||
|     } | ||||
| 
 | ||||
|     #[uniffi::constructor] | ||||
|  |  | |||
							
								
								
									
										114
									
								
								src/command.rs
									
										
									
									
									
								
							
							
						
						
									
										114
									
								
								src/command.rs
									
										
									
									
									
								
							|  | @ -5,16 +5,16 @@ use crate::char_grid::CharGrid; | |||
| use crate::compression_code::CompressionCode; | ||||
| use crate::cp437_grid::Cp437Grid; | ||||
| use crate::errors::ServicePointError; | ||||
| use servicepoint::Origin; | ||||
| use servicepoint::{BitVecCommand, BrightnessGridCommand, CharGridCommand, ClearCommand, Cp437GridCommand, FadeOutCommand, GlobalBrightnessCommand, HardResetCommand, Origin}; | ||||
| use std::sync::Arc; | ||||
| 
 | ||||
| #[derive(uniffi::Object)] | ||||
| pub struct Command { | ||||
|     pub(crate) actual: servicepoint::Command, | ||||
|     pub(crate) actual: servicepoint::TypedCommand, | ||||
| } | ||||
| 
 | ||||
| impl Command { | ||||
|     fn internal_new(actual: servicepoint::Command) -> Arc<Command> { | ||||
|     fn internal_new(actual: servicepoint::TypedCommand) -> Arc<Command> { | ||||
|         Arc::new(Command { actual }) | ||||
|     } | ||||
| } | ||||
|  | @ -23,27 +23,28 @@ impl Command { | |||
| impl Command { | ||||
|     #[uniffi::constructor] | ||||
|     pub fn clear() -> Arc<Self> { | ||||
|         Self::internal_new(servicepoint::Command::Clear) | ||||
|         Self::internal_new(ClearCommand.into()) | ||||
|     } | ||||
| 
 | ||||
|     #[uniffi::constructor] | ||||
|     pub fn brightness(brightness: u8) -> Result<Arc<Self>, ServicePointError> { | ||||
|         servicepoint::Brightness::try_from(brightness) | ||||
|             .map_err(move |value| ServicePointError::InvalidBrightness { | ||||
|                 value, | ||||
|                 value | ||||
|             }) | ||||
|             .map(servicepoint::Command::Brightness) | ||||
|             .map(GlobalBrightnessCommand::from) | ||||
|             .map(servicepoint::TypedCommand::Brightness) | ||||
|             .map(Self::internal_new) | ||||
|     } | ||||
| 
 | ||||
|     #[uniffi::constructor] | ||||
|     pub fn fade_out() -> Arc<Self> { | ||||
|         Self::internal_new(servicepoint::Command::FadeOut) | ||||
|         Self::internal_new(FadeOutCommand.into()) | ||||
|     } | ||||
| 
 | ||||
|     #[uniffi::constructor] | ||||
|     pub fn hard_reset() -> Arc<Self> { | ||||
|         Self::internal_new(servicepoint::Command::HardReset) | ||||
|         Self::internal_new(HardResetCommand.into()) | ||||
|     } | ||||
| 
 | ||||
|     #[uniffi::constructor] | ||||
|  | @ -55,13 +56,13 @@ impl Command { | |||
|     ) -> Arc<Self> { | ||||
|         let origin = Origin::new(offset_x as usize, offset_y as usize); | ||||
|         let bitmap = bitmap.actual.read().unwrap().clone(); | ||||
|         let actual = servicepoint::Command::BitmapLinearWin( | ||||
|         let actual = servicepoint::BitmapCommand { | ||||
|             origin, | ||||
|             bitmap, | ||||
|             servicepoint::CompressionCode::try_from(compression as u16) | ||||
|             compression: servicepoint::CompressionCode::try_from(compression as u16) | ||||
|                 .unwrap(), | ||||
|         ); | ||||
|         Self::internal_new(actual) | ||||
|         }; | ||||
|         Self::internal_new(actual.into()) | ||||
|     } | ||||
| 
 | ||||
|     #[uniffi::constructor] | ||||
|  | @ -72,72 +73,31 @@ impl Command { | |||
|     ) -> Arc<Self> { | ||||
|         let origin = Origin::new(offset_x as usize, offset_y as usize); | ||||
|         let grid = grid.actual.read().unwrap().clone(); | ||||
|         let actual = servicepoint::Command::CharBrightness(origin, grid); | ||||
|         Self::internal_new(actual) | ||||
|         let actual = BrightnessGridCommand {origin, grid}; | ||||
|         Self::internal_new(actual.into()) | ||||
|     } | ||||
| 
 | ||||
|     #[uniffi::constructor] | ||||
|     pub fn bitmap_linear( | ||||
|         offset: u64, | ||||
|         bitmap: &Arc<BitVec>, | ||||
|         bitvec: &Arc<BitVec>, | ||||
|         compression: CompressionCode, | ||||
|         operation: BinaryOperation, | ||||
|     ) -> Arc<Self> { | ||||
|         let bitmap = bitmap.actual.read().unwrap().clone(); | ||||
|         let actual = servicepoint::Command::BitmapLinear( | ||||
|             offset as usize, | ||||
|             bitmap, | ||||
|             servicepoint::CompressionCode::try_from(compression as u16) | ||||
|         let bitvec = bitvec.actual.read().unwrap().clone(); | ||||
|         let actual = BitVecCommand { | ||||
|             offset: offset as usize, | ||||
|             bitvec, | ||||
|             compression: servicepoint::CompressionCode::try_from(compression as u16) | ||||
|             .unwrap(), | ||||
|         ); | ||||
|         Self::internal_new(actual) | ||||
|             operation: match operation { | ||||
|                 BinaryOperation::Overwrite => servicepoint::BinaryOperation::Overwrite, | ||||
|                 BinaryOperation::And => servicepoint::BinaryOperation::And, | ||||
|                 BinaryOperation::Or => servicepoint::BinaryOperation::Or, | ||||
|                 BinaryOperation::Xor => servicepoint::BinaryOperation::Xor, | ||||
|             } | ||||
| 
 | ||||
|     #[uniffi::constructor] | ||||
|     pub fn bitmap_linear_and( | ||||
|         offset: u64, | ||||
|         bitmap: &Arc<BitVec>, | ||||
|         compression: CompressionCode, | ||||
|     ) -> Arc<Self> { | ||||
|         let bitmap = bitmap.actual.read().unwrap().clone(); | ||||
|         let actual = servicepoint::Command::BitmapLinearAnd( | ||||
|             offset as usize, | ||||
|             bitmap, | ||||
|             servicepoint::CompressionCode::try_from(compression as u16) | ||||
|                 .unwrap(), | ||||
|         ); | ||||
|         Self::internal_new(actual) | ||||
|     } | ||||
| 
 | ||||
|     #[uniffi::constructor] | ||||
|     pub fn bitmap_linear_or( | ||||
|         offset: u64, | ||||
|         bitmap: &Arc<BitVec>, | ||||
|         compression: CompressionCode, | ||||
|     ) -> Arc<Self> { | ||||
|         let bitmap = bitmap.actual.read().unwrap().clone(); | ||||
|         let actual = servicepoint::Command::BitmapLinearOr( | ||||
|             offset as usize, | ||||
|             bitmap, | ||||
|             servicepoint::CompressionCode::try_from(compression as u16) | ||||
|                 .unwrap(), | ||||
|         ); | ||||
|         Self::internal_new(actual) | ||||
|     } | ||||
| 
 | ||||
|     #[uniffi::constructor] | ||||
|     pub fn bitmap_linear_xor( | ||||
|         offset: u64, | ||||
|         bitmap: &Arc<BitVec>, | ||||
|         compression: CompressionCode, | ||||
|     ) -> Arc<Self> { | ||||
|         let bitmap = bitmap.actual.read().unwrap().clone(); | ||||
|         let actual = servicepoint::Command::BitmapLinearXor( | ||||
|             offset as usize, | ||||
|             bitmap, | ||||
|             servicepoint::CompressionCode::try_from(compression as u16) | ||||
|                 .unwrap(), | ||||
|         ); | ||||
|         Self::internal_new(actual) | ||||
|         }; | ||||
|         Self::internal_new(actual.into()) | ||||
|     } | ||||
| 
 | ||||
|     #[uniffi::constructor] | ||||
|  | @ -148,8 +108,8 @@ impl Command { | |||
|     ) -> Arc<Self> { | ||||
|         let origin = Origin::new(offset_x as usize, offset_y as usize); | ||||
|         let grid = grid.actual.read().unwrap().clone(); | ||||
|         let actual = servicepoint::Command::Cp437Data(origin, grid); | ||||
|         Self::internal_new(actual) | ||||
|         let actual = Cp437GridCommand {origin, grid}; | ||||
|         Self::internal_new(actual.into()) | ||||
|     } | ||||
| 
 | ||||
|     #[uniffi::constructor] | ||||
|  | @ -160,8 +120,8 @@ impl Command { | |||
|     ) -> Arc<Self> { | ||||
|         let origin = Origin::new(offset_x as usize, offset_y as usize); | ||||
|         let grid = grid.actual.read().unwrap().clone(); | ||||
|         let actual = servicepoint::Command::Utf8Data(origin, grid); | ||||
|         Self::internal_new(actual) | ||||
|         let actual = CharGridCommand {origin, grid}; | ||||
|         Self::internal_new(actual.into()) | ||||
|     } | ||||
| 
 | ||||
|     #[uniffi::constructor] | ||||
|  | @ -173,3 +133,11 @@ impl Command { | |||
|         self.actual == other.actual | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| #[derive(uniffi::Enum)] | ||||
| pub enum BinaryOperation { | ||||
|     Overwrite, | ||||
|     And, | ||||
|     Or, | ||||
|     Xor, | ||||
| } | ||||
|  |  | |||
|  | @ -1,35 +1,33 @@ | |||
| use std::sync::Arc; | ||||
| 
 | ||||
| use crate::command::Command; | ||||
| use crate::errors::ServicePointError; | ||||
| use std::{ | ||||
|     net::UdpSocket, | ||||
|     sync::Arc | ||||
| }; | ||||
| use servicepoint::UdpSocketExt; | ||||
| use crate::{ | ||||
|     command::Command, | ||||
|     errors::ServicePointError | ||||
| }; | ||||
| 
 | ||||
| #[derive(uniffi::Object)] | ||||
| pub struct Connection { | ||||
|     actual: servicepoint::Connection, | ||||
|     actual: UdpSocket, | ||||
| } | ||||
| 
 | ||||
| #[uniffi::export] | ||||
| impl Connection { | ||||
|     #[uniffi::constructor] | ||||
|     pub fn new(host: String) -> Result<Arc<Self>, ServicePointError> { | ||||
|         servicepoint::Connection::open(host) | ||||
|         UdpSocket::bind_connect(host) | ||||
|             .map(|actual| Arc::new(Connection { actual })) | ||||
|             .map_err(|err| ServicePointError::IoError { | ||||
|                 error: err.to_string(), | ||||
|             }) | ||||
|     } | ||||
| 
 | ||||
|     #[uniffi::constructor] | ||||
|     pub fn new_fake() -> Arc<Self> { | ||||
|         Arc::new(Self { | ||||
|             actual: servicepoint::Connection::Fake, | ||||
|         }) | ||||
|     } | ||||
| 
 | ||||
|     pub fn send(&self, command: Arc<Command>) -> Result<(), ServicePointError> { | ||||
|         self.actual.send(command.actual.clone()).map_err(|err| { | ||||
|         self.actual.send_command(command.actual.clone()).ok_or_else(|| { | ||||
|             ServicePointError::IoError { | ||||
|                 error: format!("{err:?}"), | ||||
|                 error: "send failed".to_string(), | ||||
|             } | ||||
|         }) | ||||
|     } | ||||
|  |  | |||
|  | @ -31,7 +31,7 @@ impl Cp437Grid { | |||
|             width as usize, | ||||
|             height as usize, | ||||
|             &data, | ||||
|         )) | ||||
|         ).unwrap()) | ||||
|     } | ||||
| 
 | ||||
|     #[uniffi::constructor] | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Vinzenz Schroeter
						Vinzenz Schroeter