Skip to content
Snippets Groups Projects
Unverified Commit e823ecef authored by scratchyone's avatar scratchyone
Browse files

Improve compilation errors when compiling to incompatible targets

parent 4d1f2424
No related branches found
No related tags found
No related merge requests found
[package]
name = "wasm-sockets"
version = "0.1.0"
version = "0.2.0"
authors = ["scratchyone <scratchywon@gmail.com>"]
edition = "2018"
license = "MIT"
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment