How johnyburd/net-route works
Core Architecture Components
a) Platform-Agnostic Interface Layer
• Represented by src/lib.rs
• This is the public API that consumers will interact with
b) Platform-Specific Implementation Layer
• This below the interface layer
• Three distinct implementations:
• Windows (windows.rs)
• macOS (macos folder)
• Linux (linux.rs)
c) Native Code Bridge
• Route.c and wrapper.h as a bridge component
• How it interfaces with the platform-specific implementations
Component Relationships
a) Interface Layer → Platform-Specific Layer
• Use a strategy pattern representation
• How the top-level interface delegates to platform-specific implementations
b) Platform Implementations → Native Bridge
• FFI (Foreign Function Interface) connections
• Bidirectional communication where applicable
Specific Implementation Details
For each platform implementation, show:
a) macOS Implementation
• Modular structure (bind.rs, macos.rs, mod.rs)
• Relationship between these components
b) Windows/Linux Implementations
• Direct implementation paths
• System API integration points
[Application Layer (Examples)]
• ↓
[Public API Layer (lib.rs)]
• ↓
[Platform Abstraction Layer]
• ↓
[Platform-Specific Implementations]
• ↓
[Native System Calls]
Technical Details
• Conditional compilation flags
• FFI boundary points
• System API integration points
• Error handling paths
• Event listening flows (especially for the listen functionality)