From e823ecef925737d319fc0854338f152d5fc0414d Mon Sep 17 00:00:00 2001
From: scratchyone <scratchywon@gmail.com>
Date: Wed, 6 Jan 2021 11:15:21 -0500
Subject: [PATCH] Improve compilation errors when compiling to incompatible
 targets

---
 Cargo.toml | 2 +-
 src/lib.rs | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/Cargo.toml b/Cargo.toml
index 7b929ec..7ad8ed3 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "wasm-sockets"
-version = "0.1.0"
+version = "0.2.0"
 authors = ["scratchyone <scratchywon@gmail.com>"]
 edition = "2018"
 license = "MIT"
diff --git a/src/lib.rs b/src/lib.rs
index 3bf83c5..01f781f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -96,6 +96,9 @@ use wasm_bindgen::prelude::*;
 use wasm_bindgen::JsCast;
 use web_sys::{ErrorEvent, MessageEvent, WebSocket};
 
+#[cfg(not(target_arch = "wasm32"))]
+compile_error!("wasm-sockets can only compile to WASM targets");
+
 #[derive(Debug, Clone, PartialEq)]
 pub enum ConnectionStatus {
     /// Connecting to a server
@@ -116,6 +119,7 @@ pub enum Message {
     /// A binary message
     Binary(Vec<u8>),
 }
+#[cfg(target_arch = "wasm32")]
 pub struct PollingClient {
     /// The URL this client is connected to
     pub url: String,
@@ -125,6 +129,7 @@ pub struct PollingClient {
     pub status: Rc<RefCell<ConnectionStatus>>,
     data: Rc<RefCell<Vec<Message>>>,
 }
+#[cfg(target_arch = "wasm32")]
 // TODO: Replace unwraps and JsValue with custom error type
 impl PollingClient {
     /// Create a new PollingClient and connect to a WebSocket URL
-- 
GitLab