Huakun

LocalSend Rust

A high-performance, type-safe implementation of LocalSend protocol (v2) in Rust

A high-performance, type-safe implementation of LocalSend protocol (v2) in Rust.

GitHub: https://github.com/CrossCopy/localsend-rs

Features

Core Functionality

  • Protocol Compatibility: Full interoperability with official LocalSend clients
  • Automatic Discovery: Multicast UDP discovery to find devices instantly
  • Direct Send: Transfer files or text directly to an IP address
  • HTTPS Security: TLS encryption with certificate fingerprinting
  • Text Messages: Support for sending and receiving instant text messages
  • CLI & TUI: Intuitive command-line interface with optional terminal UI

Performance & Quality

  • Streaming Transfers: Memory-efficient streaming for large files
  • Async I/O: Non-blocking file operations for high concurrency
  • Type Safety: Strong typing throughout (SessionId, FileId, Token, Port)
  • State Management: Type-safe state machine for transfer lifecycle
  • Well-Tested: 32+ unit tests covering core functionality

Installation

# Install CLI version
cargo install localsend-rs

# Install with interactive TUI
cargo install localsend-rs --features tui

Quick Start

# Discover devices
cargo run --features https -- discover

# Receive files
cargo run --features https -- receive --https

# Send files
cargo run --features https -- send "My Phone" ./photos/vacation.jpg

# Send text
cargo run --features https -- send "ROG16" "Hello from Rust CLI!"

# Launch TUI
cargo run --features all -- tui

Architecture

Clean, domain-driven modules:

src/
├── core/           # Core domain logic (device, file, session, transfer)
├── crypto/         # Cryptography (fingerprint, hash, tls)
├── storage/        # Storage abstraction
├── discovery/      # Multicast UDP & HTTP discovery
├── server/         # Axum HTTP/HTTPS server
├── client/         # Request-based client
├── protocol/       # Protocol types & validation
├── cli/            # Command-line interface
└── tui/            # Terminal UI

Key Design Patterns

  • Newtype Pattern: Strong typing for protocol identifiers
  • State Machine: Type-safe transfer lifecycle management
  • Builder Pattern: Fluent API for constructing DeviceInfo
  • Strategy Pattern: Pluggable FileSystem implementations

Built as a CrossCopy project.

On this page