Update README.md

This commit is contained in:
jasonwitty 2025-09-09 02:53:50 -07:00 committed by GitHub
parent 49164da105
commit 5f2777cdb2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -143,71 +143,3 @@ async function run() {
run(); run();
``` ```
## Benefits of This Approach
1. **Type Safety**: All socktop types work identically in WASM
2. **Validation**: Configuration validation happens in Rust
3. **Maintainability**: Share types between native and WASM code
4. **Performance**: Rust types compile to efficient WASM
5. **Future Proof**: Updates to socktop types automatically work in WASM
## Real-World Usage
For production WASM applications:
1. Use this pattern to create a WASM module that exports configuration and serialization functions
2. Handle WebSocket connections in JavaScript using browser APIs
3. Use the exported functions for type-safe message creation and parsing
4. Leverage socktop's structured error handling for robust applications
- **No TLS dependencies**: Completely avoids rustls/TLS
- **No tokio/mio**: Uses only WASM-compatible dependencies
### ❌ WASM Limitations
- **No native networking**: `tokio-tungstenite` doesn't work in WASM
- **No TLS support**: rustls is not WASM-compatible
- **No file system**: Certificate loading not available
## Architecture for WASM Users
```
WASM Application
├── Use socktop_connector types (✅ this test proves it works)
├── Use browser WebSocket API for networking
└── Handle serialization with socktop message format
```
## Quick Start
1. **Build the WASM package**:
```bash
cd socktop_wasm_test
wasm-pack build --target web --out-dir pkg
```
2. **Start local server**:
```bash
basic-http-server .
```
3. **Open browser** to `http://localhost:8000` and click "Run WASM Test"
## Success Criteria
- ✅ WASM builds without any networking dependencies
- ✅ Core types compile and serialize properly
- ✅ Configuration API works for WebSocket setup
- ✅ No rustls/TLS/tokio/mio dependencies
## Real-World WASM Usage
WASM users should:
1. **Use these types** for message structure compatibility
2. **Use browser WebSocket** for actual connections:
```javascript
const ws = new WebSocket('ws://localhost:3000/ws');
ws.send(JSON.stringify({ request: 'Metrics' }));
```
3. **Handle responses** using the same serialization format
This test proves `socktop_connector`'s **types and patterns** work in WASM, even though the networking must be handled differently.