Skip to content

feat: scaffold API, commands and tests#2

Merged
jjhafer merged 1 commit intosilvermine:masterfrom
velocitysystems:api
Apr 10, 2026
Merged

feat: scaffold API, commands and tests#2
jjhafer merged 1 commit intosilvermine:masterfrom
velocitysystems:api

Conversation

@velocitysystems
Copy link
Copy Markdown
Contributor

Summary

Scaffolds the API contract for cross-platform network connectivity detection: Tauri commands, TypeScript bindings, types, permissions, and stub Rust implementation.

API design informed by platform-native connectivity APIs — Windows NetworkInformation, iOS NWPathMonitor, and Android ConnectivityManager — unified into a single ConnectionStatus model.

Architecture

ConnectionStatus combines reachability, cost/constraint flags, and physical transport type into a single query result:

  • connected: bool — whether the device has an active internet connection
  • metered: bool — whether data usage is billed or limited (maps to NetworkCostType on Windows, NWPath.isExpensive on iOS, NET_CAPABILITY_NOT_METERED on Android)
  • constrained: bool — whether the connection is data-constrained or restricted (maps to ApproachingDataLimit/OverDataLimit/Roaming on Windows, NWPath.isConstrained on iOS, Data Saver on Android)
  • connectionType: ConnectionType — the preferred physical transport (wifi, ethernet, cellular, unknown)

ConnectivityExt trait provides Rust-side access via app.connectivity().connection_status() from any Tauri manager type. Uses managed state via .setup() — required for the mobile plugin bridge (PluginApi) when iOS/Android implementations are added.

Platform stub (src/platform.rs) returns Error::Unsupported until platform-specific implementations are added behind #[cfg] gates.

Design decisions

  • connected as a status field, not an error — iOS and Android surface "disconnected" as a normal path status, not an exception. Treating it as a field keeps the consumer code path uniform.
  • Single connectionType — when multiple interfaces are active (e.g. WiFi + Cellular), this represents the OS-determined preferred transport. Sufficient for network policy decisions without over-complicating the API.
  • Error::Unsupported only — platform-specific error variants (PluginInvoke, Windows(...)) will be added via #[cfg] + #[from] when implementations land. Matches the Tauri plugin ecosystem pattern.

Test plan

  • npm run standards passes (eslint, tsc, markdownlint, clippy, rustfmt, commitlint, check-node-version)
  • npm test passes (7 TypeScript + 7 Rust tests)
  • Serde roundtrip tested for all ConnectionType variants and ConnectionStatus
  • Error display and serialization tested
  • ConnectionStatus::disconnected() convenience constructor tested
  • TypeScript IPC mock tests cover wifi, cellular, ethernet, disconnected, and constrained scenarios
  • TypeScript error rejection tested

@velocitysystems
Copy link
Copy Markdown
Contributor Author

Thanks @jjhafer. All remaining comments have been resolved.

@jjhafer jjhafer merged commit 61be41b into silvermine:master Apr 10, 2026
1 check passed
@velocitysystems velocitysystems deleted the api branch April 14, 2026 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants