Skip to content

Commit faa73b3

Browse files
authored
Merge pull request #28 from Nic-dorman/fix/binding-parity-improvements
Fix/binding parity improvements
2 parents f8267a7 + 8fdef22 commit faa73b3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+14281
-15
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,33 @@ For full documentation including async operations, memory management, and build
604604
- **Scratchpads**: Encrypted mutable data with versioning
605605
- **GraphEntry**: Graph-based data structures
606606

607+
## Platform Limitations
608+
609+
Some features have platform-specific limitations due to language or runtime constraints. Below are the known limitations and recommended workarounds.
610+
611+
### PHP
612+
613+
| Limitation | Explanation | Workaround |
614+
|------------|-------------|------------|
615+
| No async callbacks | PHP FFI cannot receive callbacks from Rust async functions. The FFI extension lacks the ability to create function pointers that Rust can call back into. | Use blocking wrapper functions (`*Sync` methods like `dataPutPublicSync()`) that internally use a shared Tokio runtime to execute async operations synchronously. |
616+
| No real-time streaming | PHP is request-based and not suited for long-lived connections. Each HTTP request runs to completion, making continuous data streams impractical. | Use `dataGetPublic()` to fetch complete data in a single request. For large files, implement chunked downloads at the application level by storing chunk addresses and fetching them sequentially. |
617+
| No event subscriptions | Cannot subscribe to network events due to the callback limitation and request-based execution model. | Poll for updates periodically if real-time awareness is needed. Consider using a message queue or webhook system for event-driven architectures. |
618+
619+
### Lua (LuaJIT)
620+
621+
| Limitation | Explanation | Workaround |
622+
|------------|-------------|------------|
623+
| No async callbacks | LuaJIT has thread-safety limitations with callbacks. Rust async operations require callbacks that would execute on different threads, which LuaJIT's FFI cannot safely handle. | Use the `async_helper` Rust library which provides blocking poll functions (`poll_pointer_sync`, `poll_rust_buffer_sync`, `poll_void_sync`) that bridge async Rust to synchronous Lua calls. |
624+
| Limited streaming | Memory constraints when handling large data. LuaJIT allocates all data in its managed heap, which can be problematic for multi-megabyte transfers. | Use file-based operations for large data. Stream directly to disk rather than loading into memory. Process data in chunks when possible. |
625+
626+
### Dart/Flutter (Mobile)
627+
628+
| Limitation | Explanation | Workaround |
629+
|------------|-------------|------------|
630+
| Mobile directory restrictions | iOS and Android enforce sandbox file system access. Apps cannot freely access arbitrary filesystem paths. | Use platform-specific document directories via the `path_provider` package (`getApplicationDocumentsDirectory()`, `getTemporaryDirectory()`). On Android, request `MANAGE_EXTERNAL_STORAGE` permission for broader access if absolutely required. |
631+
| Memory constraints | Mobile devices have limited RAM compared to desktop systems. Loading large files entirely into memory can cause crashes or termination by the OS. | Use streaming APIs for large files. Implement pagination for archives. Process data in chunks and write to disk incrementally rather than holding everything in memory. |
632+
| Background execution limits | Mobile operating systems aggressively kill background processes to conserve battery and resources. Long-running uploads/downloads may be interrupted. | Use platform-specific background task APIs (`WorkManager` on Android, `BGTaskScheduler` on iOS). Implement resume capability by saving progress state. Break large operations into smaller resumable units. |
633+
607634
## License
608635

609636
BSD 3-Clause License. See [LICENSE](LICENSE) for details.

0 commit comments

Comments
 (0)